[pulseaudio-discuss] [PATCH v2 2/6] ucm: Don't create separate input and output jacks

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Mon May 4 11:03:41 PDT 2015


The UCM spec doesn't support separate input and output jacks, so it's
redundant to have separate input and output jacks in
pa_alsa_ucm_device.
---
 src/modules/alsa/alsa-ucm.c | 36 ++++++++++++++++++------------------
 src/modules/alsa/alsa-ucm.h |  3 +--
 2 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c
index 98d9a5d..7ddb975 100644
--- a/src/modules/alsa/alsa-ucm.c
+++ b/src/modules/alsa/alsa-ucm.c
@@ -76,6 +76,8 @@ struct ucm_info {
     unsigned priority;
 };
 
+static void device_set_jack(pa_alsa_ucm_device *device, pa_alsa_jack *jack);
+
 static struct ucm_items item[] = {
     {"PlaybackPCM", PA_ALSA_PROP_UCM_SINK},
     {"CapturePCM", PA_ALSA_PROP_UCM_SOURCE},
@@ -1263,23 +1265,20 @@ static int ucm_create_mapping(
     return ret;
 }
 
-static pa_alsa_jack* ucm_get_jack(pa_alsa_ucm_config *ucm, pa_alsa_ucm_device *device, const char *pre_tag) {
+static pa_alsa_jack* ucm_get_jack(pa_alsa_ucm_config *ucm, pa_alsa_ucm_device *device) {
     pa_alsa_jack *j;
     const char *device_name;
-    char *name;
     const char *jack_control;
     char *alsa_name;
 
     pa_assert(ucm);
     pa_assert(device);
-    pa_assert(pre_tag);
 
     device_name = pa_proplist_gets(device->proplist, PA_ALSA_PROP_UCM_NAME);
-    name = pa_sprintf_malloc("%s%s", pre_tag, device_name);
 
     PA_LLIST_FOREACH(j, ucm->jacks)
-        if (pa_streq(j->name, name))
-            goto out;
+        if (pa_streq(j->name, device_name))
+            return j;
 
     jack_control = pa_proplist_gets(device->proplist, PA_ALSA_PROP_UCM_JACK_CONTROL);
     if (jack_control)
@@ -1287,12 +1286,10 @@ static pa_alsa_jack* ucm_get_jack(pa_alsa_ucm_config *ucm, pa_alsa_ucm_device *d
     else
         alsa_name = pa_sprintf_malloc("%s Jack", device_name);
 
-    j = pa_alsa_jack_new(NULL, name, alsa_name);
+    j = pa_alsa_jack_new(NULL, device_name, alsa_name);
     pa_xfree(alsa_name);
     PA_LLIST_PREPEND(pa_alsa_jack, ucm->jacks, j);
 
-out:
-    pa_xfree(name);
     return j;
 }
 
@@ -1348,6 +1345,8 @@ static int ucm_create_profile(
         p->priority = 1000;
 
     PA_LLIST_FOREACH(dev, verb->devices) {
+        pa_alsa_jack *jack;
+
         name = pa_proplist_gets(dev->proplist, PA_ALSA_PROP_UCM_NAME);
 
         sink = pa_proplist_gets(dev->proplist, PA_ALSA_PROP_UCM_SINK);
@@ -1355,10 +1354,8 @@ static int ucm_create_profile(
 
         ucm_create_mapping(ucm, ps, p, dev, verb_name, name, sink, source);
 
-        if (sink)
-            dev->output_jack = ucm_get_jack(ucm, dev, PA_UCM_PRE_TAG_OUTPUT);
-        if (source)
-            dev->input_jack = ucm_get_jack(ucm, dev, PA_UCM_PRE_TAG_INPUT);
+        jack = ucm_get_jack(ucm, dev);
+        device_set_jack(dev, jack);
     }
 
     /* Now find modifiers that have their own PlaybackPCM and create
@@ -1447,11 +1444,8 @@ static void ucm_mapping_jack_probe(pa_alsa_mapping *m) {
         return;
 
     PA_IDXSET_FOREACH(dev, context->ucm_devices, idx) {
-        pa_alsa_jack *jack;
-        jack = m->direction == PA_ALSA_DIRECTION_OUTPUT ? dev->output_jack : dev->input_jack;
-        pa_assert (jack);
-        jack->has_control = pa_alsa_mixer_find(mixer_handle, jack->alsa_name, 0) != NULL;
-        pa_log_info("UCM jack %s has_control=%d", jack->name, jack->has_control);
+        dev->jack->has_control = pa_alsa_mixer_find(mixer_handle, dev->jack->alsa_name, 0) != NULL;
+        pa_log_info("UCM jack %s has_control=%d", dev->jack->name, dev->jack->has_control);
     }
 
     snd_mixer_close(mixer_handle);
@@ -1681,6 +1675,12 @@ void pa_alsa_ucm_roled_stream_end(pa_alsa_ucm_config *ucm, const char *role, pa_
     }
 }
 
+static void device_set_jack(pa_alsa_ucm_device *device, pa_alsa_jack *jack) {
+    pa_assert(device);
+
+    device->jack = jack;
+}
+
 #else /* HAVE_ALSA_UCM */
 
 /* Dummy functions for systems without UCM support */
diff --git a/src/modules/alsa/alsa-ucm.h b/src/modules/alsa/alsa-ucm.h
index a8c8090..8ce9b4b 100644
--- a/src/modules/alsa/alsa-ucm.h
+++ b/src/modules/alsa/alsa-ucm.h
@@ -142,8 +142,7 @@ struct pa_alsa_ucm_device {
     pa_idxset *conflicting_devices;
     pa_idxset *supported_devices;
 
-    pa_alsa_jack *input_jack;
-    pa_alsa_jack *output_jack;
+    pa_alsa_jack *jack;
 };
 
 struct pa_alsa_ucm_modifier {
-- 
1.9.3



More information about the pulseaudio-discuss mailing list