mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-07 13:30:03 -05:00
poll() is totally broken on Mac OS X
Even on 10.5.8, poll() does not do the right thing. Haven't checked on newer versions. Hence, wrap all occurences of poll() to pa_poll and emulate that call with select() on OSX. This is totally embarassing.
This commit is contained in:
parent
962164a3b7
commit
17d34462ea
12 changed files with 34 additions and 40 deletions
|
|
@ -33,6 +33,7 @@
|
|||
#include <pulse/i18n.h>
|
||||
#include <pulse/xmalloc.h>
|
||||
|
||||
#include <pulsecore/poll.h>
|
||||
#include <pulsecore/mutex.h>
|
||||
#include <pulsecore/thread.h>
|
||||
#include <pulsecore/core-util.h>
|
||||
|
|
@ -182,7 +183,7 @@ static void wait_for_ping(void) {
|
|||
pfd.fd = pipe_fd[0];
|
||||
pfd.events = POLLIN;
|
||||
|
||||
if ((k = poll(&pfd, 1, -1)) != 1) {
|
||||
if ((k = pa_poll(&pfd, 1, -1)) != 1) {
|
||||
pa_assert(k < 0);
|
||||
pa_assert(errno == EINTR);
|
||||
} else if ((s = read(pipe_fd[0], &x, 1)) != 1) {
|
||||
|
|
|
|||
|
|
@ -43,13 +43,18 @@
|
|||
|
||||
#include "winsock.h"
|
||||
|
||||
#ifndef HAVE_POLL_H
|
||||
|
||||
#include <pulsecore/core-util.h>
|
||||
#include <pulse/util.h>
|
||||
|
||||
#include "poll.h"
|
||||
|
||||
int poll (struct pollfd *fds, unsigned long int nfds, int timeout) {
|
||||
/* Mac OSX fails to implement poll() in a working way since 10.4. IOW, for
|
||||
* several years. We need to enable a dirty workaround and emulate that call
|
||||
* with select(), just like for Windows. sic! */
|
||||
|
||||
#if !defined(HAVE_POLL_H) || defined(OS_IS_DARWIN)
|
||||
|
||||
int pa_poll (struct pollfd *fds, unsigned long int nfds, int timeout) {
|
||||
struct timeval tv;
|
||||
fd_set rset, wset, xset;
|
||||
struct pollfd *f;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@
|
|||
Copyright (C) 1994,96,97,98,99,2000,2001,2004 Free Software Foundation, Inc.
|
||||
***/
|
||||
|
||||
#if defined(HAVE_POLL_H)
|
||||
#include <poll.h>
|
||||
#else
|
||||
|
||||
/* Event types that can be polled for. These bits may be set in `events'
|
||||
to indicate the interesting event types; they will appear in `revents'
|
||||
to indicate the status of the file descriptor. */
|
||||
|
|
@ -38,10 +42,6 @@
|
|||
#define POLLHUP 0x010 /* Hung up. */
|
||||
#define POLLNVAL 0x020 /* Invalid polling request. */
|
||||
|
||||
|
||||
/* Type used for the number of file descriptors. */
|
||||
typedef unsigned long int nfds_t;
|
||||
|
||||
/* Data structure describing a polling request. */
|
||||
struct pollfd
|
||||
{
|
||||
|
|
@ -50,9 +50,17 @@ struct pollfd
|
|||
short int revents; /* Types of events that actually occurred. */
|
||||
};
|
||||
|
||||
|
||||
/* Poll the file descriptors described by the NFDS structures starting at
|
||||
FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
|
||||
an event to occur; if TIMEOUT is -1, block until an event occurs.
|
||||
Returns the number of file descriptors with events, zero if timed out,
|
||||
or -1 for errors. */
|
||||
extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
|
||||
|
||||
#endif /* HAVE_POLL_H */
|
||||
|
||||
#if defined(HAVE_POLL_H) && !defined(OS_IS_DARWIN)
|
||||
#define pa_poll(fds,nfds,timeout) poll((fds),(nfds),(timeout))
|
||||
#else
|
||||
int pa_poll (struct pollfd *fds, unsigned long nfds, int timeout);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -30,15 +30,10 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef HAVE_POLL_H
|
||||
#include <poll.h>
|
||||
#else
|
||||
#include <pulsecore/poll.h>
|
||||
#endif
|
||||
|
||||
#include <pulse/xmalloc.h>
|
||||
#include <pulse/timeval.h>
|
||||
|
||||
#include <pulsecore/poll.h>
|
||||
#include <pulsecore/core-error.h>
|
||||
#include <pulsecore/core-rtclock.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
|
@ -304,7 +299,7 @@ int pa_rtpoll_run(pa_rtpoll *p, pa_bool_t wait_op) {
|
|||
r = ppoll(p->pollfd, p->n_pollfd_used, (!wait_op || p->quit || p->timer_enabled) ? &ts : NULL, NULL);
|
||||
}
|
||||
#else
|
||||
r = poll(p->pollfd, p->n_pollfd_used, (!wait_op || p->quit || p->timer_enabled) ? (int) ((timeout.tv_sec*1000) + (timeout.tv_usec / 1000)) : -1);
|
||||
r = pa_poll(p->pollfd, p->n_pollfd_used, (!wait_op || p->quit || p->timer_enabled) ? (int) ((timeout.tv_sec*1000) + (timeout.tv_usec / 1000)) : -1);
|
||||
#endif
|
||||
|
||||
p->timer_elapsed = r == 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue