Each mapping corresponds to a device prototype, except some mappings can correspond to two prototypes, because some mappings create both a sink and a source. --- src/modules/alsa/alsa-mixer.c | 13 +++++++++++++ src/modules/alsa/alsa-mixer.h | 2 ++ src/modules/alsa/alsa-sink.c | 3 +++ src/modules/alsa/alsa-source.c | 3 +++ src/modules/alsa/module-alsa-card.c | 4 ++++ 5 files changed, 25 insertions(+) diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c index a658981..41ba314 100644 --- a/src/modules/alsa/alsa-mixer.c +++ b/src/modules/alsa/alsa-mixer.c @@ -40,6 +40,7 @@ #include <pulse/xmalloc.h> #include <pulse/utf8.h> +#include <pulsecore/device-prototype.h> #include <pulsecore/i18n.h> #include <pulsecore/log.h> #include <pulsecore/macro.h> @@ -3312,6 +3313,12 @@ static void mapping_free(pa_alsa_mapping *m) { pa_alsa_ucm_mapping_context_free(&m->ucm_context); + if (m->source_prototype) + pa_device_prototype_free(m->source_prototype); + + if (m->sink_prototype) + pa_device_prototype_free(m->sink_prototype); + pa_xfree(m); } @@ -3856,6 +3863,12 @@ static int mapping_verify(pa_alsa_mapping *m, const pa_channel_map *bonus) { m->priority += 30; } + if (m->direction == PA_ALSA_DIRECTION_ANY || m->direction == PA_ALSA_DIRECTION_OUTPUT) + m->sink_prototype = pa_device_prototype_new(); + + if (m->direction == PA_ALSA_DIRECTION_ANY || m->direction == PA_ALSA_DIRECTION_INPUT) + m->source_prototype = pa_device_prototype_new(); + return 0; } diff --git a/src/modules/alsa/alsa-mixer.h b/src/modules/alsa/alsa-mixer.h index 995a34b..d964927 100644 --- a/src/modules/alsa/alsa-mixer.h +++ b/src/modules/alsa/alsa-mixer.h @@ -269,6 +269,8 @@ struct pa_alsa_mapping { snd_pcm_t *input_pcm; snd_pcm_t *output_pcm; + pa_device_prototype *sink_prototype; + pa_device_prototype *source_prototype; pa_sink *sink; pa_source *source; diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index 5fd8413..9445b6d 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -2290,6 +2290,9 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca else if (u->mixer_path_set) pa_alsa_add_ports(&data, u->mixer_path_set, card); + if (mapping) + pa_sink_new_data_set_prototype(&data, mapping->sink_prototype); + pa_node_new_data_set_fallback_name_prefix(&data.node_data, "alsa"); u->sink = pa_sink_new(m->core, &data, PA_SINK_HARDWARE | PA_SINK_LATENCY | (u->use_tsched ? PA_SINK_DYNAMIC_LATENCY : 0) | diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c index 432d61f..5f70cdb 100644 --- a/src/modules/alsa/alsa-source.c +++ b/src/modules/alsa/alsa-source.c @@ -1996,6 +1996,9 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p else if (u->mixer_path_set) pa_alsa_add_ports(&data, u->mixer_path_set, card); + if (mapping) + pa_source_new_data_set_prototype(&data, mapping->source_prototype); + pa_node_new_data_set_fallback_name_prefix(&data.node_data, "alsa"); u->source = pa_source_new(m->core, &data, PA_SOURCE_HARDWARE|PA_SOURCE_LATENCY|(u->use_tsched ? PA_SOURCE_DYNAMIC_LATENCY : 0)); diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c index e6e426e..c6f29c6 100644 --- a/src/modules/alsa/module-alsa-card.c +++ b/src/modules/alsa/module-alsa-card.c @@ -157,6 +157,8 @@ static void add_profiles(struct userdata *u, pa_hashmap *h, pa_hashmap *ports) { cp->n_sinks = pa_idxset_size(ap->output_mappings); PA_IDXSET_FOREACH(m, ap->output_mappings, idx) { + pa_hashmap_put(cp->device_prototypes, m->sink_prototype, m->sink_prototype); + if (u->use_ucm) pa_alsa_ucm_add_ports_combination(NULL, &m->ucm_context, true, ports, cp, u->core); else @@ -170,6 +172,8 @@ static void add_profiles(struct userdata *u, pa_hashmap *h, pa_hashmap *ports) { cp->n_sources = pa_idxset_size(ap->input_mappings); PA_IDXSET_FOREACH(m, ap->input_mappings, idx) { + pa_hashmap_put(cp->device_prototypes, m->source_prototype, m->source_prototype); + if (u->use_ucm) pa_alsa_ucm_add_ports_combination(NULL, &m->ucm_context, false, ports, cp, u->core); else -- 1.8.3.1