[vlc-commits] pulse: fix race where the device list was empty at start

Rémi Denis-Courmont git at videolan.org
Mon May 5 18:31:14 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon May  5 19:30:50 2014 +0300| [233e8157121367acaf3a191ab369c5c39578d829] | committer: Rémi Denis-Courmont

pulse: fix race where the device list was empty at start

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=233e8157121367acaf3a191ab369c5c39578d829
---

 modules/audio_output/pulse.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 2a4e67b..fd0e9db 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -114,7 +114,10 @@ static void sink_add_cb(pa_context *ctx, const pa_sink_info *i, int eol,
     aout_sys_t *sys = aout->sys;
 
     if (eol)
+    {
+        pa_threaded_mainloop_signal(sys->mainloop, 0);
         return;
+    }
     (void) ctx;
 
     msg_Dbg(aout, "adding sink %"PRIu32": %s (%s)", i->index, i->name,
@@ -1064,8 +1067,12 @@ static int Open(vlc_object_t *obj)
     pa_threaded_mainloop_lock(sys->mainloop);
     /* Sinks (output devices) list */
     op = pa_context_get_sink_info_list(sys->context, sink_add_cb, aout);
-    if (op != NULL)
+    if (likely(op != NULL))
+    {
+        while (pa_operation_get_state(op) == PA_OPERATION_RUNNING)
+            pa_threaded_mainloop_wait(sys->mainloop);
         pa_operation_unref(op);
+    }
 
     /* Context events */
     const pa_subscription_mask_t mask = PA_SUBSCRIPTION_MASK_SINK



More information about the vlc-commits mailing list