153a5a1b3Sopenharmony_ci/***
253a5a1b3Sopenharmony_ci  This file is part of PulseAudio.
353a5a1b3Sopenharmony_ci
453a5a1b3Sopenharmony_ci  Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
553a5a1b3Sopenharmony_ci
653a5a1b3Sopenharmony_ci  PulseAudio is free software; you can redistribute it and/or modify
753a5a1b3Sopenharmony_ci  it under the terms of the GNU Lesser General Public License as published
853a5a1b3Sopenharmony_ci  by the Free Software Foundation; either version 2.1 of the License,
953a5a1b3Sopenharmony_ci  or (at your option) any later version.
1053a5a1b3Sopenharmony_ci
1153a5a1b3Sopenharmony_ci  PulseAudio is distributed in the hope that it will be useful, but
1253a5a1b3Sopenharmony_ci  WITHOUT ANY WARRANTY; without even the implied warranty of
1353a5a1b3Sopenharmony_ci  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1453a5a1b3Sopenharmony_ci  General Public License for more details.
1553a5a1b3Sopenharmony_ci
1653a5a1b3Sopenharmony_ci  You should have received a copy of the GNU Lesser General Public License
1753a5a1b3Sopenharmony_ci  along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
1853a5a1b3Sopenharmony_ci***/
1953a5a1b3Sopenharmony_ci
2053a5a1b3Sopenharmony_ci/***
2153a5a1b3Sopenharmony_ci   Based on work for the GNU C Library.
2253a5a1b3Sopenharmony_ci   Copyright (C) 1994,96,97,98,99,2000,2001,2004 Free Software Foundation, Inc.
2353a5a1b3Sopenharmony_ci***/
2453a5a1b3Sopenharmony_ci
2553a5a1b3Sopenharmony_ci#if defined(HAVE_POLL_H)
2653a5a1b3Sopenharmony_ci#include <poll.h>
2753a5a1b3Sopenharmony_ci#elif OS_IS_WIN32 && HAVE_WINSOCK2_H && (_WIN32_WINNT >= 0x0600)
2853a5a1b3Sopenharmony_ci#include <winsock2.h>
2953a5a1b3Sopenharmony_ci#else
3053a5a1b3Sopenharmony_ci
3153a5a1b3Sopenharmony_ci/* Event types that can be polled for.  These bits may be set in `events'
3253a5a1b3Sopenharmony_ci   to indicate the interesting event types; they will appear in `revents'
3353a5a1b3Sopenharmony_ci   to indicate the status of the file descriptor.  */
3453a5a1b3Sopenharmony_ci#define POLLIN          0x001           /* There is data to read.  */
3553a5a1b3Sopenharmony_ci#define POLLPRI         0x002           /* There is urgent data to read.  */
3653a5a1b3Sopenharmony_ci#define POLLOUT         0x004           /* Writing now will not block.  */
3753a5a1b3Sopenharmony_ci
3853a5a1b3Sopenharmony_ci/* Event types always implicitly polled for.  These bits need not be set in
3953a5a1b3Sopenharmony_ci   `events', but they will appear in `revents' to indicate the status of
4053a5a1b3Sopenharmony_ci   the file descriptor.  */
4153a5a1b3Sopenharmony_ci#define POLLERR         0x008           /* Error condition.  */
4253a5a1b3Sopenharmony_ci#define POLLHUP         0x010           /* Hung up.  */
4353a5a1b3Sopenharmony_ci#define POLLNVAL        0x020           /* Invalid polling request.  */
4453a5a1b3Sopenharmony_ci
4553a5a1b3Sopenharmony_ci/* Data structure describing a polling request.  */
4653a5a1b3Sopenharmony_cistruct pollfd {
4753a5a1b3Sopenharmony_ci    int fd;                     /* File descriptor to poll.  */
4853a5a1b3Sopenharmony_ci    short int events;           /* Types of events poller cares about.  */
4953a5a1b3Sopenharmony_ci    short int revents;          /* Types of events that actually occurred.  */
5053a5a1b3Sopenharmony_ci};
5153a5a1b3Sopenharmony_ci
5253a5a1b3Sopenharmony_ci/* Poll the file descriptors described by the NFDS structures starting at
5353a5a1b3Sopenharmony_ci   FDS.  If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
5453a5a1b3Sopenharmony_ci   an event to occur; if TIMEOUT is -1, block until an event occurs.
5553a5a1b3Sopenharmony_ci   Returns the number of file descriptors with events, zero if timed out,
5653a5a1b3Sopenharmony_ci   or -1 for errors.  */
5753a5a1b3Sopenharmony_ci
5853a5a1b3Sopenharmony_ci#endif /* HAVE_POLL_H */
5953a5a1b3Sopenharmony_ci
6053a5a1b3Sopenharmony_ci#if defined(HAVE_POLL_H) && !defined(OS_IS_DARWIN)
6153a5a1b3Sopenharmony_ci#define pa_poll(fds,nfds,timeout) poll((fds),(nfds),(timeout))
6253a5a1b3Sopenharmony_ci#else
6353a5a1b3Sopenharmony_ciint pa_poll(struct pollfd *fds, unsigned long nfds, int timeout);
6453a5a1b3Sopenharmony_ci#endif
65