Commit 2e09a58d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

PulseAudio: clear all stream callbacks before disconnection

This should fix the infrequent assertions failures at exit.
parent c6b07475
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment