core: Proper poll() emulation to fix pacat and friends on Windows

Currently, Windows versions of pacat and friends fail because the current
poll emulation is not sufficient (it only works for socket fds).

Luckily Gnulib has a much better emulation that seems to work good enough.
The implementation has been largely copied (except a few bug fix
regarding timeout handling, to be pushed upstream) and works on pipes
and files as well. The copy has been obtained through their gnulib-tool utility,
which gives a LGPLv2.1+ licensed file.

This fixes the "Assertion (!e->dead) failed" error coming and lets pacat
and friends stream happily to/from a server (I didn't actually test parec).
This commit is contained in:
Thomas Martitz 2012-10-30 11:35:24 +01:00 committed by Arun Raghavan
parent fb52466d6a
commit 7e344b5ff0
4 changed files with 645 additions and 19 deletions

View file

@ -175,24 +175,6 @@ static pa_io_event* mainloop_io_new(
e->callback = callback;
e->userdata = userdata;
#ifdef OS_IS_WIN32
{
fd_set xset;
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 0;
FD_ZERO (&xset);
FD_SET (fd, &xset);
if ((select(fd, NULL, NULL, &xset, &tv) == -1) && (WSAGetLastError() == WSAENOTSOCK)) {
pa_log_warn("Cannot monitor non-socket file descriptors.");
e->dead = TRUE;
}
}
#endif
PA_LLIST_PREPEND(pa_io_event, m->io_events, e);
m->rebuild_pollfds = TRUE;
m->n_io_events ++;