From 833c86d35bc2b8c6d60a1c034e696d1c3b8c74c0 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Mon, 27 Nov 2023 23:25:19 +0300 Subject: [PATCH] alsa-ucm: Make one input/output mapping per UCM device PulseAudio combines UCM devices that have the same PlaybackPCM or CapturePCM value into a single mapping with multiple ports. It also creates ports in the same mapping for each valid combination of those UCM devices. Since mappings are the things we put in profiles, we can put in a profile either all devices of a joint mapping or none of them. This causes some complications with device conflicts. For example, a different UCM device might be marked as conflicting with some (but not all) of the devices in a joint mapping. In this case we can do one of three things: - Include all devices in one profile, and hope the conflicting device isn't chosen as the mapping's active port. We shouldn't do this as it puts conflicting devices in the same profile. - Make one profile with the joint group, and one with the other device. This is somewhat acceptable as we have no conflicts, but we sacrifice some compatible combinations of devices. - Do not group the devices into the same mapping, and make one profile for each compatible combination of devices. This appears to be the best option, one where we can always have the maximum number of working devices. This patch chooses the third option and makes one input and/or output mapping per UCM device, by using UCM device names instead of PCM device strings in the mapping names. Link: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/a50330a4a5ea7619f4de41c6d907a36a5e5ce022 Signed-off-by: Alper Nebi Yasak --- spa/plugins/alsa/acp/alsa-ucm.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/spa/plugins/alsa/acp/alsa-ucm.c b/spa/plugins/alsa/acp/alsa-ucm.c index 9ea9f8694..a8d937eba 100644 --- a/spa/plugins/alsa/acp/alsa-ucm.c +++ b/spa/plugins/alsa/acp/alsa-ucm.c @@ -1693,17 +1693,11 @@ static void alsa_mapping_add_ucm_modifier(pa_alsa_mapping *m, pa_alsa_ucm_modifi pa_channel_map_init(&m->channel_map); } -static pa_alsa_mapping* ucm_alsa_mapping_get(pa_alsa_ucm_config *ucm, pa_alsa_profile_set *ps, const char *verb_name, const char *device_str, bool is_sink) { +static pa_alsa_mapping* ucm_alsa_mapping_get(pa_alsa_ucm_config *ucm, pa_alsa_profile_set *ps, const char *verb_name, const char *ucm_name, bool is_sink) { pa_alsa_mapping *m; char *mapping_name; - size_t ucm_alibpref_len = 0; - /* find private alsa-lib's configuration device prefix */ - - if (ucm->alib_prefix && pa_startswith(device_str, ucm->alib_prefix)) - ucm_alibpref_len = strlen(ucm->alib_prefix); - - mapping_name = pa_sprintf_malloc("Mapping %s: %s: %s", verb_name, device_str + ucm_alibpref_len, is_sink ? "sink" : "source"); + mapping_name = pa_sprintf_malloc("Mapping %s: %s: %s", verb_name, ucm_name, is_sink ? "sink" : "source"); m = pa_alsa_mapping_get(ps, mapping_name); @@ -1727,7 +1721,7 @@ static int ucm_create_mapping_direction( pa_alsa_mapping *m; unsigned priority, rate, channels; - m = ucm_alsa_mapping_get(ucm, ps, verb_name, device_str, is_sink); + m = ucm_alsa_mapping_get(ucm, ps, verb_name, device_name, is_sink); if (!m) return -1; @@ -1776,7 +1770,7 @@ static int ucm_create_mapping_for_modifier( pa_alsa_mapping *m; - m = ucm_alsa_mapping_get(ucm, ps, verb_name, device_str, is_sink); + m = ucm_alsa_mapping_get(ucm, ps, verb_name, mod_name, is_sink); if (!m) return -1;