From 051f7508b4a99f4908d04364c39faf010ca00908 Mon Sep 17 00:00:00 2001 From: Georg Chini Date: Mon, 13 Jan 2020 20:40:04 +0100 Subject: [PATCH] virtual sources: Propagate asyncmsgq change after source-output move Currently, when the master of a virtual source is moved, the change of the asyncmsgq is not propagated to other attached virtual sources. This leads to a crash when the original master source is no longer available. This patch fixes the issue by modifying the moving callback to propagate the change to attached virtual sources. Virtual sinks show a similar bug but that will be fixed in a different patch series. --- src/modules/echo-cancel/module-echo-cancel.c | 8 ++++++++ src/modules/module-remap-source.c | 8 ++++++++ src/modules/module-virtual-source.c | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c index 3a4c8c949..f239492ce 100644 --- a/src/modules/echo-cancel/module-echo-cancel.c +++ b/src/modules/echo-cancel/module-echo-cancel.c @@ -1466,6 +1466,8 @@ static bool sink_input_may_move_to_cb(pa_sink_input *i, pa_sink *dest) { /* Called from main context. */ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) { struct userdata *u; + uint32_t idx; + pa_source_output *output; pa_source_output_assert_ref(o); pa_assert_ctl_context(); @@ -1477,6 +1479,12 @@ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) { } else pa_source_set_asyncmsgq(u->source, NULL); + /* Propagate asyncmsq change to attached virtual sources */ + PA_IDXSET_FOREACH(output, u->source->outputs, idx) { + if (output->destination_source && output->moving) + output->moving(output, u->source); + } + if (u->source_auto_desc && dest) { const char *y, *z; pa_proplist *pl; diff --git a/src/modules/module-remap-source.c b/src/modules/module-remap-source.c index cad04afac..281f41375 100644 --- a/src/modules/module-remap-source.c +++ b/src/modules/module-remap-source.c @@ -252,6 +252,8 @@ static void source_output_state_change_cb(pa_source_output *o, pa_source_output_ /* Called from main thread */ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) { struct userdata *u; + uint32_t idx; + pa_source_output *output; pa_source_output_assert_ref(o); pa_assert_ctl_context(); @@ -263,6 +265,12 @@ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) { } else pa_source_set_asyncmsgq(u->source, NULL); + /* Propagate asyncmsq change to attached virtual sources */ + PA_IDXSET_FOREACH(output, u->source->outputs, idx) { + if (output->destination_source && output->moving) + output->moving(output, u->source); + } + if (u->auto_desc && dest) { const char *k; pa_proplist *pl; diff --git a/src/modules/module-virtual-source.c b/src/modules/module-virtual-source.c index 7f035f6d6..22566b0bb 100644 --- a/src/modules/module-virtual-source.c +++ b/src/modules/module-virtual-source.c @@ -446,6 +446,8 @@ static void source_output_kill_cb(pa_source_output *o) { /* Called from main thread */ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) { struct userdata *u; + uint32_t idx; + pa_source_output *output; pa_source_output_assert_ref(o); pa_assert_ctl_context(); @@ -457,6 +459,12 @@ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) { } else pa_source_set_asyncmsgq(u->source, NULL); + /* Propagate asyncmsq change to attached virtual sources */ + PA_IDXSET_FOREACH(output, u->source->outputs, idx) { + if (output->destination_source && output->moving) + output->moving(output, u->source); + } + if (u->auto_desc && dest) { const char *z; pa_proplist *pl;