[pulseaudio-discuss] [PATCH 1/3] switch-on-port-available: unify input/output switching policy

Tanu Kaskinen tanuk at iki.fi
Tue Feb 16 16:38:52 UTC 2016


We don't switch away from profiles that have sinks that have ports
that are not unavailable. That rule was added to avoid automatic
switching to HDMI when plugging in a monitor, but I don't think the
rule needs to be output specific, so let's make the profile change
policy identical between input and output.
---
 src/modules/module-switch-on-port-available.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/modules/module-switch-on-port-available.c b/src/modules/module-switch-on-port-available.c
index 5dd9786..1b917ec 100644
--- a/src/modules/module-switch-on-port-available.c
+++ b/src/modules/module-switch-on-port-available.c
@@ -57,6 +57,9 @@ static bool profile_good_for_output(pa_card_profile *profile) {
 }
 
 static bool profile_good_for_input(pa_card_profile *profile) {
+    pa_source *source;
+    uint32_t idx;
+
     pa_assert(profile);
 
     if (!pa_safe_streq(profile->card->active_profile->output_name, profile->output_name))
@@ -68,6 +71,14 @@ static bool profile_good_for_input(pa_card_profile *profile) {
     if (profile->card->active_profile->max_sink_channels != profile->max_sink_channels)
         return false;
 
+    PA_IDXSET_FOREACH(source, profile->card->sources, idx) {
+        if (!source->active_port)
+            continue;
+
+        if (source->active_port->available != PA_AVAILABLE_NO)
+            return false;
+    }
+
     return true;
 }
 
-- 
2.7.0



More information about the pulseaudio-discuss mailing list