diff options
author | João Paulo Rechi Vita <jprvita@endlessm.com> | 2018-12-13 13:07:08 -0800 |
---|---|---|
committer | Tanu Kaskinen <tanuk@iki.fi> | 2018-12-14 10:22:59 +0200 |
commit | 40e72e02eb938b5c1150ce79e691efc5118770c1 (patch) | |
tree | 590ee98c34995ec720269afed348585f53608fed | |
parent | 30a551bbc45f2d213e8b2889c8bede8a9c16c9d2 (diff) | |
download | pulseaudio-40e72e02eb938b5c1150ce79e691efc5118770c1.tar.gz |
module-alsa-card: Update the active profile's availability last
The previous commit introduces logic in module-switch-on-port-available
that may change a card's active profile when its availability changes to
PA_AVAILABLE_NO. To choose the new active profile, it needs a consistent
view of the new availability of all profiles, so this commit changes the
order which the ALSA driver updates all profiles' availability to ensure
the active profile is last.
This is not generic enough to cover cases were we may want to take an
action on availability changes of profiles other than the active one
that also need a consistent view of all profiles' availability. But we
don't have any callbacks implementing such action at the moment.
-rw-r--r-- | src/modules/alsa/module-alsa-card.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c index 041d5312..47324876 100644 --- a/src/modules/alsa/module-alsa-card.c +++ b/src/modules/alsa/module-alsa-card.c @@ -368,6 +368,7 @@ static int report_jack_state(snd_mixer_elem_t *melem, unsigned int mask) { pa_alsa_jack *jack; struct temp_port_avail *tp, *tports; pa_card_profile *profile; + pa_available_t active_available = PA_AVAILABLE_UNKNOWN; pa_assert(u); @@ -463,6 +464,8 @@ static int report_jack_state(snd_mixer_elem_t *melem, unsigned int mask) { * * If there are no output ports at all, but the profile contains at least * one sink, then the output is considered to be available. */ + if (u->card->active_profile) + active_available = u->card->active_profile->available; PA_HASHMAP_FOREACH(profile, u->card->profiles, state) { pa_device_port *port; void *state2; @@ -492,9 +495,18 @@ static int report_jack_state(snd_mixer_elem_t *melem, unsigned int mask) { if ((has_input_port && !found_available_input_port) || (has_output_port && !found_available_output_port)) available = PA_AVAILABLE_NO; - pa_card_profile_set_available(profile, available); + /* We want to update the active profile's status last, so logic that + * may change the active profile based on profile availability status + * has an updated view of all profiles' availabilities. */ + if (profile == u->card->active_profile) + active_available = available; + else + pa_card_profile_set_available(profile, available); } + if (u->card->active_profile) + pa_card_profile_set_available(u->card->active_profile, active_available); + pa_xfree(tports); return 0; } |