summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanu Kaskinen <tanu.kaskinen@digia.com>2012-04-02 15:01:02 +0300
committerTanu Kaskinen <tanuk@iki.fi>2012-11-15 17:52:22 +0200
commit58de999a310757d69801d5e53dbce824dc961404 (patch)
tree9f59eb69af7d567686f1bea76ee28a57075694f5
parent387681d4179e3ac9ebeafef2cc8a4ab0a91f58f5 (diff)
mainloop: Change wakeup_requested type from pa_bool_t to pa_atomic_t.
The variable is accessed from multiple threads, so it should be atomic.
-rw-r--r--src/pulse/mainloop.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c
index 725bdb4f..179465a3 100644
--- a/src/pulse/mainloop.c
+++ b/src/pulse/mainloop.c
@@ -114,7 +114,7 @@ struct pa_mainloop {
int retval;
pa_bool_t quit:1;
- pa_bool_t wakeup_requested:1;
+ pa_atomic_t wakeup_requested;
int wakeup_pipe[2];
int wakeup_pipe_type;
@@ -774,7 +774,7 @@ void pa_mainloop_wakeup(pa_mainloop *m) {
if (m->wakeup_pipe[1] >= 0 && m->state == STATE_POLLING) {
pa_write(m->wakeup_pipe[1], &c, sizeof(c), &m->wakeup_pipe_type);
- m->wakeup_requested++;
+ pa_atomic_store(&m->wakeup_requested, TRUE);
}
}
@@ -786,10 +786,9 @@ static void clear_wakeup(pa_mainloop *m) {
if (m->wakeup_pipe[0] < 0)
return;
- if (m->wakeup_requested) {
+ if (pa_atomic_cmpxchg(&m->wakeup_requested, TRUE, FALSE)) {
while (pa_read(m->wakeup_pipe[0], &c, sizeof(c), &m->wakeup_pipe_type) == sizeof(c))
;
- m->wakeup_requested = 0;
}
}