mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-14 06:59:53 -05:00
source: move the streams to the default_source when the source unlink
When a source is unlinked, all streams of this source are moved to default_source, this action is implemented in the core rather than modules now. And after this change, the module-rescue-streams is not needed, but for backward compatibility, we keep it as a dummy module. Signed-off-by: Hui Wang <hui.wang@canonical.com>
This commit is contained in:
parent
976a366c9f
commit
5e0d5a8682
12 changed files with 35 additions and 267 deletions
|
|
@ -438,7 +438,7 @@ void pa_core_update_default_source(pa_core *core) {
|
|||
|
||||
/* try to move the streams from old_default_source to the new default_source conditionally */
|
||||
if (old_default_source)
|
||||
pa_source_move_streams_to_default_source(core, old_default_source);
|
||||
pa_source_move_streams_to_default_source(core, old_default_source, true);
|
||||
}
|
||||
|
||||
void pa_core_set_exit_idle_time(pa_core *core, int time) {
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ void pa_device_port_set_available(pa_device_port *p, pa_available_t status) {
|
|||
source = pa_device_port_get_source(p);
|
||||
if (source && p == source->active_port) {
|
||||
if (source->active_port->available == PA_AVAILABLE_NO)
|
||||
pa_source_move_streams_to_default_source(p->core, source);
|
||||
pa_source_move_streams_to_default_source(p->core, source, false);
|
||||
else
|
||||
pa_core_move_streams_to_newly_available_preferred_source(p->core, source);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -702,6 +702,9 @@ void pa_source_unlink(pa_source *s) {
|
|||
|
||||
pa_core_update_default_source(s->core);
|
||||
|
||||
if (linked)
|
||||
pa_source_move_streams_to_default_source(s->core, s, false);
|
||||
|
||||
if (s->card)
|
||||
pa_idxset_remove_by_data(s->card->sources, s, NULL);
|
||||
|
||||
|
|
@ -2993,7 +2996,7 @@ void pa_source_set_reference_volume_direct(pa_source *s, const pa_cvolume *volum
|
|||
pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_VOLUME_CHANGED], s);
|
||||
}
|
||||
|
||||
void pa_source_move_streams_to_default_source(pa_core *core, pa_source *old_source) {
|
||||
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;
|
||||
|
|
@ -3001,6 +3004,9 @@ void pa_source_move_streams_to_default_source(pa_core *core, pa_source *old_sour
|
|||
pa_assert(core);
|
||||
pa_assert(old_source);
|
||||
|
||||
if (core->state == PA_CORE_SHUTDOWN)
|
||||
return;
|
||||
|
||||
if (core->default_source == NULL || core->default_source->unlink_requested)
|
||||
return;
|
||||
|
||||
|
|
@ -3020,8 +3026,16 @@ void pa_source_move_streams_to_default_source(pa_core *core, pa_source *old_sour
|
|||
if (pa_safe_streq(old_source->name, o->preferred_source) && !old_source_is_unavailable)
|
||||
continue;
|
||||
|
||||
pa_log_info("The source output %u \"%s\" is moving to %s due to change of the default source.",
|
||||
o->index, pa_strnull(pa_proplist_gets(o->proplist, PA_PROP_APPLICATION_NAME)), core->default_source->name);
|
||||
if (!pa_source_output_may_move_to(o, core->default_source))
|
||||
continue;
|
||||
|
||||
if (default_source_changed)
|
||||
pa_log_info("The source output %u \"%s\" is moving to %s due to change of the default source.",
|
||||
o->index, pa_strnull(pa_proplist_gets(o->proplist, PA_PROP_APPLICATION_NAME)), core->default_source->name);
|
||||
else
|
||||
pa_log_info("The source output %u \"%s\" is moving to %s due to unlink of a source.",
|
||||
o->index, pa_strnull(pa_proplist_gets(o->proplist, PA_PROP_APPLICATION_NAME)), core->default_source->name);
|
||||
|
||||
pa_source_output_move_to(o, core->default_source, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -483,7 +483,7 @@ void pa_source_set_reference_volume_direct(pa_source *s, const pa_cvolume *volum
|
|||
* PA_AVAILABLE_NO, this function is called to move the streams of the old
|
||||
* default_source or the source with active_port equals PA_AVAILABLE_NO to the
|
||||
* current default_source conditionally*/
|
||||
void pa_source_move_streams_to_default_source(pa_core *core, pa_source *old_source);
|
||||
void pa_source_move_streams_to_default_source(pa_core *core, pa_source *old_source, bool default_source_changed);
|
||||
|
||||
#define pa_source_assert_io_context(s) \
|
||||
pa_assert(pa_thread_mq_get() || !PA_SOURCE_IS_LINKED((s)->state))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue