From ace863968b8053ec074ac61c8694079820126867 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 17 Oct 2009 00:06:15 +0200 Subject: 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. --- ext/pulse/pulsemixerctrl.c | 16 ++++++---------- 1 file 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); -- cgit