summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlper Nebi Yasak <alpernebiyasak@gmail.com>2021-06-06 23:00:40 +0300
committerAlper Nebi Yasak <alpernebiyasak@gmail.com>2022-06-28 15:10:26 +0300
commit9fc7064b9a447abd308a8cc260f7f021f5637cd4 (patch)
tree737ccdc6d2d3a31f7321ecc373642d1281429b71
parent880ff393f13ddc497dc9f9edff16050a02656fbd (diff)
downloadpulseaudio-9fc7064b9a447abd308a8cc260f7f021f5637cd4.tar.gz
alsa-ucm: Let profiles know their associated UCM verb
Currently each UCM verb generates one profile named the same as the verb, meaning it's trivial to know which verb the profile belongs to. This will be slightly harder to do when we generate multiple profiles per UCM verb (e.g. to make use of conflicting devices). It would still be possible to parse the profile name to get the UCM verb, but instead let's keep track of the struct instance representing the profile's associated verb. This also lets us remove a block of code searching for the verb by its name. Co-authored-by: Jaroslav Kysela <perex@perex.cz> [Alper: Reused Jaroslav's UCM profile context changes for UCM verb instead of combined devices.] 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-mixer.h5
-rw-r--r--src/modules/alsa/alsa-ucm.c20
-rw-r--r--src/modules/alsa/alsa-ucm.h5
3 files changed, 16 insertions, 14 deletions
diff --git a/src/modules/alsa/alsa-mixer.h b/src/modules/alsa/alsa-mixer.h
index 91b0ca017..b56d88113 100644
--- a/src/modules/alsa/alsa-mixer.h
+++ b/src/modules/alsa/alsa-mixer.h
@@ -318,7 +318,7 @@ struct pa_alsa_mapping {
pa_sink *sink;
pa_source *source;
- /* ucm device context*/
+ /* ucm device context */
pa_alsa_ucm_mapping_context ucm_context;
};
@@ -342,6 +342,9 @@ struct pa_alsa_profile {
pa_idxset *input_mappings;
pa_idxset *output_mappings;
+
+ /* ucm device context */
+ pa_alsa_ucm_profile_context ucm_context;
};
struct pa_alsa_decibel_fix {
diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c
index a40c3d764..20ddd9f7a 100644
--- a/src/modules/alsa/alsa-ucm.c
+++ b/src/modules/alsa/alsa-ucm.c
@@ -1438,10 +1438,13 @@ int pa_alsa_ucm_set_profile(pa_alsa_ucm_config *ucm, pa_card *card, pa_alsa_prof
if (new_profile == old_profile)
return 0;
- if (new_profile == NULL)
+ if (new_profile == NULL) {
profile = SND_USE_CASE_VERB_INACTIVE;
- else
+ verb = NULL;
+ } else {
profile = new_profile->name;
+ verb = new_profile->ucm_context.verb;
+ }
/* change verb */
pa_log_info("Set UCM verb to %s", profile);
@@ -1449,17 +1452,7 @@ int pa_alsa_ucm_set_profile(pa_alsa_ucm_config *ucm, pa_card *card, pa_alsa_prof
pa_log("Failed to set verb %s", profile);
ret = -1;
}
-
- /* find active verb */
- ucm->active_verb = NULL;
- PA_LLIST_FOREACH(verb, ucm->verbs) {
- const char *verb_name;
- verb_name = pa_proplist_gets(verb->proplist, PA_ALSA_PROP_UCM_NAME);
- if (pa_streq(verb_name, profile)) {
- ucm->active_verb = verb;
- break;
- }
- }
+ ucm->active_verb = verb;
update_mixer_paths(card->ports, profile);
return ret;
@@ -1832,6 +1825,7 @@ static int ucm_create_profile(
p->profile_set = ps;
p->name = pa_xstrdup(verb_name);
p->description = pa_xstrdup(verb_desc);
+ p->ucm_context.verb = verb;
p->output_mappings = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
p->input_mappings = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
diff --git a/src/modules/alsa/alsa-ucm.h b/src/modules/alsa/alsa-ucm.h
index e411a9262..1652aff8f 100644
--- a/src/modules/alsa/alsa-ucm.h
+++ b/src/modules/alsa/alsa-ucm.h
@@ -140,6 +140,7 @@ typedef struct pa_alsa_ucm_modifier pa_alsa_ucm_modifier;
typedef struct pa_alsa_ucm_device pa_alsa_ucm_device;
typedef struct pa_alsa_ucm_config pa_alsa_ucm_config;
typedef struct pa_alsa_ucm_mapping_context pa_alsa_ucm_mapping_context;
+typedef struct pa_alsa_ucm_profile_context pa_alsa_ucm_profile_context;
typedef struct pa_alsa_ucm_port_data pa_alsa_ucm_port_data;
typedef struct pa_alsa_ucm_volume pa_alsa_ucm_volume;
@@ -265,6 +266,10 @@ struct pa_alsa_ucm_mapping_context {
pa_idxset *ucm_modifiers;
};
+struct pa_alsa_ucm_profile_context {
+ pa_alsa_ucm_verb *verb;
+};
+
struct pa_alsa_ucm_port_data {
pa_alsa_ucm_config *ucm;
pa_device_port *core_port;