switch-on-port-available: checking the off profile when switching profile

If the current active profile is off, it has no sinks and sources, and
if users plug a headset to the audio port, the profile including this
audio port becomes available and should be selected as active profile.

But with the current design, the profile_good_for_output() will return
false because the sources in off profile and target profile doesn't
match.

For example:
(Before users plug headset)
Profiles:
         HiFi (Speaker): Default (sinks: 1, sources: 1, priority: 8100, available: no)
         HiFi (Headphones): Default (sinks: 1, sources: 1, priority: 8200, available: no)
         off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: off

(After users plug headset)
Profiles:
         HiFi (Speaker): Default (sinks: 1, sources: 1, priority: 8100, available: yes)
         HiFi (Headphones): Default (sinks: 1, sources: 1, priority: 8200, available: yes)
         off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: off

Signed-off-by: Hui Wang <hui.wang@canonical.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/354>
This commit is contained in:
Hui Wang 2020-08-20 16:21:08 +08:00 committed by Tanu Kaskinen
parent 33c89b6b76
commit 6d41b93cdb

View file

@ -71,6 +71,9 @@ static bool profile_good_for_output(pa_card_profile *profile, pa_device_port *po
card = profile->card;
if (pa_safe_streq(card->active_profile->name, "off"))
return true;
if (!pa_safe_streq(card->active_profile->input_name, profile->input_name))
return false;
@ -103,6 +106,9 @@ static bool profile_good_for_input(pa_card_profile *profile, pa_device_port *por
card = profile->card;
if (pa_safe_streq(card->active_profile->name, "off"))
return true;
if (!pa_safe_streq(card->active_profile->output_name, profile->output_name))
return false;