diff options
author | Alper Nebi Yasak <alpernebiyasak@gmail.com> | 2021-06-23 22:10:10 +0300 |
---|---|---|
committer | Alper Nebi Yasak <alpernebiyasak@gmail.com> | 2022-06-28 15:11:17 +0300 |
commit | 45278904167f59a8cec5630cc9f09a9f605e11b7 (patch) | |
tree | 0f881ec6872cb9ad5986e6829077b23cf85c3cfc | |
parent | 9fc7064b9a447abd308a8cc260f7f021f5637cd4 (diff) | |
download | pulseaudio-45278904167f59a8cec5630cc9f09a9f605e11b7.tar.gz |
alsa-ucm: Stop conflating profile name with UCM verb name
So far each profile had the exact name as their associated UCM verb,
which caused the one to be used where the other should have been.
Explicitly get and use the verb name where that was intended, and make
sure things about profiles aren't named after verbs.
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.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c index 20ddd9f7a..dab842a7d 100644 --- a/src/modules/alsa/alsa-ucm.c +++ b/src/modules/alsa/alsa-ucm.c @@ -991,16 +991,16 @@ static void set_eld_devices(pa_hashmap *hash) } } -static void update_mixer_paths(pa_hashmap *ports, const char *profile) { +static void update_mixer_paths(pa_hashmap *ports, const char *profile_name) { pa_device_port *port; pa_alsa_ucm_port_data *data; void *state; /* select volume controls on ports */ PA_HASHMAP_FOREACH(port, ports, state) { - pa_log_info("Updating mixer path for %s: %s", profile, port->name); + pa_log_info("Updating mixer path for %s: %s", profile_name, port->name); data = PA_DEVICE_PORT_DATA(port); - data->path = pa_hashmap_get(data->paths, profile); + data->path = pa_hashmap_get(data->paths, profile_name); } } @@ -1432,29 +1432,33 @@ void pa_alsa_ucm_add_ports( /* Change UCM verb and device to match selected card profile */ int pa_alsa_ucm_set_profile(pa_alsa_ucm_config *ucm, pa_card *card, pa_alsa_profile *new_profile, pa_alsa_profile *old_profile) { int ret = 0; - const char *profile; + const char *verb_name, *profile_name; pa_alsa_ucm_verb *verb; if (new_profile == old_profile) return 0; if (new_profile == NULL) { - profile = SND_USE_CASE_VERB_INACTIVE; verb = NULL; + profile_name = SND_USE_CASE_VERB_INACTIVE; + verb_name = SND_USE_CASE_VERB_INACTIVE; } else { - profile = new_profile->name; verb = new_profile->ucm_context.verb; + profile_name = new_profile->name; + verb_name = pa_proplist_gets(verb->proplist, PA_ALSA_PROP_UCM_NAME); } /* change verb */ - pa_log_info("Set UCM verb to %s", profile); - if ((snd_use_case_set(ucm->ucm_mgr, "_verb", profile)) < 0) { - pa_log("Failed to set verb %s", profile); + 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; } ucm->active_verb = verb; - update_mixer_paths(card->ports, profile); + update_mixer_paths(card->ports, profile_name); + return ret; } @@ -1804,8 +1808,8 @@ static int ucm_create_profile( pa_alsa_ucm_config *ucm, pa_alsa_profile_set *ps, pa_alsa_ucm_verb *verb, - const char *verb_name, - const char *verb_desc) { + const char *profile_name, + const char *profile_desc) { pa_alsa_profile *p; pa_alsa_ucm_device *dev; @@ -1813,18 +1817,19 @@ static int ucm_create_profile( int i = 0; const char *name, *sink, *source; unsigned int priority; + const char *verb_name = pa_proplist_gets(verb->proplist, PA_ALSA_PROP_UCM_NAME); pa_assert(ps); - if (pa_hashmap_get(ps->profiles, verb_name)) { - pa_log("Verb %s already exists", verb_name); + if (pa_hashmap_get(ps->profiles, profile_name)) { + pa_log("Profile %s already exists", profile_name); return -1; } p = pa_xnew0(pa_alsa_profile, 1); p->profile_set = ps; - p->name = pa_xstrdup(verb_name); - p->description = pa_xstrdup(verb_desc); + p->name = pa_xstrdup(profile_name); + p->description = pa_xstrdup(profile_desc); p->ucm_context.verb = verb; p->output_mappings = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); @@ -2038,14 +2043,18 @@ static void ucm_probe_profile_set(pa_alsa_ucm_config *ucm, pa_alsa_profile_set * void *state; pa_alsa_profile *p; pa_alsa_mapping *m; + const char *verb_name; uint32_t idx; PA_HASHMAP_FOREACH(p, ps->profiles, state) { + pa_log_info("Probing profile %s", p->name); + /* change verb */ - pa_log_info("Set ucm verb to %s", p->name); + verb_name = pa_proplist_gets(p->ucm_context.verb->proplist, PA_ALSA_PROP_UCM_NAME); + pa_log_info("Set ucm verb to %s", verb_name); - if ((snd_use_case_set(ucm->ucm_mgr, "_verb", p->name)) < 0) { - pa_log("Failed to set verb %s", p->name); + if ((snd_use_case_set(ucm->ucm_mgr, "_verb", verb_name)) < 0) { + pa_log("Failed to set verb %s", verb_name); p->supported = false; continue; } |