[pulseaudio-commits] 2 commits - src/modules

David Henningsson diwic at kemper.freedesktop.org
Mon Nov 17 04:06:37 PST 2014


 src/modules/alsa/module-alsa-card.c |   25 ++++++++++++++++++-------
 src/modules/dbus/iface-device.c     |    2 +-
 2 files changed, 19 insertions(+), 8 deletions(-)

New commits:
commit 3978bbb13a88d1dd6a7d6a467c20b83492104ad4
Author: David Henningsson <david.henningsson at canonical.com>
Date:   Mon Nov 17 13:04:32 2014 +0100

    dbus-iface: Initialize "new_active" variable to NULL
    
    Fixes warning: 'new_active' may be used uninitialized in this function,
    and could potentially cause erronous behaviour in case an invalid port
    name was specified.
    
    Signed-off-by: David Henningsson <david.henningsson at canonical.com>

diff --git a/src/modules/dbus/iface-device.c b/src/modules/dbus/iface-device.c
index d469483..4469b78 100644
--- a/src/modules/dbus/iface-device.c
+++ b/src/modules/dbus/iface-device.c
@@ -727,7 +727,7 @@ static void handle_set_active_port(DBusConnection *conn, DBusMessage *msg, DBusM
     const char *new_active_path;
     pa_dbusiface_device_port *port;
     void *state;
-    pa_dbusiface_device_port *new_active;
+    pa_dbusiface_device_port *new_active = NULL;
     int r;
 
     pa_assert(conn);

commit d5fec4ca7af9241d0c2ae17df40d0fb1c18c74a0
Author: Sjoerd Simons <sjoerd at luon.net>
Date:   Sun Nov 16 23:15:50 2014 +0100

    Alsa: Correct port availability with multiple jacks
    
    In case there are two independent jacks for one port (e.g. Dock
    Headphone Jack and Headphone Jack), the availability ends up being
    incorrect if the first one was _NO (not plugged) and the second gets
    _YES (plugged). Also pulse complains about the state being inconsistent
    which isn't true.
    
    Fix this by preferring more precise states (yes/no) over unknown and yes
    over others. However in case a plugged jack makes the port unavailable
    let that overrule everything else.

diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index ed332e0..fc9a772 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -335,15 +335,26 @@ static void report_port_state(pa_device_port *p, struct userdata *u) {
 
         cpa = jack->plugged_in ? jack->state_plugged : jack->state_unplugged;
 
-        /* "Yes" and "no" trumphs "unknown" if we have more than one jack */
-        if (cpa == PA_AVAILABLE_UNKNOWN)
-            continue;
+        if (cpa == PA_AVAILABLE_NO) {
+          /* If a plugged-in jack causes the availability to go to NO, it
+           * should override all other availability information (like a
+           * blacklist) so set and bail */
+          if (jack->plugged_in) {
+            pa = cpa;
+            break;
+          }
 
-        if ((cpa == PA_AVAILABLE_NO && pa == PA_AVAILABLE_YES) ||
-            (pa == PA_AVAILABLE_NO && cpa == PA_AVAILABLE_YES))
-            pa_log_warn("Availability of port '%s' is inconsistent!", p->name);
-        else
+          /* If the current availablility is unknown go the more precise no,
+           * but otherwise don't change state */
+          if (pa == PA_AVAILABLE_UNKNOWN)
             pa = cpa;
+        } else if (cpa == PA_AVAILABLE_YES) {
+          /* Output is available through at least one jack, so go to that
+           * level of availability. We still need to continue iterating through
+           * the jacks in case a jack is plugged in that forces the state to no
+           */
+          pa = cpa;
+        }
     }
 
     pa_device_port_set_available(p, pa);



More information about the pulseaudio-commits mailing list