[vlc-commits] PulseAudio: clear all stream callbacks before disconnection

Rémi Denis-Courmont git at videolan.org
Wed Aug 10 21:27:44 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Aug 10 22:24:43 2011 +0300| [2e09a58d867f214a18c964684712842a971d1919] | committer: Rémi Denis-Courmont

PulseAudio: clear all stream callbacks before disconnection

This should fix the infrequent assertions failures at exit.

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

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

diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 9db690c..2c6de91 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -831,30 +831,20 @@ static void Close (vlc_object_t *obj)
         /* The callback takes mainloop lock, so it CANNOT be held here! */
         var_DelCallback (aout, "audio-device", StreamMove, s);
         var_Destroy (aout, "audio-device");
-    }
 
-    vlc_pa_lock();
-    if (s != NULL) {
-        pa_operation *op;
+        pa_stream_disconnect(s);
 
-        if (pa_stream_is_corked(s) > 0)
-            /* Stream paused: discard all buffers */
-            op = pa_stream_flush(s, stream_success_cb, NULL);
-        else
-            /* Stream playing: wait until buffers are played */
-            op = pa_stream_drain(s, stream_success_cb, NULL);
-        if (likely(op != NULL)) {
-#ifdef LIBPULSE_GETS_A_CLUE
-            while (pa_operation_get_state(op) == PA_OPERATION_RUNNING)
-                vlc_pa_wait();
-#endif
-            pa_operation_unref(op);
-        }
+        /* Clear all callbacks */
+        pa_stream_set_state_callback(s, NULL, NULL);
+        pa_stream_set_latency_update_callback(s, NULL, aout);
+        pa_stream_set_moved_callback(s, NULL, aout);
+        pa_stream_set_overflow_callback(s, NULL, aout);
+        pa_stream_set_started_callback(s, NULL, aout);
+        pa_stream_set_suspended_callback(s, NULL, aout);
+        pa_stream_set_underflow_callback(s, NULL, aout);
 
-        pa_stream_disconnect(s);
         pa_stream_unref(s);
     }
-    vlc_pa_unlock();
 
     vlc_pa_disconnect(obj, ctx);
     free(sys);



More information about the vlc-commits mailing list