]> git.sesse.net Git - vlc/commitdiff
Fix invalid use of the PulseAudio stream from the context callback
authorRémi Denis-Courmont <remi@remlab.net>
Fri, 28 Oct 2011 20:40:25 +0000 (23:40 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Fri, 28 Oct 2011 20:44:02 +0000 (23:44 +0300)
Make sure the context callback is registered only after the stream
is created, and unregistered before the stream is destroyed. This
should fix a potential assertion failure when stopping audio.

modules/audio_output/pulse.c

index 6c3348fc901565af333a564e677d92859722f777..904f794e62f5b985f030914246762f56f3f62b0d 100644 (file)
@@ -842,15 +842,6 @@ static int Open(vlc_object_t *obj)
     sys->desync = 0;
     sys->rate = ss.rate;
 
-    /* Context events */
-    const pa_subscription_mask_t mask = PA_SUBSCRIPTION_MASK_SINK
-                                      | PA_SUBSCRIPTION_MASK_SINK_INPUT;
-
-    pa_context_set_subscribe_callback(ctx, context_cb, aout);
-    op = pa_context_subscribe(ctx, mask, NULL, NULL);
-    if (likely(op != NULL))
-       pa_operation_unref(op);
-
     /* Channel volume */
     sys->base_volume = PA_VOLUME_NORM;
     pa_cvolume_set(&sys->cvolume, ss.channels, PA_VOLUME_NORM);
@@ -940,6 +931,14 @@ static int Open(vlc_object_t *obj)
     if (op != NULL)
         pa_operation_unref(op);
     stream_moved_cb(s, aout);
+
+    /* Context events */
+    const pa_subscription_mask_t mask = PA_SUBSCRIPTION_MASK_SINK
+                                      | PA_SUBSCRIPTION_MASK_SINK_INPUT;
+    pa_context_set_subscribe_callback(ctx, context_cb, aout);
+    op = pa_context_subscribe(ctx, mask, NULL, NULL);
+    if (likely(op != NULL))
+       pa_operation_unref(op);
     pa_threaded_mainloop_unlock(sys->mainloop);
 
     aout->format.i_format = format;
@@ -984,6 +983,7 @@ static void Close (vlc_object_t *obj)
         pa_stream_set_started_callback(s, NULL, NULL);
         pa_stream_set_suspended_callback(s, NULL, NULL);
         pa_stream_set_underflow_callback(s, NULL, NULL);
+        pa_context_set_subscribe_callback(ctx, NULL, NULL);
 
         pa_stream_unref(s);
         pa_threaded_mainloop_unlock(sys->mainloop);