From 6d41b93cdb011a08d01770624a8fe5bb9720b586 Mon Sep 17 00:00:00 2001 From: Hui Wang Date: Thu, 20 Aug 2020 16:21:08 +0800 Subject: [PATCH] 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 Part-of: --- src/modules/module-switch-on-port-available.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/module-switch-on-port-available.c b/src/modules/module-switch-on-port-available.c index 99d61a4b8..e60d7852f 100644 --- a/src/modules/module-switch-on-port-available.c +++ b/src/modules/module-switch-on-port-available.c @@ -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;