Commit bdc6b6ff authored by Georg Chini's avatar Georg Chini
Browse files

sink, source: Fix stream rescue from sinks or sources without port

Currently pa_{sink,source}_move_streams_to_default_{sink,source}() check the
availability of the old sink or source. The sink or source is only marked as
unavailable if the active port of a sink or source is not available.
Therefore sinks or sources without port are always considered available,
even if they are in the process of being unlinked and streams are not
rescued.

This patch removes the availability check because it is unnecessary. The
functions are only called if the sink or source becomes unavailable or if
the default sink or source changes, therefore the default_sink_changed or
default_source_changed argument can be used as an indicator if the old
sink or source is still present. In the case that the old default sink or
source becomes unavailable, the function will be called twice, once when
the default sink or source changes and once when the old sink or source
is unlinked.
parent 2afadb71
......@@ -3943,7 +3943,6 @@ void pa_sink_set_reference_volume_direct(pa_sink *s, const pa_cvolume *volume) {
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);
......@@ -3957,9 +3956,6 @@ void pa_sink_move_streams_to_default_sink(pa_core *core, pa_sink *old_sink, bool
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;
......@@ -3967,7 +3963,8 @@ void pa_sink_move_streams_to_default_sink(pa_core *core, pa_sink *old_sink, bool
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))
......
......@@ -2999,7 +2999,6 @@ void pa_source_set_reference_volume_direct(pa_source *s, const pa_cvolume *volum
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);
......@@ -3013,9 +3012,6 @@ void pa_source_move_streams_to_default_source(pa_core *core, pa_source *old_sour
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;
......@@ -3023,7 +3019,8 @@ void pa_source_move_streams_to_default_source(pa_core *core, pa_source *old_sour
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))
......
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