summaryrefslogtreecommitdiffstats
path: root/pulse/pulse.c
diff options
context:
space:
mode:
Diffstat (limited to 'pulse/pulse.c')
-rw-r--r--pulse/pulse.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/pulse/pulse.c b/pulse/pulse.c
index 9bd1d10..f91d0e7 100644
--- a/pulse/pulse.c
+++ b/pulse/pulse.c
@@ -148,6 +148,18 @@ static void context_state_cb(pa_context * c, void *userdata)
}
}
+static int make_nonblock(int fd) {
+ int fl;
+
+ if ((fl = fcntl(fd, F_GETFL)) < 0)
+ return fl;
+
+ if (fl & O_NONBLOCK)
+ return 0;
+
+ return fcntl(fd, F_SETFL, fl | O_NONBLOCK);
+}
+
snd_pulse_t *pulse_new(void)
{
snd_pulse_t *p;
@@ -169,8 +181,8 @@ snd_pulse_t *pulse_new(void)
p->main_fd = fd[0];
p->thread_fd = fd[1];
- fcntl(fd[0], F_SETFL, O_NONBLOCK);
- fcntl(fd[1], F_SETFL, O_NONBLOCK);
+ make_nonblock(p->main_fd);
+ make_nonblock(p->thread_fd);
p->mainloop = pa_threaded_mainloop_new();
if (!p->mainloop)