[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] alsa: adjust ucm sink/source priority according to ports priority
Tanu Kaskinen
gitlab at gitlab.freedesktop.org
Fri Jul 17 09:24:58 UTC 2020
Tanu Kaskinen pushed to branch master at PulseAudio / pulseaudio
Commits:
c8653c13 by Hui Wang at 2020-07-17T09:20:50+00:00
alsa: adjust ucm sink/source priority according to ports priority
On the machines with the ucm used, the different input/output devices
often have different pcm stream, so they often belong to different
sources and sinks, this is greatly different from the design of all
devices connected to a codec (without ucm).
For example, on a machine with ucm2 used:
the internal dmic is on source#0
the external mic is on the source#1
the internal spk is on sink#0
the external headphone is on sink#1
Users expect that after plugging the external device, it will become
the active device automatically. The switch-on-port-available could
make it to be the active_port on its own source/sink, but can't make
source/sink to be default_source/sink since the sources/sinks belong
to the same profile (HiFi usually).
If we adjust the source/sink priority according to ucm ports priority,
the device_port.c could handle the default_source/sink changing then.
Usually we set higher priority for external device than internal
device in the ucm.
In order to bring the lowest side effect on the source/sink priority,
I change the ucm priority to units digit first, then add it to the
original priority.
Signed-off-by: Hui Wang <hui.wang at canonical.com>
- - - - -
2 changed files:
- src/modules/alsa/alsa-sink.c
- src/modules/alsa/alsa-source.c
Changes:
=====================================
src/modules/alsa/alsa-sink.c
=====================================
@@ -2598,6 +2598,19 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
goto fail;
}
+ if (u->ucm_context) {
+ pa_device_port *port;
+ void *state;
+ unsigned h_prio = 0;
+ PA_HASHMAP_FOREACH(port, u->sink->ports, state) {
+ if (!h_prio || port->priority > h_prio)
+ h_prio = port->priority;
+ }
+ /* ucm ports prioriy is 100, 200, ..., 900, change it to units digit */
+ h_prio = h_prio / 100;
+ u->sink->priority += h_prio;
+ }
+
if (pa_modargs_get_value_u32(ma, "deferred_volume_safety_margin",
&u->sink->thread_info.volume_change_safety_margin) < 0) {
pa_log("Failed to parse deferred_volume_safety_margin parameter");
=====================================
src/modules/alsa/alsa-source.c
=====================================
@@ -2284,6 +2284,19 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
goto fail;
}
+ if (u->ucm_context) {
+ pa_device_port *port;
+ void *state;
+ unsigned h_prio = 0;
+ PA_HASHMAP_FOREACH(port, u->source->ports, state) {
+ if (!h_prio || port->priority > h_prio)
+ h_prio = port->priority;
+ }
+ /* ucm ports prioriy is 100, 200, ..., 900, change it to units digit */
+ h_prio = h_prio / 100;
+ u->source->priority += h_prio;
+ }
+
if (pa_modargs_get_value_u32(ma, "deferred_volume_safety_margin",
&u->source->thread_info.volume_change_safety_margin) < 0) {
pa_log("Failed to parse deferred_volume_safety_margin parameter");
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/c8653c13faed5d877db3870335b870c144f01513
--
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/c8653c13faed5d877db3870335b870c144f01513
You're receiving this email because of your account on gitlab.freedesktop.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20200717/94b881a3/attachment-0001.htm>
More information about the pulseaudio-commits
mailing list