summaryrefslogtreecommitdiffstats
path: root/pulse
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-09-03 02:58:35 +0200
committerLennart Poettering <lennart@poettering.net>2008-09-03 20:25:37 +0200
commitfa9d943c69346b5bebda615c93bc350843c258b8 (patch)
tree04ebad774a75ef3e261d9b6f77ca2022b3e612f4 /pulse
parentc5759e34c179061dc02c9a28653a822cc586ec23 (diff)
Split out O_NONBLOCK setting into seperate function
Since we set O_NONBLOCK more than once, make it a nice and correct function.
Diffstat (limited to 'pulse')
-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)