[pulseaudio-discuss] [PATCH 3/8] alsa-mixer: Fill in input and output names

David Henningsson david.henningsson at canonical.com
Tue May 5 08:01:09 PDT 2015


Fill in input_name and output_name to make routing easier for
routing modules.

Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---
 src/modules/alsa/alsa-mixer.c       | 14 +++++++++++++-
 src/modules/alsa/alsa-mixer.h       |  3 +++
 src/modules/alsa/module-alsa-card.c |  2 ++
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index 2314612..356db40 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -3362,6 +3362,8 @@ static void profile_free(pa_alsa_profile *p) {
 
     pa_xfree(p->name);
     pa_xfree(p->description);
+    pa_xfree(p->input_name);
+    pa_xfree(p->output_name);
 
     pa_xstrfreev(p->input_mapping_names);
     pa_xstrfreev(p->output_mapping_names);
@@ -4007,6 +4009,7 @@ static void profile_set_add_auto_pair(
     p->name = name;
 
     if (m) {
+        p->output_name = pa_xstrdup(m->name);
         p->output_mappings = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
         pa_idxset_put(p->output_mappings, m, NULL);
         p->priority += m->priority * 100;
@@ -4014,6 +4017,7 @@ static void profile_set_add_auto_pair(
     }
 
     if (n) {
+        p->input_name = pa_xstrdup(n->name);
         p->input_mappings = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
         pa_idxset_put(p->input_mappings, n, NULL);
         p->priority += n->priority;
@@ -4064,6 +4068,9 @@ static int profile_verify(pa_alsa_profile *p) {
     if (p->output_mapping_names) {
         char **name;
 
+        if (!p->output_name && !p->input_mapping_names)
+            p->output_name = pa_xstrdup(p->name);
+
         pa_assert(!p->output_mappings);
         p->output_mappings = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
 
@@ -4100,6 +4107,9 @@ static int profile_verify(pa_alsa_profile *p) {
     if (p->input_mapping_names) {
         char **name;
 
+        if (!p->input_name && !p->output_mapping_names)
+            p->input_name = pa_xstrdup(p->name);
+
         pa_assert(!p->input_mappings);
         p->input_mappings = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
 
@@ -4176,9 +4186,11 @@ void pa_alsa_profile_dump(pa_alsa_profile *p) {
     pa_alsa_mapping *m;
     pa_assert(p);
 
-    pa_log_debug("Profile %s (%s), priority=%u, supported=%s n_input_mappings=%u, n_output_mappings=%u",
+    pa_log_debug("Profile %s (%s), input=%s, output=%s priority=%u, supported=%s n_input_mappings=%u, n_output_mappings=%u",
                  p->name,
                  pa_strnull(p->description),
+                 pa_strnull(p->input_name),
+                 pa_strnull(p->output_name),
                  p->priority,
                  pa_yes_no(p->supported),
                  p->input_mappings ? pa_idxset_size(p->input_mappings) : 0,
diff --git a/src/modules/alsa/alsa-mixer.h b/src/modules/alsa/alsa-mixer.h
index ec39fab..232017b 100644
--- a/src/modules/alsa/alsa-mixer.h
+++ b/src/modules/alsa/alsa-mixer.h
@@ -283,6 +283,9 @@ struct pa_alsa_profile {
     char *description;
     unsigned priority;
 
+    char *input_name;
+    char *output_name;
+
     bool supported:1;
     bool fallback_input:1;
     bool fallback_output:1;
diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index 382e40d..2af7979 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -143,6 +143,8 @@ static void add_profiles(struct userdata *u, pa_hashmap *h, pa_hashmap *ports) {
 
         cp = pa_card_profile_new(ap->name, ap->description, sizeof(struct profile_data));
         cp->priority = ap->priority;
+        cp->input_name = pa_xstrdup(ap->input_name);
+        cp->output_name = pa_xstrdup(ap->output_name);
 
         if (ap->output_mappings) {
             cp->n_sinks = pa_idxset_size(ap->output_mappings);
-- 
1.9.1



More information about the pulseaudio-discuss mailing list