mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-08 13:29:59 -05:00
card: Only update port's preferred profile if profile is saved
In case pa_card_set_profile is called with save=false, then probably it makes more sense not to update the port's preferred profile as well. Signed-off-by: David Henningsson <david.henningsson@canonical.com>
This commit is contained in:
parent
55f065301a
commit
cd46a4ef06
1 changed files with 18 additions and 9 deletions
|
|
@ -258,12 +258,22 @@ static const char* profile_name_for_dir(pa_card_profile *cp, pa_direction_t dir)
|
|||
return cp->name;
|
||||
}
|
||||
|
||||
int pa_card_set_profile(pa_card *c, pa_card_profile *profile, bool save) {
|
||||
int r;
|
||||
static void update_port_preferred_profile(pa_card *c) {
|
||||
pa_sink *sink;
|
||||
pa_source *source;
|
||||
uint32_t state;
|
||||
|
||||
PA_IDXSET_FOREACH(sink, c->sinks, state)
|
||||
if (sink->active_port)
|
||||
pa_device_port_set_preferred_profile(sink->active_port, profile_name_for_dir(c->active_profile, PA_DIRECTION_OUTPUT));
|
||||
PA_IDXSET_FOREACH(source, c->sources, state)
|
||||
if (source->active_port)
|
||||
pa_device_port_set_preferred_profile(source->active_port, profile_name_for_dir(c->active_profile, PA_DIRECTION_INPUT));
|
||||
}
|
||||
|
||||
int pa_card_set_profile(pa_card *c, pa_card_profile *profile, bool save) {
|
||||
int r;
|
||||
|
||||
pa_assert(c);
|
||||
pa_assert(profile);
|
||||
pa_assert(profile->card == c);
|
||||
|
|
@ -274,7 +284,10 @@ int pa_card_set_profile(pa_card *c, pa_card_profile *profile, bool save) {
|
|||
}
|
||||
|
||||
if (c->active_profile == profile) {
|
||||
c->save_profile = c->save_profile || save;
|
||||
if (save && !c->save_profile) {
|
||||
update_port_preferred_profile(c);
|
||||
c->save_profile = true;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -288,12 +301,8 @@ int pa_card_set_profile(pa_card *c, pa_card_profile *profile, bool save) {
|
|||
c->active_profile = profile;
|
||||
c->save_profile = save;
|
||||
|
||||
PA_IDXSET_FOREACH(sink, c->sinks, state)
|
||||
if (sink->active_port)
|
||||
pa_device_port_set_preferred_profile(sink->active_port, profile_name_for_dir(profile, PA_DIRECTION_OUTPUT));
|
||||
PA_IDXSET_FOREACH(source, c->sources, state)
|
||||
if (source->active_port)
|
||||
pa_device_port_set_preferred_profile(source->active_port, profile_name_for_dir(profile, PA_DIRECTION_INPUT));
|
||||
if (save)
|
||||
update_port_preferred_profile(c);
|
||||
|
||||
pa_hook_fire(&c->core->hooks[PA_CORE_HOOK_CARD_PROFILE_CHANGED], c);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue