sink: move streams to new appeared sinks if they prefer these sinks

When a new sink appears, all streams that have their preferred_sink
set to the new sink should be moved to the new sink.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
This commit is contained in:
Hui Wang 2019-01-16 12:10:38 +08:00
parent 40d92e9b1a
commit b886836630
4 changed files with 35 additions and 53 deletions

View file

@ -523,6 +523,37 @@ void pa_core_rttime_restart(pa_core *c, pa_time_event *e, pa_usec_t usec) {
c->mainloop->time_restart(e, pa_timeval_rtstore(&tv, usec, true));
}
void pa_core_move_streams_to_newly_available_preferred_sink(pa_core *c, pa_sink *s) {
pa_sink_input *si;
uint32_t idx;
pa_assert(c);
pa_assert(s);
PA_IDXSET_FOREACH(si, c->sink_inputs, idx) {
if (si->sink == s)
continue;
if (!si->sink)
continue;
/* Skip this sink input if it is connecting a filter sink to
* the master */
if (si->origin_sink)
continue;
/* It might happen that a stream and a sink are set up at the
same time, in which case we want to make sure we don't
interfere with that */
if (!PA_SINK_INPUT_IS_LINKED(si->state))
continue;
if (pa_safe_streq(si->preferred_sink, s->name))
pa_sink_input_move_to(si, s, false);
}
}
/* Helper macro to reduce repetition in pa_suspend_cause_to_string().
* Parameters:
* char *p: the current position in the write buffer