[pulseaudio-discuss] [PATCH 03/17] alsa: Fix jack state reporting

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Mon Dec 30 05:04:38 PST 2013


The old code assumed that each path can contain only one port, which
isn't true.
---
 src/modules/alsa/module-alsa-card.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index 103a8fa..7576043 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -302,22 +302,21 @@ static void report_port_state(pa_device_port *p, struct userdata *u) {
     void *state;
     pa_alsa_jack *jack;
     pa_available_t pa = PA_AVAILABLE_UNKNOWN;
-    pa_device_port *port;
 
     PA_HASHMAP_FOREACH(jack, u->jacks, state) {
         pa_available_t cpa;
 
-        if (u->use_ucm)
-            port = pa_hashmap_get(u->card->ports, jack->name);
-        else {
-            if (jack->path)
-                port = jack->path->port;
-            else
+        if (u->use_ucm) {
+            pa_device_port *port = pa_hashmap_get(u->card->ports, jack->name);
+
+            if (p != port)
                 continue;
-        }
+        } else {
+            pa_alsa_port_data *data = PA_DEVICE_PORT_DATA(p);
 
-        if (p != port)
-            continue;
+            if (jack->path != data->path)
+                continue;
+        }
 
         cpa = jack->plugged_in ? jack->state_plugged : jack->state_unplugged;
 
@@ -365,12 +364,14 @@ static int report_jack_state(snd_hctl_elem_t *elem, unsigned int mask) {
                 pa_assert(u->card->ports);
                 port = pa_hashmap_get(u->card->ports, jack->name);
                 pa_assert(port);
+                report_port_state(port, u);
             }
             else {
-                pa_assert(jack->path && jack->path->port);
-                port = jack->path->port;
+                unsigned idx;
+
+                PA_DYNARRAY_FOREACH(port, jack->path->ports, idx)
+                    report_port_state(port, u);
             }
-            report_port_state(port, u);
         }
     return 0;
 }
-- 
1.8.3.1



More information about the pulseaudio-discuss mailing list