void pa_sink_move_streams_to_default_sink(pa_core *core, pa_sink *old_sink, bool default_sink_changed) {
pa_sink_input *i;
uint32_t idx;
- bool old_sink_is_unavailable = false;
pa_assert(core);
pa_assert(old_sink);
if (old_sink == core->default_sink)
return;
- if (old_sink->active_port && old_sink->active_port->available == PA_AVAILABLE_NO)
- old_sink_is_unavailable = true;
-
PA_IDXSET_FOREACH(i, old_sink->inputs, idx) {
if (!PA_SINK_INPUT_IS_LINKED(i->state))
continue;
if (!i->sink)
continue;
- if (pa_safe_streq(old_sink->name, i->preferred_sink) && !old_sink_is_unavailable)
+ /* If default_sink_changed is false, the old sink became unavailable, so all streams must be moved. */
+ if (pa_safe_streq(old_sink->name, i->preferred_sink) && default_sink_changed)
continue;
if (!pa_sink_input_may_move_to(i, core->default_sink))
void pa_source_move_streams_to_default_source(pa_core *core, pa_source *old_source, bool default_source_changed) {
pa_source_output *o;
uint32_t idx;
- bool old_source_is_unavailable = false;
pa_assert(core);
pa_assert(old_source);
if (old_source == core->default_source)
return;
- if (old_source->active_port && old_source->active_port->available == PA_AVAILABLE_NO)
- old_source_is_unavailable = true;
-
PA_IDXSET_FOREACH(o, old_source->outputs, idx) {
if (!PA_SOURCE_OUTPUT_IS_LINKED(o->state))
continue;
if (!o->source)
continue;
- if (pa_safe_streq(old_source->name, o->preferred_source) && !old_source_is_unavailable)
+ /* If default_source_changed is false, the old source became unavailable, so all streams must be moved. */
+ if (pa_safe_streq(old_source->name, o->preferred_source) && default_source_changed)
continue;
if (!pa_source_output_may_move_to(o, core->default_source))