[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v1.0-dev-251-gaaab340

Colin Guthrie gitmailer-noreply at 0pointer.de
Tue Apr 5 03:25:13 PDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The master branch has been updated
      from  c083259464e1e140165795a8bf6e3c0cfcbc64fe (commit)

- Log -----------------------------------------------------------------
aaab340 bluetooth-device: fix rounding errors caused by few bt volume steps
1bbafdb stream-restore: add version to new entry.
1020065 doc: Fix typo
b14f0d7 alsa: Fix log output to inform about positive base volumes correctly.
5d43aba bluetooth: drop data every 500ms on oor condition
6ed3a7d switch-on-connect: Add a new module to allow for hotplugged devices to be used by default.
-----------------------------------------------------------------------

Summary of changes:
 src/Makefile.am                                 |   10 +-
 src/modules/alsa/alsa-sink.c                    |    5 +-
 src/modules/alsa/alsa-source.c                  |    5 +-
 src/modules/bluetooth/module-bluetooth-device.c |   72 ++++++---
 src/modules/module-stream-restore.c             |    1 +
 src/modules/module-switch-on-connect.c          |  187 +++++++++++++++++++++++
 src/pulse/stream.h                              |    2 +-
 7 files changed, 249 insertions(+), 33 deletions(-)
 create mode 100644 src/modules/module-switch-on-connect.c

-----------------------------------------------------------------------

commit 6ed3a7dcc9de81469c5d35a5256e5f50bd48f804
Author: Michael Terry <michael.terry at canonical.com>
Date:   Sun Apr 3 13:42:44 2011 +0100

    switch-on-connect: Add a new module to allow for hotplugged devices to be used by default.
    
    This module implements a simply policy decision that any newly plugged
    in devices should be used.
    
    This is a reasonable approach and paprefs will be updated to allow for
    this option to be turned on or off.
    
    This is more or less a stop-gap solution. When priority lists are
    implemented in the core, then policy modules may ultimately be
    re-engineered to adjust the priority lists rather than doing any of
    their own routing per-se.

diff --git a/src/Makefile.am b/src/Makefile.am
index bdedded..dc2a1cd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1051,7 +1051,8 @@ modlibexec_LTLIBRARIES += \
 		module-cork-music-on-phone.la \
 		module-loopback.la \
 		module-virtual-sink.la \
-		module-virtual-source.la
+		module-virtual-source.la \
+		module-switch-on-connect.la
 
 # See comment at librtp.la above
 if !OS_IS_WIN32
@@ -1338,7 +1339,8 @@ SYMDEF_FILES = \
 		module-dbus-protocol-symdef.h \
 		module-loopback-symdef.h \
 		module-virtual-sink-symdef.h \
-		module-virtual-source-symdef.h
+		module-virtual-source-symdef.h \
+		module-switch-on-connect-symdef.h
 
 EXTRA_DIST += $(SYMDEF_FILES)
 BUILT_SOURCES += $(SYMDEF_FILES) builddirs
@@ -1480,6 +1482,10 @@ module_combine_la_SOURCES = modules/module-combine.c
 module_combine_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_combine_la_LIBADD = $(MODULE_LIBADD)
 
+module_switch_on_connect_la_SOURCES = modules/module-switch-on-connect.c
+module_switch_on_connect_la_LDFLAGS = $(MODULE_LDFLAGS)
+module_switch_on_connect_la_LIBADD = $(MODULE_LIBADD)
+
 module_remap_sink_la_SOURCES = modules/module-remap-sink.c
 module_remap_sink_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_remap_sink_la_LIBADD = $(MODULE_LIBADD)
diff --git a/src/modules/module-switch-on-connect.c b/src/modules/module-switch-on-connect.c
new file mode 100644
index 0000000..b121fd9
--- /dev/null
+++ b/src/modules/module-switch-on-connect.c
@@ -0,0 +1,187 @@
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2006 Lennart Poettering
+  Copyright 2009 Canonical Ltd
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2.1 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <pulse/xmalloc.h>
+
+#include <pulsecore/core.h>
+#include <pulsecore/sink-input.h>
+#include <pulsecore/source-output.h>
+#include <pulsecore/modargs.h>
+#include <pulsecore/log.h>
+#include <pulsecore/namereg.h>
+#include <pulsecore/core-util.h>
+
+#include "module-switch-on-connect-symdef.h"
+
+PA_MODULE_AUTHOR("Michael Terry");
+PA_MODULE_DESCRIPTION("When a sink/source is added, switch to it");
+PA_MODULE_VERSION(PACKAGE_VERSION);
+PA_MODULE_LOAD_ONCE(TRUE);
+
+static const char* const valid_modargs[] = {
+    NULL,
+};
+
+struct userdata {
+    pa_hook_slot
+        *sink_put_slot,
+        *source_put_slot;
+};
+
+static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, void* userdata) {
+    pa_sink_input *i;
+    uint32_t idx;
+    pa_sink *def;
+    const char *s;
+
+    pa_assert(c);
+    pa_assert(sink);
+
+    /* Don't want to run during startup or shutdown */
+    if (c->state != PA_CORE_RUNNING)
+        return PA_HOOK_OK;
+
+    /* Don't switch to any internal devices */
+    if ((s = pa_proplist_gets(sink->proplist, PA_PROP_DEVICE_BUS))) {
+        if (pa_streq(s, "pci"))
+            return PA_HOOK_OK;
+        else if (pa_streq(s, "isa"))
+            return PA_HOOK_OK;
+    }
+
+    def = pa_namereg_get_default_sink(c);
+    if (def == sink)
+        return PA_HOOK_OK;
+
+    /* Actually do the switch to the new sink */
+    pa_namereg_set_default_sink(c, sink);
+
+    /* Now move all old inputs over */
+    if (pa_idxset_size(def->inputs) <= 0) {
+        pa_log_debug("No sink inputs to move away.");
+        return PA_HOOK_OK;
+    }
+
+    PA_IDXSET_FOREACH(i, def->inputs, idx) {
+        if (i->save_sink)
+            continue;
+
+        if (pa_sink_input_move_to(i, sink, FALSE) < 0)
+            pa_log_info("Failed to move sink input %u \"%s\" to %s.", i->index,
+                        pa_strnull(pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME)), sink->name);
+        else
+            pa_log_info("Sucessfully moved sink input %u \"%s\" to %s.", i->index,
+                        pa_strnull(pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME)), sink->name);
+    }
+
+    return PA_HOOK_OK;
+}
+
+static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source, void* userdata) {
+    pa_source_output *o;
+    uint32_t idx;
+    pa_source *def;
+    const char *s;
+
+    pa_assert(c);
+    pa_assert(source);
+
+    /* Don't want to run during startup or shutdown */
+    if (c->state != PA_CORE_RUNNING)
+        return PA_HOOK_OK;
+
+    /* Don't switch to any internal devices */
+    if ((s = pa_proplist_gets(source->proplist, PA_PROP_DEVICE_BUS))) {
+        if (pa_streq(s, "pci"))
+            return PA_HOOK_OK;
+        else if (pa_streq(s, "isa"))
+            return PA_HOOK_OK;
+    }
+
+    def = pa_namereg_get_default_source(c);
+    if (def == source)
+        return PA_HOOK_OK;
+
+    /* Actually do the switch to the new source */
+    pa_namereg_set_default_source(c, source);
+
+    /* Now move all old outputs over */
+    if (pa_idxset_size(def->outputs) <= 0) {
+        pa_log_debug("No source outputs to move away.");
+        return PA_HOOK_OK;
+    }
+
+    PA_IDXSET_FOREACH(o, def->outputs, idx) {
+        if (o->save_source)
+            continue;
+
+        if (pa_source_output_move_to(o, source, FALSE) < 0)
+            pa_log_info("Failed to move source output %u \"%s\" to %s.", o->index,
+                        pa_strnull(pa_proplist_gets(o->proplist, PA_PROP_APPLICATION_NAME)), source->name);
+        else
+            pa_log_info("Sucessfully moved source output %u \"%s\" to %s.", o->index,
+                        pa_strnull(pa_proplist_gets(o->proplist, PA_PROP_APPLICATION_NAME)), source->name);
+    }
+
+    return PA_HOOK_OK;
+}
+
+int pa__init(pa_module*m) {
+    pa_modargs *ma;
+    struct userdata *u;
+
+    pa_assert(m);
+
+    if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
+        pa_log("Failed to parse module arguments");
+        return -1;
+    }
+
+    m->userdata = u = pa_xnew(struct userdata, 1);
+
+    /* A little bit later than module-rescue-streams... */
+    u->sink_put_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_LATE+30, (pa_hook_cb_t) sink_put_hook_callback, u);
+    u->source_put_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_PUT], PA_HOOK_LATE+20, (pa_hook_cb_t) source_put_hook_callback, u);
+
+    pa_modargs_free(ma);
+    return 0;
+}
+
+void pa__done(pa_module*m) {
+    struct userdata *u;
+
+    pa_assert(m);
+
+    if (!(u = m->userdata))
+        return;
+
+    if (u->sink_put_slot)
+        pa_hook_slot_free(u->sink_put_slot);
+    if (u->source_put_slot)
+        pa_hook_slot_free(u->source_put_slot);
+
+    pa_xfree(u);
+}

commit 5d43aba3d5e61756b4336fafc90b92dc1796286d
Author: Marc-André Lureau <marc-andre.lureau at nokia.com>
Date:   Mon Apr 4 14:33:35 2011 +0300

    bluetooth: drop data every 500ms on oor condition

diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index e4a2cef..bd1511b 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -1671,17 +1671,20 @@ static void thread_func(void *userdata) {
                     writable = FALSE;
                 }
 
-                if ((!u->source || !PA_SOURCE_IS_LINKED(u->source->thread_info.state)) && do_write <= 0 && writable) {
-                    pa_usec_t time_passed, next_write_at, sleep_for;
-
-                    /* Hmm, there is no input stream we could synchronize
-                     * to. So let's estimate when we need to wake up the latest */
-
-                    time_passed = pa_rtclock_now() - u->started_at;
-                    next_write_at = pa_bytes_to_usec(u->write_index, &u->sample_spec);
-                    sleep_for = time_passed < next_write_at ? next_write_at - time_passed : 0;
-
-/*                 pa_log("Sleeping for %lu; time passed %lu, next write at %lu", (unsigned long) sleep_for, (unsigned long) time_passed, (unsigned long)next_write_at); */
+                if ((!u->source || !PA_SOURCE_IS_LINKED(u->source->thread_info.state)) && do_write <= 0) {
+                    pa_usec_t sleep_for;
+                    pa_usec_t time_passed, next_write_at;
+
+                    if (writable) {
+                        /* Hmm, there is no input stream we could synchronize
+                         * to. So let's estimate when we need to wake up the latest */
+                        time_passed = pa_rtclock_now() - u->started_at;
+                        next_write_at = pa_bytes_to_usec(u->write_index, &u->sample_spec);
+                        sleep_for = time_passed < next_write_at ? next_write_at - time_passed : 0;
+                        /* pa_log("Sleeping for %lu; time passed %lu, next write at %lu", (unsigned long) sleep_for, (unsigned long) time_passed, (unsigned long)next_write_at); */
+                    } else
+                        /* drop stream every 500 ms */
+                        sleep_for = PA_USEC_PER_MSEC * 500;
 
                     pa_rtpoll_set_timer_relative(u->rtpoll, sleep_for);
                     disable_timer = FALSE;

commit b14f0d79f68f83999cb9ea2d63b6cf05fce7a0ca
Author: Tanu Kaskinen <tanu.kaskinen at digia.com>
Date:   Mon Apr 4 14:51:16 2011 +0300

    alsa: Fix log output to inform about positive base volumes correctly.
    
    This fix was done for _set_port_cb() already, but the first fix didn't fix
    setup_mixer(). Now that's done too.

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 9ed4d4d..ccbc062 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -1724,10 +1724,7 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB, pa_bool_t sync_v
             u->sink->base_volume = pa_sw_volume_from_dB(-u->mixer_path->max_dB);
             u->sink->n_volume_steps = PA_VOLUME_NORM+1;
 
-            if (u->mixer_path->max_dB > 0.0)
-                pa_log_info("Fixing base volume to %0.2f dB", pa_sw_volume_to_dB(u->sink->base_volume));
-            else
-                pa_log_info("No particular base volume set, fixing to 0 dB");
+            pa_log_info("Fixing base volume to %0.2f dB", pa_sw_volume_to_dB(u->sink->base_volume));
 
         } else {
             pa_log_info("Hardware volume ranges from %li to %li.", u->mixer_path->min_volume, u->mixer_path->max_volume);
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 6d18e60..3355fbd 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -1465,10 +1465,7 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB) {
             u->source->base_volume = pa_sw_volume_from_dB(-u->mixer_path->max_dB);
             u->source->n_volume_steps = PA_VOLUME_NORM+1;
 
-            if (u->mixer_path->max_dB > 0.0)
-                pa_log_info("Fixing base volume to %0.2f dB", pa_sw_volume_to_dB(u->source->base_volume));
-            else
-                pa_log_info("No particular base volume set, fixing to 0 dB");
+            pa_log_info("Fixing base volume to %0.2f dB", pa_sw_volume_to_dB(u->source->base_volume));
 
         } else {
             pa_log_info("Hardware volume ranges from %li to %li.", u->mixer_path->min_volume, u->mixer_path->max_volume);

commit 1020065df79b71d6d0fe33d3f2a7924a38735c8b
Author: Colin Guthrie <colin at mageia.org>
Date:   Tue Apr 5 09:53:16 2011 +0100

    doc: Fix typo

diff --git a/src/pulse/stream.h b/src/pulse/stream.h
index 256b150..dd67db7 100644
--- a/src/pulse/stream.h
+++ b/src/pulse/stream.h
@@ -266,7 +266,7 @@
  * pa_stream_get_time() and pa_stream_get_latency() will try to
  * interpolate the current playback time/latency by estimating the
  * number of samples that have been played back by the hardware since
- * the last regular timing update. It is espcially useful to combine
+ * the last regular timing update. It is especially useful to combine
  * this option with PA_STREAM_AUTO_TIMING_UPDATE, which will enable
  * you to monitor the current playback time/latency very precisely and
  * very frequently without requiring a network round trip every time.

commit 1bbafdbb0ac9fc36b679e899958344a9478fd4fa
Author: Harri Mähönen <ext-harri.mahonen at nokia.com>
Date:   Tue Apr 5 11:58:01 2011 +0300

    stream-restore: add version to new entry.

diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index 8edfee0..d27982b 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -650,6 +650,7 @@ static void handle_add_entry(DBusConnection *conn, DBusMessage *msg, void *userd
         pa_assert_se(pa_hashmap_put(u->dbus_entries, dbus_entry->entry_name, dbus_entry) == 0);
 
         e = pa_xnew0(struct entry, 1);
+        e->version = ENTRY_VERSION;
         e->muted_valid = TRUE;
         e->volume_valid = !!map.channels;
         e->device_valid = !!device[0];

commit aaab340d4e3c57d58755151310f59a0ee96554b1
Author: Juho Hämäläinen <juho.hamalainen at tieto.com>
Date:   Mon Apr 4 15:24:17 2011 +0300

    bluetooth-device: fix rounding errors caused by few bt volume steps
    
    When volume changes in bluetooth device PulseAudio volume is rounded
    one too low, so if bluetooth headset changes volume and that volume
    is immediately set again for bluetooth device, bluetooth step drifts
    lower all the time. Volume is incremented by one in the conversion so
    that we get right bluetooth step when re-applying volume.
    
    Signed-off-by: Juho Hämäläinen <ext-juho.hamalainen at nokia.com>

diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index bd1511b..bbd57ed 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -59,6 +59,7 @@
 
 #define BITPOOL_DEC_LIMIT 32
 #define BITPOOL_DEC_STEP 5
+#define HSP_MAX_GAIN 15
 
 PA_MODULE_AUTHOR("Joao Paulo Rechi Vita");
 PA_MODULE_DESCRIPTION("Bluetooth audio sink and source");
@@ -1753,20 +1754,30 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
         dbus_uint16_t gain;
         pa_cvolume v;
 
-        if (!dbus_message_get_args(m, &err, DBUS_TYPE_UINT16, &gain, DBUS_TYPE_INVALID) || gain > 15) {
+        if (!dbus_message_get_args(m, &err, DBUS_TYPE_UINT16, &gain, DBUS_TYPE_INVALID) || gain > HSP_MAX_GAIN) {
             pa_log("Failed to parse org.bluez.Headset.{Speaker|Microphone}GainChanged: %s", err.message);
             goto fail;
         }
 
         if (u->profile == PROFILE_HSP) {
             if (u->sink && dbus_message_is_signal(m, "org.bluez.Headset", "SpeakerGainChanged")) {
+                pa_volume_t volume = (pa_volume_t) (gain * PA_VOLUME_NORM / HSP_MAX_GAIN);
 
-                pa_cvolume_set(&v, u->sample_spec.channels, (pa_volume_t) (gain * PA_VOLUME_NORM / 15));
+                /* increment volume by one to correct rounding errors */
+                if (volume < PA_VOLUME_NORM)
+                    volume++;
+
+                pa_cvolume_set(&v, u->sample_spec.channels, volume);
                 pa_sink_volume_changed(u->sink, &v);
 
             } else if (u->source && dbus_message_is_signal(m, "org.bluez.Headset", "MicrophoneGainChanged")) {
+                pa_volume_t volume = (pa_volume_t) (gain * PA_VOLUME_NORM / HSP_MAX_GAIN);
+
+                /* increment volume by one to correct rounding errors */
+                if (volume < PA_VOLUME_NORM)
+                    volume++;
 
-                pa_cvolume_set(&v, u->sample_spec.channels, (pa_volume_t) (gain * PA_VOLUME_NORM / 15));
+                pa_cvolume_set(&v, u->sample_spec.channels, volume);
                 pa_source_volume_changed(u->source, &v);
             }
         }
@@ -1804,6 +1815,7 @@ fail:
 static void sink_set_volume_cb(pa_sink *s) {
     DBusMessage *m;
     dbus_uint16_t gain;
+    pa_volume_t volume;
     struct userdata *u;
     char *k;
 
@@ -1818,12 +1830,18 @@ static void sink_set_volume_cb(pa_sink *s) {
     pa_assert(u->sink == s);
     pa_assert(u->profile == PROFILE_HSP);
 
-    gain = (pa_cvolume_max(&s->real_volume) * 15) / PA_VOLUME_NORM;
+    gain = (pa_cvolume_max(&s->real_volume) * HSP_MAX_GAIN) / PA_VOLUME_NORM;
+
+    if (gain > HSP_MAX_GAIN)
+        gain = HSP_MAX_GAIN;
 
-    if (gain > 15)
-        gain = 15;
+    volume = (pa_volume_t) (gain * PA_VOLUME_NORM / HSP_MAX_GAIN);
 
-    pa_cvolume_set(&s->real_volume, u->sample_spec.channels, (pa_volume_t) (gain * PA_VOLUME_NORM / 15));
+    /* increment volume by one to correct rounding errors */
+    if (volume < PA_VOLUME_NORM)
+        volume++;
+
+    pa_cvolume_set(&s->real_volume, u->sample_spec.channels, volume);
 
     pa_assert_se(m = dbus_message_new_method_call("org.bluez", u->path, "org.bluez.Headset", "SetSpeakerGain"));
     pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_UINT16, &gain, DBUS_TYPE_INVALID));
@@ -1835,6 +1853,7 @@ static void sink_set_volume_cb(pa_sink *s) {
 static void source_set_volume_cb(pa_source *s) {
     DBusMessage *m;
     dbus_uint16_t gain;
+    pa_volume_t volume;
     struct userdata *u;
     char *k;
 
@@ -1849,12 +1868,18 @@ static void source_set_volume_cb(pa_source *s) {
     pa_assert(u->source == s);
     pa_assert(u->profile == PROFILE_HSP);
 
-    gain = (pa_cvolume_max(&s->volume) * 15) / PA_VOLUME_NORM;
+    gain = (pa_cvolume_max(&s->volume) * HSP_MAX_GAIN) / PA_VOLUME_NORM;
+
+    if (gain > HSP_MAX_GAIN)
+        gain = HSP_MAX_GAIN;
+
+    volume = (pa_volume_t) (gain * PA_VOLUME_NORM / HSP_MAX_GAIN);
 
-    if (gain > 15)
-        gain = 15;
+    /* increment volume by one to correct rounding errors */
+    if (volume < PA_VOLUME_NORM)
+        volume++;
 
-    pa_cvolume_set(&s->volume, u->sample_spec.channels, (pa_volume_t) (gain * PA_VOLUME_NORM / 15));
+    pa_cvolume_set(&s->volume, u->sample_spec.channels, volume);
 
     pa_assert_se(m = dbus_message_new_method_call("org.bluez", u->path, "org.bluez.Headset", "SetMicrophoneGain"));
     pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_UINT16, &gain, DBUS_TYPE_INVALID));

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list