summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlper Nebi Yasak <alpernebiyasak@gmail.com>2021-06-29 17:56:27 +0300
committerAlper Nebi Yasak <alpernebiyasak@gmail.com>2022-06-28 15:15:08 +0300
commite49da7bcd6f0a7788bee1aa1c30979f532605b9d (patch)
treee0b6c30c0d2fe34e9ade6ffe44d20f237bf3ddeb
parent4821a0569ecbcb77d0cad5f02e040643af6a1a6c (diff)
downloadpulseaudio-e49da7bcd6f0a7788bee1aa1c30979f532605b9d.tar.gz
alsa-ucm: Disable old devices when switching profiles of same verb
While switching profiles, it was enough to switch UCM verbs since that disables all enabled UCM devices and every profile had a distinct verb. However, switching to the current verb does not disable any devices. To support multiple profiles for a verb we need to explicitly disable the old profile's devices, since they might be conflicting with the new profile's devices and will prevent them from being enabled. Compare both profiles' mappings, and disable the devices not in the new mappings. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/596>
-rw-r--r--src/modules/alsa/alsa-ucm.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c
index 2fde322ba..ec011d2d5 100644
--- a/src/modules/alsa/alsa-ucm.c
+++ b/src/modules/alsa/alsa-ucm.c
@@ -1389,6 +1389,8 @@ int pa_alsa_ucm_set_profile(pa_alsa_ucm_config *ucm, pa_card *card, pa_alsa_prof
int ret = 0;
const char *verb_name, *profile_name;
pa_alsa_ucm_verb *verb;
+ pa_alsa_mapping *map;
+ uint32_t idx;
if (new_profile == old_profile)
return 0;
@@ -1403,12 +1405,26 @@ int pa_alsa_ucm_set_profile(pa_alsa_ucm_config *ucm, pa_card *card, pa_alsa_prof
verb_name = pa_proplist_gets(verb->proplist, PA_ALSA_PROP_UCM_NAME);
}
- /* change verb */
pa_log_info("Set profile to %s", profile_name);
- pa_log_info("Set UCM verb to %s", verb_name);
- if ((snd_use_case_set(ucm->ucm_mgr, "_verb", verb_name)) < 0) {
- pa_log("Failed to set verb %s", verb_name);
- ret = -1;
+ if (ucm->active_verb != verb) {
+ /* change verb */
+ pa_log_info("Set UCM verb to %s", verb_name);
+ if ((snd_use_case_set(ucm->ucm_mgr, "_verb", verb_name)) < 0) {
+ pa_log("Failed to set verb %s", verb_name);
+ ret = -1;
+ }
+
+ } else if (ucm->active_verb) {
+ /* Disable devices not in new profile */
+ PA_IDXSET_FOREACH(map, old_profile->input_mappings, idx)
+ if (new_profile && !pa_idxset_contains(new_profile->input_mappings, map))
+ if (ucm_device_disable(ucm, map->ucm_context.ucm_device) < 0)
+ ret = -1;
+
+ PA_IDXSET_FOREACH(map, old_profile->output_mappings, idx)
+ if (new_profile && !pa_idxset_contains(new_profile->output_mappings, map))
+ if (ucm_device_disable(ucm, map->ucm_context.ucm_device) < 0)
+ ret = -1;
}
ucm->active_verb = verb;