mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
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
This commit is contained in:
parent
12d4b5d952
commit
48d66cd5e8
9 changed files with 249 additions and 107 deletions
|
|
@ -40,6 +40,10 @@
|
|||
|
||||
#include "../polypcore/winsock.h"
|
||||
|
||||
#ifndef HAVE_PIPE
|
||||
#include "../polypcore/pipe.h"
|
||||
#endif
|
||||
|
||||
#include <polypcore/util.h>
|
||||
#include <polypcore/idxset.h>
|
||||
#include <polypcore/xmalloc.h>
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue