Adding ports will not be necessary in the future, but setting the intended roles will stay relevant. For that reason it makes sense to have those two operations separate. --- src/modules/alsa/alsa-sink.c | 7 ++++--- src/modules/alsa/alsa-source.c | 7 ++++--- src/modules/alsa/alsa-ucm.c | 22 +++++++++++++--------- src/modules/alsa/alsa-ucm.h | 2 +- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index 9445b6d..aa81a6f 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -2285,9 +2285,10 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca goto fail; } - if (u->ucm_context) - pa_alsa_ucm_add_ports(&data.ports, data.proplist, u->ucm_context, true, card); - else if (u->mixer_path_set) + if (u->ucm_context) { + pa_alsa_ucm_add_ports(&data.ports, u->ucm_context, true, card); + pa_alsa_ucm_set_intended_roles(data.proplist, u->ucm_context, PA_DIRECTION_OUTPUT); + } else if (u->mixer_path_set) pa_alsa_add_ports(&data, u->mixer_path_set, card); if (mapping) diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c index 5f70cdb..feb4f0f 100644 --- a/src/modules/alsa/alsa-source.c +++ b/src/modules/alsa/alsa-source.c @@ -1991,9 +1991,10 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p goto fail; } - if (u->ucm_context) - pa_alsa_ucm_add_ports(&data.ports, data.proplist, u->ucm_context, false, card); - else if (u->mixer_path_set) + if (u->ucm_context) { + pa_alsa_ucm_add_ports(&data.ports, u->ucm_context, false, card); + pa_alsa_ucm_set_intended_roles(data.proplist, u->ucm_context, PA_DIRECTION_INPUT); + } else if (u->mixer_path_set) pa_alsa_add_ports(&data, u->mixer_path_set, card); if (mapping) diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c index e7fde1a..21efc40 100644 --- a/src/modules/alsa/alsa-ucm.c +++ b/src/modules/alsa/alsa-ucm.c @@ -861,25 +861,27 @@ void pa_alsa_ucm_add_ports_combination( void pa_alsa_ucm_add_ports( pa_hashmap **p, - pa_proplist *proplist, pa_alsa_ucm_mapping_context *context, bool is_sink, pa_card *card) { + pa_assert(p); + pa_assert(*p); + + pa_alsa_ucm_add_ports_combination(*p, context, is_sink, card->ports, card->core); +} + +void pa_alsa_ucm_set_intended_roles(pa_proplist *proplist, pa_alsa_ucm_mapping_context *context, pa_direction_t direction) { uint32_t idx; char *merged_roles; - const char *role_name = is_sink ? PA_ALSA_PROP_UCM_PLAYBACK_ROLES : PA_ALSA_PROP_UCM_CAPTURE_ROLES; + const char *role_name = direction == PA_DIRECTION_OUTPUT ? PA_ALSA_PROP_UCM_PLAYBACK_ROLES : PA_ALSA_PROP_UCM_CAPTURE_ROLES; pa_alsa_ucm_device *dev; pa_alsa_ucm_modifier *mod; char *tmp; - pa_assert(p); - pa_assert(*p); - - /* add ports first */ - pa_alsa_ucm_add_ports_combination(*p, context, is_sink, card->ports, card->core); + pa_assert(proplist); + pa_assert(context); - /* then set property PA_PROP_DEVICE_INTENDED_ROLES */ merged_roles = pa_xstrdup(pa_proplist_gets(proplist, PA_PROP_DEVICE_INTENDED_ROLES)); PA_IDXSET_FOREACH(dev, context->ucm_devices, idx) { const char *roles = pa_proplist_gets(dev->proplist, role_name); @@ -1760,7 +1762,6 @@ int pa_alsa_ucm_get_verb(snd_use_case_mgr_t *uc_mgr, const char *verb_name, cons void pa_alsa_ucm_add_ports( pa_hashmap **hash, - pa_proplist *proplist, pa_alsa_ucm_mapping_context *context, bool is_sink, pa_card *card) { @@ -1774,6 +1775,9 @@ void pa_alsa_ucm_add_ports_combination( pa_core *core) { } +void pa_alsa_ucm_set_intended_roles(pa_proplist *proplist, pa_alsa_ucm_mapping_context *context, pa_direction_t direction) { +} + int pa_alsa_ucm_set_port(pa_alsa_ucm_mapping_context *context, pa_device_port *port, bool is_sink) { return -1; } diff --git a/src/modules/alsa/alsa-ucm.h b/src/modules/alsa/alsa-ucm.h index 42e82b0..476ba41 100644 --- a/src/modules/alsa/alsa-ucm.h +++ b/src/modules/alsa/alsa-ucm.h @@ -100,7 +100,6 @@ int pa_alsa_ucm_get_verb(snd_use_case_mgr_t *uc_mgr, const char *verb_name, cons void pa_alsa_ucm_add_ports( pa_hashmap **hash, - pa_proplist *proplist, pa_alsa_ucm_mapping_context *context, bool is_sink, pa_card *card); @@ -110,6 +109,7 @@ void pa_alsa_ucm_add_ports_combination( bool is_sink, pa_hashmap *ports, pa_core *core); +void pa_alsa_ucm_set_intended_roles(pa_proplist *proplist, pa_alsa_ucm_mapping_context *context, pa_direction_t direction); int pa_alsa_ucm_set_port(pa_alsa_ucm_mapping_context *context, pa_device_port *port, bool is_sink); void pa_alsa_ucm_free(pa_alsa_ucm_config *ucm); -- 1.8.3.1