sink-input, source-output: set sink/source to NULL before the "unlink post" hook

At the time the "unlink post" hook is fired, the stream is not any more
connected to its old device, so it makes sense to reset the sink/source
pointer to NULL before firing the hook. If this is not done, the pointer
may become stale during the "unlink post" hook, because
module-bluetooth-policy does a card profile change in its "unlink post"
callback, so even if the pointer is valid when module-bluetooth-policy's
callback is called, it will be invalid in subsequent callbacks.
This commit is contained in:
Tanu Kaskinen 2016-10-12 17:20:41 +03:00
parent c3393d27a5
commit 74ff115342
2 changed files with 10 additions and 10 deletions

View file

@ -697,11 +697,6 @@ void pa_sink_input_unlink(pa_sink_input *i) {
reset_callbacks(i);
if (linked) {
pa_subscription_post(i->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_REMOVE, i->index);
pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_UNLINK_POST], i);
}
if (i->sink) {
if (PA_SINK_IS_LINKED(pa_sink_get_state(i->sink)))
pa_sink_update_status(i->sink);
@ -709,6 +704,11 @@ void pa_sink_input_unlink(pa_sink_input *i) {
i->sink = NULL;
}
if (linked) {
pa_subscription_post(i->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_REMOVE, i->index);
pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_UNLINK_POST], i);
}
pa_core_maybe_vacuum(i->core);
pa_sink_input_unref(i);

View file

@ -591,11 +591,6 @@ void pa_source_output_unlink(pa_source_output*o) {
reset_callbacks(o);
if (linked) {
pa_subscription_post(o->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_REMOVE, o->index);
pa_hook_fire(&o->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK_POST], o);
}
if (o->source) {
if (PA_SOURCE_IS_LINKED(pa_source_get_state(o->source)))
pa_source_update_status(o->source);
@ -603,6 +598,11 @@ void pa_source_output_unlink(pa_source_output*o) {
o->source = NULL;
}
if (linked) {
pa_subscription_post(o->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_REMOVE, o->index);
pa_hook_fire(&o->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK_POST], o);
}
pa_core_maybe_vacuum(o->core);
pa_source_output_unref(o);