[pulseaudio-commits] Branch 'next' - 6 commits - src/daemon src/modules

David Henningsson diwic at kemper.freedesktop.org
Wed Apr 24 03:57:12 PDT 2013


 src/daemon/default.pa.in                                   |    5 
 src/modules/alsa/mixer/paths/analog-input.conf             |    1 
 src/modules/alsa/mixer/paths/analog-output-headphones.conf |    1 
 src/modules/alsa/module-alsa-card.c                        |    5 
 src/modules/module-switch-on-port-available.c              |   67 ++++++++++++-
 5 files changed, 69 insertions(+), 10 deletions(-)

New commits:
commit 738c93a49187f27f756024626a811331a4326e5c
Author: David Henningsson <david.henningsson at canonical.com>
Date:   Tue Apr 16 06:40:40 2013 +0200

    alsa-mixer: Switch to Headphone when Headphone mic jack is plugged in
    
    When a "Headphone Mic" jack becomes available, we do not know if
    a headphone or a mic has been plugged in. Therefore, setting both
    paths to "unknown" is, in theory, the correct thing to do.
    However, in practice, people are more likely to plug in a headphone
    rather than a mic. Therefore, allow autoswitch to the headphone port
    when the jack is plugged in.
    
    A more advanced implementation would consider what was plugged in last
    time depending on what port was selected on the input side at that
    time, and set availability accordingly. However, such an implementation
    will have to wait (probably at least until we have our fancy routing
    system implementation).
    
    Buglink: https://bugs.launchpad.net/bugs/1169143
    Signed-off-by: David Henningsson <david.henningsson at canonical.com>

diff --git a/src/modules/alsa/mixer/paths/analog-output-headphones.conf b/src/modules/alsa/mixer/paths/analog-output-headphones.conf
index e876768..e682033 100644
--- a/src/modules/alsa/mixer/paths/analog-output-headphones.conf
+++ b/src/modules/alsa/mixer/paths/analog-output-headphones.conf
@@ -44,7 +44,6 @@ state.unplugged = unknown
 # This jack can be either a headphone *or* a mic. Used on some ASUS netbooks.
 [Jack Headphone Mic]
 required-any = any
-state.plugged = unknown
 
 [Element Hardware Master]
 switch = mute

commit d75f793f1dea90ff68a59b117de96d3c510b5350
Author: David Henningsson <david.henningsson at canonical.com>
Date:   Wed Apr 24 10:59:42 2013 +0200

    alsa-mixer: Allow input fallback port for devices with no gain control
    
    I recently came across a device without any ALSA-level mixer controls,
    everything was physical knobs on the hardware.
    
    This patch enables that device to get a port too ("Analog Input").
    
    Signed-off-by: David Henningsson <david.henningsson at canonical.com>

diff --git a/src/modules/alsa/mixer/paths/analog-input.conf b/src/modules/alsa/mixer/paths/analog-input.conf
index ecacc9c..c8f8e3c 100644
--- a/src/modules/alsa/mixer/paths/analog-input.conf
+++ b/src/modules/alsa/mixer/paths/analog-input.conf
@@ -23,7 +23,6 @@
 priority = 100
 
 [Element Capture]
-required = volume
 switch = mute
 volume = merge
 override-map.1 = all

commit d136568427ed7fcbb0a2bf5bfa9765a3802d770c
Author: David Henningsson <david.henningsson at canonical.com>
Date:   Tue Apr 16 14:56:35 2013 +0200

    alsa: Fix ELD access warning on shutdown
    
    The hdmi_eld_changed callback is called by alsa-lib at shutdown.
    In that case, just exit instead of trying to access something with
    already closed handles.
    
    Signed-off-by: David Henningsson <david.henningsson at canonical.com>

diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index 9b739dc..b37eabc 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -409,6 +409,9 @@ static int hdmi_eld_changed(snd_hctl_elem_t *elem, unsigned int mask) {
     pa_hdmi_eld eld;
     bool changed = false;
 
+    if (mask == SND_CTL_EVENT_MASK_REMOVE)
+        return 0;
+
     p = find_port_with_eld_device(u->card->ports, device);
     if (p == NULL) {
         pa_log_error("Invalid device changed in ALSA: %d", device);

commit 96cb27c725ca8dc656f50fa2227615d55a07e273
Author: David Henningsson <david.henningsson at canonical.com>
Date:   Tue Apr 16 13:09:38 2013 +0200

    default.pa: Load switch-on-port-available before udev-detect
    
    We need to pick the right port as early as possible, before the
    first volume is picked up. Hence this module needs to be loaded
    before the sound card modules are loaded.
    
    Signed-off-by: David Henningsson <david.henningsson at canonical.com>

diff --git a/src/daemon/default.pa.in b/src/daemon/default.pa.in
index b4c4965..f50d929 100755
--- a/src/daemon/default.pa.in
+++ b/src/daemon/default.pa.in
@@ -44,6 +44,9 @@ load-module module-card-restore
 ### stored in /usr/share/application
 load-module module-augment-properties
 
+### Should be after module-*-restore but before module-*-detect
+load-module module-switch-on-port-available
+
 ### Load audio drivers statically
 ### (it's probably better to not load these drivers manually, but instead
 ### use module-udev-detect -- see below -- for doing this automatically)
@@ -193,8 +196,6 @@ ifelse(@HAVE_X11@, 1, [dnl
 #.endif
 ])dnl
 
-load-module module-switch-on-port-available
-
 ### Make some devices default
 #set-default-sink output
 #set-default-source input

commit 572bfbb2988cbaa9196f049361b04fb417d44741
Author: David Henningsson <david.henningsson at canonical.com>
Date:   Tue Apr 16 16:20:36 2013 +0200

    module-switch-on-port-available: Handle hotplugged cards
    
    If a card is hot-plugged (which all cards will be when we load
    this module before module-*-detect), make sure we don't start up
    a sink with an unavailable port selected.
    
    Signed-off-by: David Henningsson <david.henningsson at canonical.com>

diff --git a/src/modules/module-switch-on-port-available.c b/src/modules/module-switch-on-port-available.c
index 82ccb12..819835d 100644
--- a/src/modules/module-switch-on-port-available.c
+++ b/src/modules/module-switch-on-port-available.c
@@ -31,7 +31,9 @@
 #include "module-switch-on-port-available-symdef.h"
 
 struct userdata {
-     pa_hook_slot *callback_slot;
+     pa_hook_slot *available_slot;
+     pa_hook_slot *sink_new_slot;
+     pa_hook_slot *source_new_slot;
 };
 
 static pa_device_port* find_best_port(pa_hashmap *ports) {
@@ -240,6 +242,52 @@ static void handle_all_unavailable(pa_core *core) {
     }
 }
 
+static pa_device_port *new_sink_source(pa_hashmap *ports, const char *name) {
+
+    void *state;
+    pa_device_port *i, *p = NULL;
+
+    if (!ports)
+        return NULL;
+    if (name)
+        p = pa_hashmap_get(ports, name);
+    if (!p)
+        PA_HASHMAP_FOREACH(i, ports, state)
+            if (!p || i->priority > p->priority)
+                p = i;
+    if (!p)
+        return NULL;
+    if (p->available != PA_AVAILABLE_NO)
+        return NULL;
+
+    pa_assert_se(p = find_best_port(ports));
+    return p;
+}
+
+static pa_hook_result_t sink_new_hook_callback(pa_core *c, pa_sink_new_data *new_data, struct userdata *u) {
+
+    pa_device_port *p = new_sink_source(new_data->ports, new_data->active_port);
+
+    if (p) {
+        pa_log_debug("Switching initial port for sink '%s' to '%s'", new_data->name, p->name);
+        pa_sink_new_data_set_port(new_data, p->name);
+    }
+    return PA_HOOK_OK;
+}
+
+static pa_hook_result_t source_new_hook_callback(pa_core *c, pa_source_new_data *new_data, struct userdata *u) {
+
+    pa_device_port *p = new_sink_source(new_data->ports, new_data->active_port);
+
+    if (p) {
+        pa_log_debug("Switching initial port for source '%s' to '%s'", new_data->name,
+                     new_data->active_port);
+        pa_source_new_data_set_port(new_data, p->name);
+    }
+    return PA_HOOK_OK;
+}
+
+
 int pa__init(pa_module*m) {
     struct userdata *u;
 
@@ -247,8 +295,13 @@ int pa__init(pa_module*m) {
 
     m->userdata = u = pa_xnew(struct userdata, 1);
 
-    u->callback_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_PORT_AVAILABLE_CHANGED],
-                                       PA_HOOK_LATE, (pa_hook_cb_t) port_available_hook_callback, u);
+    /* Make sure we are after module-device-restore, so we can overwrite that suggestion if necessary */
+    u->sink_new_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_NEW],
+                                       PA_HOOK_NORMAL, (pa_hook_cb_t) sink_new_hook_callback, u);
+    u->source_new_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_NEW],
+                                         PA_HOOK_NORMAL, (pa_hook_cb_t) source_new_hook_callback, u);
+    u->available_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_PORT_AVAILABLE_CHANGED],
+                                        PA_HOOK_LATE, (pa_hook_cb_t) port_available_hook_callback, u);
 
     handle_all_unavailable(m->core);
 
@@ -263,8 +316,12 @@ void pa__done(pa_module*m) {
     if (!(u = m->userdata))
         return;
 
-    if (u->callback_slot)
-        pa_hook_slot_free(u->callback_slot);
+    if (u->available_slot)
+        pa_hook_slot_free(u->available_slot);
+    if (u->sink_new_slot)
+        pa_hook_slot_free(u->sink_new_slot);
+    if (u->source_new_slot)
+        pa_hook_slot_free(u->source_new_slot);
 
     pa_xfree(u);
 }

commit 8e640964cdd04588d98e3fdc23a5eda6edac66a6
Author: David Henningsson <david.henningsson at canonical.com>
Date:   Tue Apr 16 15:17:37 2013 +0200

    alsa: Initialize ports before sinks/sources
    
    This way port availability has been filled in when we create the
    sink, which will later enable us to pick the right port directly.
    
    Signed-off-by: David Henningsson <david.henningsson at canonical.com>

diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index 2529c0d..9b739dc 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -748,8 +748,8 @@ int pa__init(pa_module *m) {
     u->card->userdata = u;
     u->card->set_profile = card_set_profile;
 
-    init_profile(u);
     init_jacks(u);
+    init_profile(u);
     init_eld_ctls(u);
 
     if (reserve)



More information about the pulseaudio-commits mailing list