|
|
0386fe |
From 1e13b722545a23699479bb177648f30f7be396ca Mon Sep 17 00:00:00 2001
|
|
|
0386fe |
From: Tanu Kaskinen <tanuk@iki.fi>
|
|
|
0386fe |
Date: Sun, 7 May 2017 12:12:39 +0300
|
|
|
0386fe |
Subject: [PATCH 2/4] sink, source: update the default sink/source on port
|
|
|
0386fe |
switches
|
|
|
0386fe |
|
|
|
0386fe |
When sinks are compared during the default sink selection, the active
|
|
|
0386fe |
port's availability is inspected. Therefore, the default sink should be
|
|
|
0386fe |
updated when the active port changes, because the new port may have
|
|
|
0386fe |
different availability status than the old port.
|
|
|
0386fe |
|
|
|
0386fe |
For example, let's say that a laptop has an analog sink with a speaker
|
|
|
0386fe |
and a headphone port, and headphones are initially plugged in, so both
|
|
|
0386fe |
ports can be used[1]. The headphone port is initially the active port.
|
|
|
0386fe |
There's also a null sink in the system. When the headphones are
|
|
|
0386fe |
unplugged, the headphone port becomes unavailable, and the null sink
|
|
|
0386fe |
becomes the new default sink. Then module-switch-on-connect changes the
|
|
|
0386fe |
analog sink port to speakers. Now the default sink should change back to
|
|
|
0386fe |
the analog sink, but that doesn't happen without this patch.
|
|
|
0386fe |
|
|
|
0386fe |
[1] Actually we currently mark speakers as unavailable when headphones
|
|
|
0386fe |
are plugged in, but that's not strictly necessary. My example relies on
|
|
|
0386fe |
both ports being available initially, so the bug can't be reproduced
|
|
|
0386fe |
with the current mixer configuration.
|
|
|
0386fe |
---
|
|
|
0386fe |
src/pulsecore/sink.c | 3 +++
|
|
|
0386fe |
src/pulsecore/source.c | 3 +++
|
|
|
0386fe |
2 files changed, 6 insertions(+)
|
|
|
0386fe |
|
|
|
0386fe |
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
|
|
|
0386fe |
index aa2182220..ebb13c2c9 100644
|
|
|
0386fe |
--- a/src/pulsecore/sink.c
|
|
|
0386fe |
+++ b/src/pulsecore/sink.c
|
|
|
0386fe |
@@ -3355,6 +3355,9 @@ int pa_sink_set_port(pa_sink *s, const char *name, bool save) {
|
|
|
0386fe |
|
|
|
0386fe |
pa_sink_set_port_latency_offset(s, s->active_port->latency_offset);
|
|
|
0386fe |
|
|
|
0386fe |
+ /* The active port affects the default sink selection. */
|
|
|
0386fe |
+ pa_core_update_default_sink(s->core);
|
|
|
0386fe |
+
|
|
|
0386fe |
pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_PORT_CHANGED], s);
|
|
|
0386fe |
|
|
|
0386fe |
return 0;
|
|
|
0386fe |
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
|
|
|
0386fe |
index 8ce781804..3f0f53b52 100644
|
|
|
0386fe |
--- a/src/pulsecore/source.c
|
|
|
0386fe |
+++ b/src/pulsecore/source.c
|
|
|
0386fe |
@@ -2630,6 +2630,9 @@ int pa_source_set_port(pa_source *s, const char *name, bool save) {
|
|
|
0386fe |
s->active_port = port;
|
|
|
0386fe |
s->save_port = save;
|
|
|
0386fe |
|
|
|
0386fe |
+ /* The active port affects the default source selection. */
|
|
|
0386fe |
+ pa_core_update_default_source(s->core);
|
|
|
0386fe |
+
|
|
|
0386fe |
pa_source_set_port_latency_offset(s, s->active_port->latency_offset);
|
|
|
0386fe |
|
|
|
0386fe |
pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_PORT_CHANGED], s);
|
|
|
0386fe |
--
|
|
|
0386fe |
2.14.3
|
|
|
0386fe |
|