mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-14 06:59:53 -05:00
sink: move the streams to the default_sink when the sink is unlinked
When a sink is unlinked, all streams of this sink are moved to default_sink, this action is implemented in the core rather than modules now. Signed-off-by: Hui Wang <hui.wang@canonical.com>
This commit is contained in:
parent
60d948618e
commit
43e3a7f3c3
6 changed files with 21 additions and 189 deletions
|
|
@ -352,7 +352,7 @@ void pa_core_update_default_sink(pa_core *core) {
|
|||
|
||||
/* try to move the streams from old_default_sink to the new default_sink conditionally */
|
||||
if (old_default_sink)
|
||||
pa_sink_move_streams_to_default_sink(core, old_default_sink);
|
||||
pa_sink_move_streams_to_default_sink(core, old_default_sink, true);
|
||||
}
|
||||
|
||||
/* a < b -> return -1
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ void pa_device_port_set_available(pa_device_port *p, pa_available_t status) {
|
|||
sink = pa_device_port_get_sink(p);
|
||||
if (sink && p == sink->active_port) {
|
||||
if (sink->active_port->available == PA_AVAILABLE_NO)
|
||||
pa_sink_move_streams_to_default_sink(p->core, sink);
|
||||
pa_sink_move_streams_to_default_sink(p->core, sink, false);
|
||||
else
|
||||
pa_core_move_streams_to_newly_available_preferred_sink(p->core, sink);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -762,6 +762,9 @@ void pa_sink_unlink(pa_sink* s) {
|
|||
|
||||
pa_core_update_default_sink(s->core);
|
||||
|
||||
if (linked)
|
||||
pa_sink_move_streams_to_default_sink(s->core, s, false);
|
||||
|
||||
if (s->card)
|
||||
pa_idxset_remove_by_data(s->card->sinks, s, NULL);
|
||||
|
||||
|
|
@ -3937,7 +3940,7 @@ void pa_sink_set_reference_volume_direct(pa_sink *s, const pa_cvolume *volume) {
|
|||
pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_VOLUME_CHANGED], s);
|
||||
}
|
||||
|
||||
void pa_sink_move_streams_to_default_sink(pa_core *core, pa_sink *old_sink) {
|
||||
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;
|
||||
|
|
@ -3945,6 +3948,9 @@ void pa_sink_move_streams_to_default_sink(pa_core *core, pa_sink *old_sink) {
|
|||
pa_assert(core);
|
||||
pa_assert(old_sink);
|
||||
|
||||
if (core->state == PA_CORE_SHUTDOWN)
|
||||
return;
|
||||
|
||||
if (core->default_sink == NULL || core->default_sink->unlink_requested)
|
||||
return;
|
||||
|
||||
|
|
@ -3964,8 +3970,16 @@ void pa_sink_move_streams_to_default_sink(pa_core *core, pa_sink *old_sink) {
|
|||
if (pa_safe_streq(old_sink->name, i->preferred_sink) && !old_sink_is_unavailable)
|
||||
continue;
|
||||
|
||||
pa_log_info("The sink input %u \"%s\" is moving to %s due to change of the default sink.",
|
||||
i->index, pa_strnull(pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME)), core->default_sink->name);
|
||||
if (!pa_sink_input_may_move_to(i, core->default_sink))
|
||||
continue;
|
||||
|
||||
if (default_sink_changed)
|
||||
pa_log_info("The sink input %u \"%s\" is moving to %s due to change of the default sink.",
|
||||
i->index, pa_strnull(pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME)), core->default_sink->name);
|
||||
else
|
||||
pa_log_info("The sink input %u \"%s\" is moving to %s due to unlink of a sink.",
|
||||
i->index, pa_strnull(pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME)), core->default_sink->name);
|
||||
|
||||
pa_sink_input_move_to(i, core->default_sink, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -562,7 +562,7 @@ void pa_sink_set_reference_volume_direct(pa_sink *s, const pa_cvolume *volume);
|
|||
* PA_AVAILABLE_NO, this function is called to move the streams of the old
|
||||
* default_sink or the sink with active_port equals PA_AVAILABLE_NO to the
|
||||
* current default_sink conditionally*/
|
||||
void pa_sink_move_streams_to_default_sink(pa_core *core, pa_sink *old_sink);
|
||||
void pa_sink_move_streams_to_default_sink(pa_core *core, pa_sink *old_sink, bool default_sink_changed);
|
||||
|
||||
/* Verify that we called in IO context (aka 'thread context), or that
|
||||
* the sink is not yet set up, i.e. the thread not set up yet. See
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue