[vlc-commits] Fix invalid use of the PulseAudio stream from the context callback

Rémi Denis-Courmont git at videolan.org
Fri Oct 28 22:44:06 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Oct 28 23:40:25 2011 +0300| [f2f5a1b707f28abf691fabb1e5c540b075209a15] | committer: Rémi Denis-Courmont

Fix invalid use of the PulseAudio stream from the context callback

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.

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

 modules/audio_output/pulse.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 6c3348f..904f794 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -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);



More information about the vlc-commits mailing list