Commit bc0e7283 authored by Hui Wang's avatar Hui Wang
Browse files

sink-input: clear the preferred_sink if it is default_sink



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's avatarHui Wang <hui.wang@canonical.com>
parent 24d5d180
......@@ -1311,21 +1311,24 @@ 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) {
pa_sink *s;
if (sink_input->preferred_sink != NULL || !created_new_entry) {
pa_sink *s = NULL;
pa_xfree(entry->device);
entry->device = pa_xstrdup(sink_input->preferred_sink);
entry->device_valid = true;
device_updated = !created_new_entry && (!old->device_valid || !pa_streq(entry->device, old->device));
s = pa_namereg_get(c, entry->device, PA_NAMEREG_SINK);
if (s && s->card) {
pa_xfree(entry->card);
if (!entry->device)
entry->device_valid = false;
device_updated = !created_new_entry && !pa_safe_streq(entry->device, old->device);
pa_xfree(entry->card);
entry->card = NULL;
entry->card_valid = false;
if (entry->device_valid && (s = pa_namereg_get(c, entry->device, PA_NAMEREG_SINK)) && s->card) {
entry->card = pa_xstrdup(s->card->name);
entry->card_valid = true;
}
}
} else {
pa_source_output *source_output;
......
......@@ -1930,8 +1930,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)
......
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