sink-input: add a new API pa_sink_input_set_preferred_sink

If the sink here is NULL, that means users want to clear the
preferred_sink and move the sink-input to the default_sink, otherwise
set the preferred_sink to the sink->name and move the sink-input to
the sink. After that fire the sink_input_change event.

After adding this API, we can use this API to simplify the entry_apply
in the module-stream-restore.c.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
This commit is contained in:
Hui Wang 2019-01-15 19:28:23 +08:00
parent fbf8716685
commit 24d5d180b8
3 changed files with 18 additions and 8 deletions

View file

@ -2421,3 +2421,17 @@ void pa_sink_input_set_reference_ratio(pa_sink_input *i, const pa_cvolume *ratio
pa_cvolume_snprint_verbose(old_ratio_str, sizeof(old_ratio_str), &old_ratio, &i->channel_map, true),
pa_cvolume_snprint_verbose(new_ratio_str, sizeof(new_ratio_str), ratio, &i->channel_map, true));
}
/* Called from the main thread. */
void pa_sink_input_set_preferred_sink(pa_sink_input *i, pa_sink *s) {
pa_assert(i);
pa_xfree(i->preferred_sink);
if (s) {
i->preferred_sink = pa_xstrdup(s->name);
pa_sink_input_move_to(i, s, false);
} else {
i->preferred_sink = NULL;
pa_sink_input_move_to(i, i->core->default_sink, false);
}
}