[pulseaudio-discuss] [PATCH v3 3/8] sink-input: clear the preferred_sink if it is default_sink
Hui Wang
hui.wang at canonical.com
Sun Aug 18 05:32:36 UTC 2019
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 at canonical.com>
---
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 c8bc02ecd..0d3f9d8ac 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 if (sink_input->sink->card) {
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 7521bed08..ee3083041 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -1927,8 +1927,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
More information about the pulseaudio-discuss
mailing list