When the user moves a stream to the current default sink, the preferred_sink should be set to NULL and module-stream-restore should clear the routing for that stream in the stream database. From that point on the stream will be always routed to the default sink. Signed-off-by: Hui Wang <hui.wang@xxxxxxxxxxxxx> --- src/modules/module-stream-restore.c | 19 ++++++++++++++----- src/pulsecore/sink-input.c | 6 +++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c index 366f1a5a8..142d1e3b4 100644 --- a/src/modules/module-stream-restore.c +++ b/src/modules/module-stream-restore.c @@ -1311,13 +1311,22 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3 mute_updated = !created_new_entry && (!old->muted_valid || entry->muted != old->muted); } - if (sink_input->preferred_sink != NULL) { + if (sink_input->preferred_sink != NULL || !created_new_entry) { pa_xfree(entry->device); - entry->device = pa_xstrdup(sink_input->preferred_sink); - entry->device_valid = true; + if (sink_input->preferred_sink != NULL) { + entry->device = pa_xstrdup(sink_input->preferred_sink); + entry->device_valid = true; + } else { + entry->device = NULL; + entry->device_valid = false; + } - device_updated = !created_new_entry && (!old->device_valid || !pa_streq(entry->device, old->device)); - if (sink_input->sink->card) { + device_updated = !created_new_entry && !pa_safe_streq(entry->device, old->device); + if (entry->device_valid == false) { + pa_xfree(entry->card); + entry->card = NULL; + entry->card_valid = false; + } else { pa_xfree(entry->card); entry->card = pa_xstrdup(sink_input->sink->card->name); entry->card_valid = true; diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index 4dbc0cdef..f87c1f49f 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -1925,8 +1925,12 @@ int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, bool save) { save the preferred_sink */ if (save) { pa_xfree(i->preferred_sink); - i->preferred_sink = pa_xstrdup(dest->name); + if (dest == dest->core->default_sink) + i->preferred_sink = NULL; + else + i->preferred_sink = pa_xstrdup(dest->name); } + pa_idxset_put(dest->inputs, pa_sink_input_ref(i), NULL); PA_HASHMAP_FOREACH(v, i->volume_factor_sink_items, state) -- 2.17.1 _______________________________________________ pulseaudio-discuss mailing list pulseaudio-discuss@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss