summaryrefslogtreecommitdiff
path: root/src/modules/alsa/alsa-mixer.c
diff options
context:
space:
mode:
authorHui Wang <hui.wang@canonical.com>2020-05-08 11:19:48 +0800
committerTanu Kaskinen <tanuk@iki.fi>2020-06-10 08:46:51 +0300
commit3549a4d926c9505f3600a8eb7941dc27a9039b3f (patch)
tree21ba033b4cf594cfed12b84f02368b4f2c9ea53f /src/modules/alsa/alsa-mixer.c
parentfb3e4bb54c436ad9970999c0be02589c996895e4 (diff)
alsa-mixer: store the ucm_device with the order of their priority
There is some case that multiple ucm devices share an amixer Jack like "Headphones", "Headset" and "Mic2" share the "Headphone Mic Jack", When the Jack state is changed, the module-switch-on-port-available will process them in the order they are in the jack->ucm_devices, and the last device will decide the final setting. But usually users put priority for those devices and expect the final setting is based on the highest priority device if there is no other policies like manual selection. So here do some change to store the ucm_devices according to their priority (from low to high). For example, we have ucm devices definition like below (ucm2): SectionDevice."Mic2" { Comment "Headphones Stereo Microphone" ... Value { CapturePriority 200 ... } SectionDevice."Headset" { Comment "Headset Mono Microphone" ... Value { CapturePriority 300 ... } } Without this patch, the final setting is based on Mic2, after applying this patch, the final setting is based on the Headset (with higher priority than Mic2). Signed-off-by: Hui Wang <hui.wang@canonical.com>
Diffstat (limited to 'src/modules/alsa/alsa-mixer.c')
-rw-r--r--src/modules/alsa/alsa-mixer.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index d184aec7a..f2fe20057 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -249,10 +249,23 @@ void pa_alsa_jack_set_plugged_in(pa_alsa_jack *jack, bool plugged_in) {
}
void pa_alsa_jack_add_ucm_device(pa_alsa_jack *jack, pa_alsa_ucm_device *device) {
+ pa_alsa_ucm_device *idevice;
+ unsigned idx, prio, iprio;
+
pa_assert(jack);
pa_assert(device);
- pa_dynarray_append(jack->ucm_devices, device);
+ /* store the ucm device with the sequence of priority from low to high. this
+ * could guarantee when the jack state is changed, the device with highest
+ * priority will send to the module-switch-on-port-available last */
+ prio = device->playback_priority ? device->playback_priority : device->capture_priority;
+
+ PA_DYNARRAY_FOREACH(idevice, jack->ucm_devices, idx) {
+ iprio = idevice->playback_priority ? idevice->playback_priority : idevice->capture_priority;
+ if (iprio > prio)
+ break;
+ }
+ pa_dynarray_insert_by_index(jack->ucm_devices, device, idx);
}
void pa_alsa_jack_add_ucm_hw_mute_device(pa_alsa_jack *jack, pa_alsa_ucm_device *device) {