[pulseaudio-commits] 2 commits - src/pulse
Tanu Kaskinen
tanuk at kemper.freedesktop.org
Thu Nov 15 08:00:57 PST 2012
src/pulse/mainloop.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
New commits:
commit 872f56dc7ec43cb1511ef0d25c1736a373b3c2e2
Author: Tanu Kaskinen <tanu.kaskinen at digia.com>
Date: Mon Apr 2 15:01:05 2012 +0300
mainloop: Don't care about the mainloop state variable when waking up the mainloop.
If the mainloop is just about to enter polling, but m->state
is not POLLING yet when some other thread calls
pa_mainloop_wakeup(), the mainloop will not be woken up.
It's safe to write to the wakeup pipe at any time, so let's
just remove the check.
diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c
index 179465a..aec082c 100644
--- a/src/pulse/mainloop.c
+++ b/src/pulse/mainloop.c
@@ -772,7 +772,7 @@ void pa_mainloop_wakeup(pa_mainloop *m) {
char c = 'W';
pa_assert(m);
- if (m->wakeup_pipe[1] >= 0 && m->state == STATE_POLLING) {
+ if (m->wakeup_pipe[1] >= 0) {
pa_write(m->wakeup_pipe[1], &c, sizeof(c), &m->wakeup_pipe_type);
pa_atomic_store(&m->wakeup_requested, TRUE);
}
commit 58de999a310757d69801d5e53dbce824dc961404
Author: Tanu Kaskinen <tanu.kaskinen at digia.com>
Date: Mon Apr 2 15:01:02 2012 +0300
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.
diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c
index 725bdb4..179465a 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;
}
}
More information about the pulseaudio-commits
mailing list