[pulseaudio-discuss] [PATCH v2 05/10] alsa: Add device prototype support
Tanu Kaskinen
tanu.kaskinen at linux.intel.com
Mon Dec 9 10:31:42 PST 2013
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 | 1 -
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 | 10 ++++++++++
5 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index a658981..f4661f6 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -3311,7 +3311,6 @@ static void mapping_free(pa_alsa_mapping *m) {
pa_assert(!m->output_pcm);
pa_alsa_ucm_mapping_context_free(&m->ucm_context);
-
pa_xfree(m);
}
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 7934064..bcb3b08 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -157,6 +157,11 @@ static void add_profiles(struct userdata *u, pa_card_new_data *data) {
cp->n_sinks = pa_idxset_size(ap->output_mappings);
PA_IDXSET_FOREACH(m, ap->output_mappings, idx) {
+ if (!m->sink_prototype)
+ m->sink_prototype = pa_device_prototype_new(PA_DIRECTION_OUTPUT);
+
+ pa_hashmap_put(cp->sink_prototypes, m->sink_prototype, m->sink_prototype);
+
if (u->use_ucm)
pa_alsa_ucm_add_ports_combination(NULL, &m->ucm_context, true, data->ports, cp, u->core);
else
@@ -170,6 +175,11 @@ static void add_profiles(struct userdata *u, pa_card_new_data *data) {
cp->n_sources = pa_idxset_size(ap->input_mappings);
PA_IDXSET_FOREACH(m, ap->input_mappings, idx) {
+ if (!m->source_prototype)
+ m->source_prototype = pa_device_prototype_new(PA_DIRECTION_INPUT);
+
+ pa_hashmap_put(cp->source_prototypes, m->source_prototype, m->source_prototype);
+
if (u->use_ucm)
pa_alsa_ucm_add_ports_combination(NULL, &m->ucm_context, false, data->ports, cp, u->core);
else
--
1.8.3.1
More information about the pulseaudio-discuss
mailing list