Commit f2f5a1b7 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

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.
parent 61cb650c
......@@ -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);
......
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