diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-10-17 00:06:15 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-10-17 00:12:56 +0200 |
commit | ace863968b8053ec074ac61c8694079820126867 (patch) | |
tree | 738e05675256d2b61e8174cd5c5f20cbc38f4456 | |
parent | 6ee0b41bcb113e2db50193fd797623f56242e95d (diff) |
pulse: loop while connecting to server
pthread does not guarantee that there are no spurious condition variable
wakeups, neither does pa_threaded_mainloop_xxx() which is a wrapper
around it. So we need to loop around the _wait() function to make sure
we get the right wakeup.
Also, unify the order of the wait loops across the file.
-rw-r--r-- | ext/pulse/pulsemixerctrl.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/ext/pulse/pulsemixerctrl.c b/ext/pulse/pulsemixerctrl.c index 591337bf..760bd3ec 100644 --- a/ext/pulse/pulsemixerctrl.c +++ b/ext/pulse/pulsemixerctrl.c @@ -250,16 +250,12 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c) } /* Wait until the context is ready */ - pa_threaded_mainloop_wait (c->mainloop); - - if (pa_context_get_state (c->context) != PA_CONTEXT_READY) { - GST_WARNING_OBJECT (c->object, "Failed to connect context: %s", - pa_strerror (pa_context_errno (c->context))); - goto unlock_and_fail; + while (pa_context_get_state (c->context) != PA_CONTEXT_READY) { + CHECK_DEAD_GOTO (c, unlock_and_fail); + pa_threaded_mainloop_wait (c->mainloop); } /* Subscribe to events */ - if (!(o = pa_context_subscribe (c->context, PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE, @@ -271,8 +267,8 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c) c->operation_success = FALSE; while (pa_operation_get_state (o) != PA_OPERATION_DONE) { - pa_threaded_mainloop_wait (c->mainloop); CHECK_DEAD_GOTO (c, unlock_and_fail); + pa_threaded_mainloop_wait (c->mainloop); } if (!c->operation_success) { @@ -297,8 +293,8 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c) c->operation_success = FALSE; while (pa_operation_get_state (o) != PA_OPERATION_DONE) { - pa_threaded_mainloop_wait (c->mainloop); CHECK_DEAD_GOTO (c, unlock_and_fail); + pa_threaded_mainloop_wait (c->mainloop); } pa_operation_unref (o); @@ -323,8 +319,8 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c) c->operation_success = FALSE; while (pa_operation_get_state (o) != PA_OPERATION_DONE) { - pa_threaded_mainloop_wait (c->mainloop); CHECK_DEAD_GOTO (c, unlock_and_fail); + pa_threaded_mainloop_wait (c->mainloop); } pa_operation_unref (o); |