[pulseaudio-discuss] [PATCH 3/3] core: prefer available devices during default source/sink selection
Georg Chini
georg at chini.tk
Mon Apr 9 18:38:26 UTC 2018
Because ports with disabled jack detection are set to availability
unknown by default, available ports should be preferred over ports
with unknown availability.
---
src/pulsecore/core.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c
index acd47cbb..8c074afe 100644
--- a/src/pulsecore/core.c
+++ b/src/pulsecore/core.c
@@ -325,7 +325,15 @@ static int compare_sinks(pa_sink *a, pa_sink *b) {
core = a->core;
- /* Available sinks always beat unavailable sinks. */
+ /* Available sinks always beat sinks with unknown availability. */
+ if ((!a->active_port || a->active_port->available <= PA_AVAILABLE_UNKNOWN)
+ && b->active_port && b->active_port->available == PA_AVAILABLE_YES)
+ return -1;
+ if ((!b->active_port || b->active_port->available <= PA_AVAILABLE_UNKNOWN)
+ && a->active_port && a->active_port->available == PA_AVAILABLE_YES)
+ return 1;
+
+ /* Possibly available sinks always beat unavailable sinks. */
if (a->active_port && a->active_port->available == PA_AVAILABLE_NO
&& (!b->active_port || b->active_port->available != PA_AVAILABLE_NO))
return -1;
@@ -402,7 +410,15 @@ static int compare_sources(pa_source *a, pa_source *b) {
core = a->core;
- /* Available sources always beat unavailable sources. */
+ /* Available sources always beat sources with unknown availability. */
+ if ((!a->active_port || a->active_port->available <= PA_AVAILABLE_UNKNOWN)
+ && b->active_port && b->active_port->available == PA_AVAILABLE_YES)
+ return -1;
+ if ((!b->active_port || b->active_port->available <= PA_AVAILABLE_UNKNOWN)
+ && a->active_port && a->active_port->available == PA_AVAILABLE_YES)
+ return 1;
+
+ /* Possibly available sources always beat unavailable sources. */
if (a->active_port && a->active_port->available == PA_AVAILABLE_NO
&& (!b->active_port || b->active_port->available != PA_AVAILABLE_NO))
return -1;
--
2.14.1
More information about the pulseaudio-discuss
mailing list