From 303cff04eb8c091fb0c7665440797fc56f07d570 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Fri, 15 Nov 2013 09:33:39 +0100 Subject: [PATCH] sink/source: When picking the initial ports, prefer ones that are not unavailable. This does for sinks/source ports what f434087e42b did for card profiles. --- src/pulsecore/sink.c | 11 ++++++++++- src/pulsecore/source.c | 12 +++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 81fefbc..95cf9b6 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -304,9 +304,18 @@ pa_sink* pa_sink_new( void *state; pa_device_port *p; - PA_HASHMAP_FOREACH(p, s->ports, state) + PA_HASHMAP_FOREACH(p, s->ports, state) { + if (p->available == PA_AVAILABLE_NO) + continue; + if (!s->active_port || p->priority > s->active_port->priority) s->active_port = p; + } + if (!s->active_port) { + PA_HASHMAP_FOREACH(p, s->ports, state) + if (!s->active_port || p->priority > s->active_port->priority) + s->active_port = p; + } } if (s->active_port) diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c index 92411de..a6dc9bf 100644 --- a/src/pulsecore/source.c +++ b/src/pulsecore/source.c @@ -292,9 +292,19 @@ pa_source* pa_source_new( void *state; pa_device_port *p; - PA_HASHMAP_FOREACH(p, s->ports, state) + PA_HASHMAP_FOREACH(p, s->ports, state) { + if (p->available == PA_AVAILABLE_NO) + continue; + if (!s->active_port || p->priority > s->active_port->priority) s->active_port = p; + } + + if (!s->active_port) { + PA_HASHMAP_FOREACH(p, s->ports, state) + if (!s->active_port || p->priority > s->active_port->priority) + s->active_port = p; + } } if (s->active_port) -- 2.7.4