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..c52d6e7 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 (s->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) -- 1.8.4.3