From 48d66cd5e89764b00fe225db4823b3392a759942 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 11 May 2006 11:08:58 +0000 Subject: Handle pipes on platforms where they are non-existant of broken. We do this by creating a TCP socket pair instead of a normal pipe. Since Windows isn't UNIX-y enough to support read()/write() on sockets, we also need a wrapper to handle read() vs recv() and write() vs send(). git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@840 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/polyp/mainloop.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/polyp/mainloop.c') diff --git a/src/polyp/mainloop.c b/src/polyp/mainloop.c index 98b3f3c6..589fe77e 100644 --- a/src/polyp/mainloop.c +++ b/src/polyp/mainloop.c @@ -40,6 +40,10 @@ #include "../polypcore/winsock.h" +#ifndef HAVE_PIPE +#include "../polypcore/pipe.h" +#endif + #include #include #include @@ -330,18 +334,14 @@ pa_mainloop *pa_mainloop_new(void) { m = pa_xmalloc(sizeof(pa_mainloop)); -#ifndef OS_IS_WIN32 if (pipe(m->wakeup_pipe) < 0) { + pa_log_error(__FILE__": ERROR: cannot create wakeup pipe"); pa_xfree(m); return NULL; } pa_make_nonblock_fd(m->wakeup_pipe[0]); pa_make_nonblock_fd(m->wakeup_pipe[1]); -#else - m->wakeup_pipe[0] = -1; - m->wakeup_pipe[1] = -1; -#endif m->io_events = pa_idxset_new(NULL, NULL); m->defer_events = pa_idxset_new(NULL, NULL); @@ -622,7 +622,7 @@ void pa_mainloop_wakeup(pa_mainloop *m) { assert(m); if (m->wakeup_pipe[1] >= 0) - write(m->wakeup_pipe[1], &c, sizeof(c)); + pa_write(m->wakeup_pipe[1], &c, sizeof(c)); } static void clear_wakeup(pa_mainloop *m) { @@ -633,7 +633,7 @@ static void clear_wakeup(pa_mainloop *m) { if (m->wakeup_pipe[0] < 0) return; - while (read(m->wakeup_pipe[0], &c, sizeof(c)) == sizeof(c)); + while (pa_read(m->wakeup_pipe[0], &c, sizeof(c)) == sizeof(c)); } int pa_mainloop_prepare(pa_mainloop *m, int timeout) { -- cgit