sink, source: update the default sink/source on port switches
authorTanu Kaskinen <tanuk@iki.fi>
Sun, 7 May 2017 09:12:39 +0000 (12:12 +0300)
committerTanu Kaskinen <tanuk@iki.fi>
Wed, 17 May 2017 20:05:04 +0000 (23:05 +0300)
commit4c6843f02067bed2a299bed1651d00832e2afea0
tree2ac855aa6b64a5b53e87e95144dfa034505a8037
parent61860e7cebd55b6bf95169cd5c65f31316bcebdc
sink, source: update the default sink/source on port switches

When sinks are compared during the default sink selection, the active
port's availability is inspected. Therefore, the default sink should be
updated when the active port changes, because the new port may have
different availability status than the old port.

For example, let's say that a laptop has an analog sink with a speaker
and a headphone port, and headphones are initially plugged in, so both
ports can be used[1]. The headphone port is initially the active port.
There's also a null sink in the system. When the headphones are
unplugged, the headphone port becomes unavailable, and the null sink
becomes the new default sink. Then module-switch-on-port-available
changes the analog sink port to speakers. Now the default sink should
change back to the analog sink, but that doesn't happen without this
patch.

[1] Actually we currently mark speakers as unavailable when headphones
are plugged in, but that's not strictly necessary. My example relies on
both ports being available initially, so the bug can't be reproduced
with the current mixer configuration.
src/pulsecore/sink.c
src/pulsecore/source.c