rpms/pulseaudio/devel 0001-Initialize-exit_idle_time-to-1-instead-of-0-when-i.patch, NONE, 1.1 0002-Unload-module-bluetooth-device-if-the-remote-device.patch, NONE, 1.1 0003-instead-of-resetting-virtual_volume-unconditionally.patch, NONE, 1.1 0004-use-pa_channel_map_init_extend-instead-of-pa_chann.patch, NONE, 1.1 0005-if-the-channel-map-was-modified-due-to-PA_SINK_INPUT.patch, NONE, 1.1 0006-define-0dB-in-PA-as-maximum-amplification.patch, NONE, 1.1 0007-Fix-a-potential-C-C99-ism-add-a-log-message-on-er.patch, NONE, 1.1 0008-Fix-two-typos-that-broke-tunnels.patch, NONE, 1.1 0009-properly-remove-dbus-matches-an-filters-when-unloadi.patch, NONE, 1.1 0010-Fix-possible-invalid-read-while-attempting-to-load-m.patch, NONE, 1.1 0011-always-check-for-libtool-prefix-binary-name-to-avoid.patch, NONE, 1.1 0012-Fix-spelling-of-privilige.patch, NONE, 1.1 0013-Make-missing-git-changelog.perl-non-fatal.patch, NONE, 1.1 0014-fix-invalid-validity-check.patch, NONE, 1.1 0015-convert-argument-to-boolean-int-in-PA_UNLIKELY-too.patch, NONE, 1.1 0016-include-log.h-near-the-end-so-that-macro.h-can-be-in.patch, NONE, 1.1 0017-Try-to-catch-certain-driver-errors.patch, NONE, 1.1 0018-make-the-debug-trap-macro-a-proper-macro-in-macro.h.patch, NONE, 1.1 0019-don-t-set-the-volume-of-pacat-unless-it-is-explicitl.patch, NONE, 1.1 0020-warn-if-ALSA-wakes-us-up-and-there-is-actually-nothi.patch, NONE, 1.1 0021-fix-build.patch, NONE, 1.1 pulseaudio.spec, 1.57, 1.58

Lennart Poettering lennart at fedoraproject.org
Thu Oct 23 21:41:51 UTC 2008


Author: lennart

Update of /cvs/pkgs/rpms/pulseaudio/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv4705

Modified Files:
	pulseaudio.spec 
Added Files:
	0001-Initialize-exit_idle_time-to-1-instead-of-0-when-i.patch 
	0002-Unload-module-bluetooth-device-if-the-remote-device.patch 
	0003-instead-of-resetting-virtual_volume-unconditionally.patch 
	0004-use-pa_channel_map_init_extend-instead-of-pa_chann.patch 
	0005-if-the-channel-map-was-modified-due-to-PA_SINK_INPUT.patch 
	0006-define-0dB-in-PA-as-maximum-amplification.patch 
	0007-Fix-a-potential-C-C99-ism-add-a-log-message-on-er.patch 
	0008-Fix-two-typos-that-broke-tunnels.patch 
	0009-properly-remove-dbus-matches-an-filters-when-unloadi.patch 
	0010-Fix-possible-invalid-read-while-attempting-to-load-m.patch 
	0011-always-check-for-libtool-prefix-binary-name-to-avoid.patch 
	0012-Fix-spelling-of-privilige.patch 
	0013-Make-missing-git-changelog.perl-non-fatal.patch 
	0014-fix-invalid-validity-check.patch 
	0015-convert-argument-to-boolean-int-in-PA_UNLIKELY-too.patch 
	0016-include-log.h-near-the-end-so-that-macro.h-can-be-in.patch 
	0017-Try-to-catch-certain-driver-errors.patch 
	0018-make-the-debug-trap-macro-a-proper-macro-in-macro.h.patch 
	0019-don-t-set-the-volume-of-pacat-unless-it-is-explicitl.patch 
	0020-warn-if-ALSA-wakes-us-up-and-there-is-actually-nothi.patch 
	0021-fix-build.patch 
Log Message:
Backport a couple of fixes from current git master

0001-Initialize-exit_idle_time-to-1-instead-of-0-when-i.patch:

--- NEW FILE 0001-Initialize-exit_idle_time-to-1-instead-of-0-when-i.patch ---
>From b6a802717b02ca77689b044773956462d58df12d Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Tue, 7 Oct 2008 02:00:07 +0200
Subject: [PATCH] Initialize exit_idle_time to -1 instead of 0  when in system mode.
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Spotted by Rafał Mużyło.
---
 src/daemon/main.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/daemon/main.c b/src/daemon/main.c
index fad635f..bc8bc63 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -646,9 +646,9 @@ int main(int argc, char *argv[]) {
         conf->disable_shm = TRUE;
     }
 
-    if (conf->system_instance && conf->exit_idle_time > 0) {
+    if (conf->system_instance && conf->exit_idle_time >= 0) {
         pa_log_notice(_("Running in system mode, forcibly disabling exit idle time!"));
-        conf->exit_idle_time = 0;
+        conf->exit_idle_time = -1;
     }
 
     if (conf->cmd == PA_CMD_START) {
-- 
1.6.0.3


0002-Unload-module-bluetooth-device-if-the-remote-device.patch:

--- NEW FILE 0002-Unload-module-bluetooth-device-if-the-remote-device.patch ---
>From 31318274ff84e2d359aa762ffcde09eae115d2d4 Mon Sep 17 00:00:00 2001
From: Luiz Augusto von Dentz <luiz.dentz at openbossa.org>
Date: Mon, 6 Oct 2008 14:59:15 -0300
Subject: [PATCH] Unload module-bluetooth-device if the remote device disconnects.

---
 src/modules/bluetooth/module-bluetooth-discover.c |   55 ++++++++++++++++----
 1 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/src/modules/bluetooth/module-bluetooth-discover.c b/src/modules/bluetooth/module-bluetooth-discover.c
index 0601e9a..a33ca64 100644
--- a/src/modules/bluetooth/module-bluetooth-discover.c
+++ b/src/modules/bluetooth/module-bluetooth-discover.c
@@ -91,6 +91,16 @@ static void module_free(struct module *m) {
     pa_xfree(m);
 }
 
+static struct module* module_find(struct device *d, const char *profile) {
+    struct module *m;
+
+    for (m = d->module_list; d; d = d->next)
+        if (pa_streq(m->profile, profile))
+            return m;
+
+    return NULL;
+}
+
 static struct uuid *uuid_new(const char *uuid) {
     struct uuid *node;
 
@@ -345,6 +355,21 @@ static void load_module_for_device(struct userdata *u, struct device *d, const c
     PA_LLIST_PREPEND(struct module, d->module_list, m);
 }
 
+static void unload_module_for_device(struct userdata *u, struct device *d, const char *profile) {
+    struct module *m;
+
+    pa_assert(u);
+    pa_assert(d);
+
+    if (!(m = module_find(d, profile)))
+        return;
+
+    pa_module_unload_request(m->pa_m, TRUE);
+
+    PA_LLIST_REMOVE(struct module, d->module_list, m);
+    module_free(m);
+}
+
 static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *msg, void *userdata) {
     DBusMessageIter arg_i;
     DBusError err;
@@ -387,6 +412,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *msg, void *
         struct device *d;
         const char *profile;
         DBusMessageIter variant_i;
+        dbus_bool_t connected;
 
         if (!dbus_message_iter_init(msg, &arg_i)) {
             pa_log("dbus: message has no parameters");
@@ -400,6 +426,9 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *msg, void *
 
         dbus_message_iter_get_basic(&arg_i, &value);
 
+        if (!pa_streq(value, "Connected"))
+            goto done;
+
         if (!dbus_message_iter_next(&arg_i)) {
             pa_log("Property value missing");
             goto done;
@@ -412,25 +441,29 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *msg, void *
 
         dbus_message_iter_recurse(&arg_i, &variant_i);
 
-        if (dbus_message_iter_get_arg_type(&variant_i) == DBUS_TYPE_BOOLEAN) {
-            dbus_bool_t connected;
-            dbus_message_iter_get_basic(&variant_i, &connected);
-
-            if (!pa_streq(value, "Connected") || !connected)
-                goto done;
+        if (dbus_message_iter_get_arg_type(&variant_i) != DBUS_TYPE_BOOLEAN) {
+            pa_log("Property value not a boolean.");
+            goto done;
         }
 
-        if (!(d = device_find(u, dbus_message_get_path(msg)))) {
-                d = device_new(dbus_message_get_path(msg));
-                PA_LLIST_PREPEND(struct device, u->device_list, d);
-        }
+        dbus_message_iter_get_basic(&variant_i, &connected);
 
         if (dbus_message_is_signal(msg, "org.bluez.Headset", "PropertyChanged"))
             profile = "hsp";
         else
             profile = "a2dp";
 
-        load_module_for_device(u, d, profile);
+        d = device_find(u, dbus_message_get_path(msg));
+
+        if (connected) {
+            if (!d) {
+                    d = device_new(dbus_message_get_path(msg));
+                    PA_LLIST_PREPEND(struct device, u->device_list, d);
+            }
+
+            load_module_for_device(u, d, profile);
+        } else if (d)
+            unload_module_for_device(u, d, profile);
     }
 
 done:
-- 
1.6.0.3


0003-instead-of-resetting-virtual_volume-unconditionally.patch:

--- NEW FILE 0003-instead-of-resetting-virtual_volume-unconditionally.patch ---
>From fc2ba1f914b2d015c9c43951c6ffb917977257b1 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Tue, 7 Oct 2008 22:42:13 +0200
Subject: [PATCH] instead of resetting virtual_volume unconditionally on initialization, do so only when no volume was set before

---
 src/pulsecore/sink-input.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 4f70347..508591e 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -150,8 +150,10 @@ pa_sink_input* pa_sink_input_new(
     pa_return_null_if_fail(pa_channel_map_valid(&data->channel_map));
     pa_return_null_if_fail(data->channel_map.channels == data->sample_spec.channels);
 
-    if (!data->volume_is_set)
+    if (!data->volume_is_set) {
         pa_cvolume_reset(&data->volume, data->sample_spec.channels);
+        pa_cvolume_reset(&data->virtual_volume, data->sample_spec.channels);
+    }
 
     pa_return_null_if_fail(pa_cvolume_valid(&data->volume));
     pa_return_null_if_fail(data->volume.channels == data->sample_spec.channels);
-- 
1.6.0.3


0004-use-pa_channel_map_init_extend-instead-of-pa_chann.patch:

--- NEW FILE 0004-use-pa_channel_map_init_extend-instead-of-pa_chann.patch ---
>From 215f1fbffa18caa1cfb8ac4c7c3a108dc740a2c6 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Tue, 7 Oct 2008 22:45:37 +0200
Subject: [PATCH] use pa_channel_map_init_extend() instead of pa_channel_map_init_auto() as channel map for sink inputs/source outputs in case no map is specified

---
 src/pulsecore/sink-input.c    |    2 +-
 src/pulsecore/source-output.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 508591e..89aaf55 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -144,7 +144,7 @@ pa_sink_input* pa_sink_input_new(
         if (data->sink->channel_map.channels == data->sample_spec.channels)
             data->channel_map = data->sink->channel_map;
         else
-            pa_return_null_if_fail(pa_channel_map_init_auto(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT));
+            pa_channel_map_init_extend(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT);
     }
 
     pa_return_null_if_fail(pa_channel_map_valid(&data->channel_map));
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index d76f6e4..c66c6fa 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -127,7 +127,7 @@ pa_source_output* pa_source_output_new(
         if (data->source->channel_map.channels == data->sample_spec.channels)
             data->channel_map = data->source->channel_map;
         else
-            pa_return_null_if_fail(pa_channel_map_init_auto(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT));
+            pa_channel_map_init_extend(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT);
     }
 
     pa_return_null_if_fail(pa_channel_map_valid(&data->channel_map));
-- 
1.6.0.3


0005-if-the-channel-map-was-modified-due-to-PA_SINK_INPUT.patch:

--- NEW FILE 0005-if-the-channel-map-was-modified-due-to-PA_SINK_INPUT.patch ---
>From f0a2294f685985fd6edcf3a52018cc833eb5fa11 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Tue, 7 Oct 2008 22:46:18 +0200
Subject: [PATCH] if the channel map was modified due to PA_SINK_INPUT_FIX_CHANNELS, remap the specified volume properly

---
 src/pulsecore/sink-input.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 89aaf55..cade0db 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -167,6 +167,8 @@ pa_sink_input* pa_sink_input_new(
     if (flags & PA_SINK_INPUT_FIX_RATE)
         data->sample_spec.rate = data->sink->sample_spec.rate;
 
+    original_cm = data->channel_map;
+
     if (flags & PA_SINK_INPUT_FIX_CHANNELS) {
         data->sample_spec.channels = data->sink->sample_spec.channels;
         data->channel_map = data->sink->channel_map;
@@ -176,8 +178,7 @@ pa_sink_input* pa_sink_input_new(
     pa_assert(pa_channel_map_valid(&data->channel_map));
 
     /* Due to the fixing of the sample spec the volume might not match anymore */
-    if (data->volume.channels != data->sample_spec.channels)
-        pa_cvolume_set(&data->volume, data->sample_spec.channels, pa_cvolume_avg(&data->volume));
+    pa_cvolume_remap(&data->volume, &original_cm, &data->channel_map);
 
     if (data->resample_method == PA_RESAMPLER_INVALID)
         data->resample_method = core->resample_method;
-- 
1.6.0.3


0006-define-0dB-in-PA-as-maximum-amplification.patch:

--- NEW FILE 0006-define-0dB-in-PA-as-maximum-amplification.patch ---
>From 220c9c0c207c9e3a205596b540277825c8a917cd Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Wed, 8 Oct 2008 04:02:10 +0200
Subject: [PATCH] define 0dB in PA as maximum amplification

---
 src/modules/module-alsa-sink.c   |   10 ++++++----
 src/modules/module-alsa-source.c |   10 ++++++----
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/modules/module-alsa-sink.c b/src/modules/module-alsa-sink.c
index 0e15da3..4044de1 100644
--- a/src/modules/module-alsa-sink.c
+++ b/src/modules/module-alsa-sink.c
@@ -796,7 +796,7 @@ static int sink_get_volume_cb(pa_sink *s) {
                 VALGRIND_MAKE_MEM_DEFINED(&alsa_vol, sizeof(alsa_vol));
 #endif
 
-                r.values[i] = pa_sw_volume_from_dB((double) alsa_vol / 100.0);
+                r.values[i] = pa_sw_volume_from_dB((double) (alsa_vol - u->hw_dB_max) / 100.0);
             } else {
 
                 if ((err = snd_mixer_selem_get_playback_volume(u->mixer_elem, u->mixer_map[i], &alsa_vol)) < 0)
@@ -818,7 +818,7 @@ static int sink_get_volume_cb(pa_sink *s) {
             VALGRIND_MAKE_MEM_DEFINED(&alsa_vol, sizeof(alsa_vol));
 #endif
 
-            pa_cvolume_set(&r, s->sample_spec.channels, pa_sw_volume_from_dB((double) alsa_vol / 100.0));
+            pa_cvolume_set(&r, s->sample_spec.channels, pa_sw_volume_from_dB((double) (alsa_vol - u->hw_dB_max) / 100.0));
 
         } else {
 
@@ -875,6 +875,7 @@ static int sink_set_volume_cb(pa_sink *s) {
             if (u->hw_dB_supported) {
 
                 alsa_vol = (long) (pa_sw_volume_to_dB(vol) * 100);
+                alsa_vol += u->hw_dB_max;
                 alsa_vol = PA_CLAMP_UNLIKELY(alsa_vol, u->hw_dB_min, u->hw_dB_max);
 
                 if ((err = snd_mixer_selem_set_playback_dB(u->mixer_elem, u->mixer_map[i], alsa_vol, 1)) < 0)
@@ -883,7 +884,7 @@ static int sink_set_volume_cb(pa_sink *s) {
                 if ((err = snd_mixer_selem_get_playback_dB(u->mixer_elem, u->mixer_map[i], &alsa_vol)) < 0)
                     goto fail;
 
-                r.values[i] = pa_sw_volume_from_dB((double) alsa_vol / 100.0);
+                r.values[i] = pa_sw_volume_from_dB((double) (alsa_vol - u->hw_dB_max) / 100.0);
 
             } else {
                 alsa_vol = to_alsa_volume(u, vol);
@@ -906,6 +907,7 @@ static int sink_set_volume_cb(pa_sink *s) {
 
         if (u->hw_dB_supported) {
             alsa_vol = (long) (pa_sw_volume_to_dB(vol) * 100);
+            alsa_vol += u->hw_dB_max;
             alsa_vol = PA_CLAMP_UNLIKELY(alsa_vol, u->hw_dB_min, u->hw_dB_max);
 
             if ((err = snd_mixer_selem_set_playback_dB_all(u->mixer_elem, alsa_vol, 1)) < 0)
@@ -914,7 +916,7 @@ static int sink_set_volume_cb(pa_sink *s) {
             if ((err = snd_mixer_selem_get_playback_dB(u->mixer_elem, SND_MIXER_SCHN_MONO, &alsa_vol)) < 0)
                 goto fail;
 
-            pa_cvolume_set(&r, s->volume.channels, pa_sw_volume_from_dB((double) alsa_vol / 100.0));
+            pa_cvolume_set(&r, s->volume.channels, pa_sw_volume_from_dB((double) (alsa_vol - u->hw_dB_max) / 100.0));
 
         } else {
             alsa_vol = to_alsa_volume(u, vol);
diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c
index 2827ecf..a743776 100644
--- a/src/modules/module-alsa-source.c
+++ b/src/modules/module-alsa-source.c
@@ -742,7 +742,7 @@ static int source_get_volume_cb(pa_source *s) {
                 VALGRIND_MAKE_MEM_DEFINED(&alsa_vol, sizeof(alsa_vol));
 #endif
 
-                r.values[i] = pa_sw_volume_from_dB((double) alsa_vol / 100.0);
+                r.values[i] = pa_sw_volume_from_dB((double) (alsa_vol - u->hw_dB_max) / 100.0);
             } else {
 
                 if ((err = snd_mixer_selem_get_capture_volume(u->mixer_elem, u->mixer_map[i], &alsa_vol)) < 0)
@@ -764,7 +764,7 @@ static int source_get_volume_cb(pa_source *s) {
             VALGRIND_MAKE_MEM_DEFINED(&alsa_vol, sizeof(alsa_vol));
 #endif
 
-            pa_cvolume_set(&r, s->sample_spec.channels, pa_sw_volume_from_dB((double) alsa_vol / 100.0));
+            pa_cvolume_set(&r, s->sample_spec.channels, pa_sw_volume_from_dB((double) (alsa_vol - u->hw_dB_max) / 100.0));
 
         } else {
 
@@ -821,6 +821,7 @@ static int source_set_volume_cb(pa_source *s) {
             if (u->hw_dB_supported) {
 
                 alsa_vol = (long) (pa_sw_volume_to_dB(vol) * 100);
+                alsa_vol += u->hw_dB_max;
                 alsa_vol = PA_CLAMP_UNLIKELY(alsa_vol, u->hw_dB_min, u->hw_dB_max);
 
                 if ((err = snd_mixer_selem_set_capture_dB(u->mixer_elem, u->mixer_map[i], alsa_vol, 1)) < 0)
@@ -829,7 +830,7 @@ static int source_set_volume_cb(pa_source *s) {
                 if ((err = snd_mixer_selem_get_capture_dB(u->mixer_elem, u->mixer_map[i], &alsa_vol)) < 0)
                     goto fail;
 
-                r.values[i] = pa_sw_volume_from_dB((double) alsa_vol / 100.0);
+                r.values[i] = pa_sw_volume_from_dB((double) (alsa_vol - u->hw_dB_max) / 100.0);
 
             } else {
                 alsa_vol = to_alsa_volume(u, vol);
@@ -852,6 +853,7 @@ static int source_set_volume_cb(pa_source *s) {
 
         if (u->hw_dB_supported) {
             alsa_vol = (long) (pa_sw_volume_to_dB(vol) * 100);
+            alsa_vol += u->hw_dB_max;
             alsa_vol = PA_CLAMP_UNLIKELY(alsa_vol, u->hw_dB_min, u->hw_dB_max);
 
             if ((err = snd_mixer_selem_set_capture_dB_all(u->mixer_elem, alsa_vol, 1)) < 0)
@@ -860,7 +862,7 @@ static int source_set_volume_cb(pa_source *s) {
             if ((err = snd_mixer_selem_get_capture_dB(u->mixer_elem, SND_MIXER_SCHN_MONO, &alsa_vol)) < 0)
                 goto fail;
 
-            pa_cvolume_set(&r, s->volume.channels, pa_sw_volume_from_dB((double) alsa_vol / 100.0));
+            pa_cvolume_set(&r, s->volume.channels, pa_sw_volume_from_dB((double) (alsa_vol - u->hw_dB_max) / 100.0));
 
         } else {
             alsa_vol = to_alsa_volume(u, vol);
-- 
1.6.0.3


0007-Fix-a-potential-C-C99-ism-add-a-log-message-on-er.patch:

--- NEW FILE 0007-Fix-a-potential-C-C99-ism-add-a-log-message-on-er.patch ---
>From c72a7db3b1e08b9ebef3a0f7da0b8e669f7e79fa Mon Sep 17 00:00:00 2001
From: Colin Guthrie <pulse at colin.guthr.ie>
Date: Wed, 8 Oct 2008 22:56:12 +0200
Subject: [PATCH] Fix a potential C++/C99 ism, add a log message on error condition

Signed-off-by: Lennart Poettering <lennart at poettering.net>
---
 src/pulsecore/pid.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/pulsecore/pid.c b/src/pulsecore/pid.c
index ce8ef19..99ba3e1 100644
--- a/src/pulsecore/pid.c
+++ b/src/pulsecore/pid.c
@@ -211,6 +211,7 @@ int pa_pid_file_create(const char *procname) {
     if ((pid = read_pid(fn, fd)) == (pid_t) -1)
         pa_log_warn("Corrupt PID file, overwriting.");
     else if (pid > 0) {
+        int ours = 1;
 
 #ifdef OS_IS_WIN32
         if ((process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid)) != NULL) {
@@ -218,11 +219,13 @@ int pa_pid_file_create(const char *procname) {
 #else
         if (kill(pid, 0) >= 0 || errno != ESRCH) {
 #endif
-            int ours = 1;
 
             if (procname)
-                if ((ours = proc_name_ours(pid, procname)) < 0)
+                if ((ours = proc_name_ours(pid, procname)) < 0) {
+                    pa_log_warn("Could not check to see if pid %lu is a pulseaudio process. "
+                                "Asssuming it is and the daemon is already running.", (unsigned long) pid);
                     goto fail;
+                }
 
             if (ours) {
                 pa_log("Daemon already running.");
-- 
1.6.0.3


0008-Fix-two-typos-that-broke-tunnels.patch:

--- NEW FILE 0008-Fix-two-typos-that-broke-tunnels.patch ---
>From cab7cc3dfdbcc7dbe55862a3b39d9c6950a93c12 Mon Sep 17 00:00:00 2001
From: Colin Guthrie <pulse at colin.guthr.ie>
Date: Sat, 11 Oct 2008 18:20:06 +0100
Subject: [PATCH] Fix two typos that broke tunnels

---
 src/modules/module-tunnel.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c
index 4bbb11a..a46d6e5 100644
--- a/src/modules/module-tunnel.c
+++ b/src/modules/module-tunnel.c
@@ -508,7 +508,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
 
     switch (code) {
 
-        case PA_SINK_MESSAGE_SET_STATE: {
+        case PA_SOURCE_MESSAGE_SET_STATE: {
             int r;
 
             if ((r = pa_source_process_msg(o, code, data, offset, chunk)) >= 0)
@@ -520,7 +520,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
         case PA_SOURCE_MESSAGE_GET_LATENCY: {
             pa_usec_t yr, yl, *usec = data;
 
-            yl = pa_bytes_to_usec((uint64_t) u->counter, &PA_SINK(o)->sample_spec);
+            yl = pa_bytes_to_usec((uint64_t) u->counter, &PA_SOURCE(o)->sample_spec);
             yr = pa_smoother_get(u->smoother, pa_rtclock_usec());
 
             *usec = yr > yl ? yr - yl : 0;
-- 
1.6.0.3


0009-properly-remove-dbus-matches-an-filters-when-unloadi.patch:

--- NEW FILE 0009-properly-remove-dbus-matches-an-filters-when-unloadi.patch ---
>From 9fd82c196432f3b5aadd0970a810fc778804bb34 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Mon, 13 Oct 2008 19:52:02 +0200
Subject: [PATCH] properly remove dbus matches an filters when unloading m-b-d

---
 src/modules/bluetooth/module-bluetooth-discover.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/src/modules/bluetooth/module-bluetooth-discover.c b/src/modules/bluetooth/module-bluetooth-discover.c
index a33ca64..ad436f3 100644
--- a/src/modules/bluetooth/module-bluetooth-discover.c
+++ b/src/modules/bluetooth/module-bluetooth-discover.c
@@ -485,8 +485,23 @@ void pa__done(pa_module* m) {
         device_free(i);
     }
 
-    if (u->conn)
+    if (u->conn) {
+        DBusError error;
+        dbus_error_init(&error);
+
+        dbus_bus_remove_match(pa_dbus_connection_get(u->conn), "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceRemoved'", &error);
+        dbus_error_free(&error);
+
+        dbus_bus_remove_match(pa_dbus_connection_get(u->conn), "type='signal',sender='org.bluez',interface='org.bluez.Headset',member='PropertyChanged'", &error);
+        dbus_error_free(&error);
+
+        dbus_bus_remove_match(pa_dbus_connection_get(u->conn), "type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'", &error);
+        dbus_error_free(&error);
+
+        dbus_connection_remove_filter(pa_dbus_connection_get(u->conn), filter_cb, u);
+
         pa_dbus_connection_unref(u->conn);
+    }
 
     pa_xfree(u);
 }
-- 
1.6.0.3


0010-Fix-possible-invalid-read-while-attempting-to-load-m.patch:

--- NEW FILE 0010-Fix-possible-invalid-read-while-attempting-to-load-m.patch ---
>From 6ad65da869df57a93a6f0a53eb5744126ce439ba Mon Sep 17 00:00:00 2001
From: Luiz Augusto von Dentz <luiz.dentz at openbossa.org>
Date: Thu, 9 Oct 2008 19:31:43 -0300
Subject: [PATCH] Fix possible invalid read while attempting to load module-bluetooth-device.

---
 src/modules/bluetooth/module-bluetooth-discover.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/modules/bluetooth/module-bluetooth-discover.c b/src/modules/bluetooth/module-bluetooth-discover.c
index ad436f3..36c0a35 100644
--- a/src/modules/bluetooth/module-bluetooth-discover.c
+++ b/src/modules/bluetooth/module-bluetooth-discover.c
@@ -346,7 +346,7 @@ static void load_module_for_device(struct userdata *u, struct device *d, const c
     pa_m = pa_module_load(u->module->core, "module-bluetooth-device", args);
     pa_xfree(args);
 
-    if (!m) {
+    if (!pa_m) {
         pa_log_debug("Failed to load module for device %s", d->object_path);
         return;
     }
-- 
1.6.0.3


0011-always-check-for-libtool-prefix-binary-name-to-avoid.patch:

--- NEW FILE 0011-always-check-for-libtool-prefix-binary-name-to-avoid.patch ---
>From af133f504f83b7e657d3d9d1fda88d767e324b42 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Sun, 19 Oct 2008 22:24:18 +0200
Subject: [PATCH] always check for libtool prefix binary name to avoid confusion when using both installed and run-from-build-tree versions of PA in parallel

---
 src/pulsecore/pid.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/pulsecore/pid.c b/src/pulsecore/pid.c
index 99ba3e1..bf9ba98 100644
--- a/src/pulsecore/pid.c
+++ b/src/pulsecore/pid.c
@@ -171,14 +171,14 @@ static int proc_name_ours(pid_t pid, const char *procname) {
         good = pa_startswith(stored, expected);
         pa_xfree(expected);
 
-#if !defined(__OPTIMIZE__)
+/*#if !defined(__OPTIMIZE__)*/
         if (!good) {
             /* libtool likes to rename our binary names ... */
             expected = pa_sprintf_malloc("%lu (lt-%s)", (unsigned long) pid, procname);
             good = pa_startswith(stored, expected);
             pa_xfree(expected);
         }
-#endif
+/*#endif*/
 
         return !!good;
     }
-- 
1.6.0.3


0012-Fix-spelling-of-privilige.patch:

--- NEW FILE 0012-Fix-spelling-of-privilige.patch ---
>From ac4b0afadbd58b5313ed9d2c6b71999cb3898c13 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Sun, 19 Oct 2008 22:25:58 +0200
Subject: [PATCH] Fix spelling of privilige

---
 src/daemon/caps.c |    2 +-
 src/daemon/main.c |   14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/daemon/caps.c b/src/daemon/caps.c
index 707b532..b5cbbc6 100644
--- a/src/daemon/caps.c
+++ b/src/daemon/caps.c
@@ -60,7 +60,7 @@ void pa_drop_root(void) {
     if (uid == 0 || geteuid() != 0)
         return;
 
-    pa_log_info(_("Dropping root priviliges."));
+    pa_log_info(_("Dropping root privileges."));
 
 #if defined(HAVE_SETRESUID)
     pa_assert_se(setresuid(uid, uid, uid) >= 0);
diff --git a/src/daemon/main.c b/src/daemon/main.c
index bc8bc63..2306483 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -222,7 +222,7 @@ static int change_user(void) {
 #elif defined(HAVE_SETREGID)
     r = setregid(gr->gr_gid, gr->gr_gid);
 #else
-#error "No API to drop priviliges"
+#error "No API to drop privileges"
 #endif
 
     if (r < 0) {
@@ -238,7 +238,7 @@ static int change_user(void) {
 #elif defined(HAVE_SETREUID)
     r = setreuid(pw->pw_uid, pw->pw_uid);
 #else
-#error "No API to drop priviliges"
+#error "No API to drop privileges"
 #endif
 
     if (r < 0) {
@@ -382,7 +382,7 @@ int main(int argc, char *argv[]) {
         /* Drop all capabilities except CAP_SYS_NICE  */
         pa_limit_caps();
 
-        /* Drop priviliges, but keep CAP_SYS_NICE */
+        /* Drop privileges, but keep CAP_SYS_NICE */
         pa_drop_root();
 
         /* After dropping root, the effective set is reset, hence,
@@ -476,9 +476,9 @@ int main(int argc, char *argv[]) {
             pa_drop_caps();
 
             if (conf->high_priority || conf->realtime_scheduling)
-                pa_log_notice(_("Called SUID root and real-time/high-priority scheduling was requested in the configuration. However, we lack the necessary priviliges:\n"
-                                "We are not in group '"PA_REALTIME_GROUP"' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n"
-                                "For enabling real-time scheduling please acquire the appropriate PolicyKit priviliges, or become a member of '"PA_REALTIME_GROUP"', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."));
+                pa_log_notice(_("Called SUID root and real-time/high-priority scheduling was requested in the configuration. However, we lack the necessary privileges:\n"
+                                "We are not in group '"PA_REALTIME_GROUP"' and PolicyKit refuse to grant us privileges. Dropping SUID again.\n"
+                                "For enabling real-time scheduling please acquire the appropriate PolicyKit privileges, or become a member of '"PA_REALTIME_GROUP"', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."));
         }
     }
 
@@ -626,7 +626,7 @@ int main(int argc, char *argv[]) {
     if (real_root && !conf->system_instance)
         pa_log_warn(_("This program is not intended to be run as root (unless --system is specified)."));
     else if (!real_root && conf->system_instance) {
-        pa_log(_("Root priviliges required."));
+        pa_log(_("Root privileges required."));
         goto finish;
     }
 
-- 
1.6.0.3


0013-Make-missing-git-changelog.perl-non-fatal.patch:

--- NEW FILE 0013-Make-missing-git-changelog.perl-non-fatal.patch ---
>From f3770fa7afa6c9f8a38336c4d0ee735bbb60216c Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Mon, 20 Oct 2008 20:33:28 +0200
Subject: [PATCH] Make missing git-changelog.perl non-fatal

---
 Makefile.am |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index facce0d..ebc5e69 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -58,7 +58,7 @@ dist-hook:
 	if test -d .git ; then \
 		git pull ; \
 		chmod u+w ${distdir}/ChangeLog || true ; \
-		git-changelog.perl > ${distdir}/ChangeLog ; \
+		( git-changelog.perl || echo "git-changelog.perl failed." ) > ${distdir}/ChangeLog 2>&1 ; \
 	fi
 
 .PHONY: homepage distcleancheck doxygen
-- 
1.6.0.3


0014-fix-invalid-validity-check.patch:

--- NEW FILE 0014-fix-invalid-validity-check.patch ---
>From 74898ff657ff85a3a3ce481d74d75438d79fde25 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Tue, 21 Oct 2008 18:22:28 +0200
Subject: [PATCH] fix invalid validity check

---
 src/pulsecore/sink-input.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index cade0db..5368f31 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -156,7 +156,7 @@ pa_sink_input* pa_sink_input_new(
     }
 
     pa_return_null_if_fail(pa_cvolume_valid(&data->volume));
-    pa_return_null_if_fail(data->volume.channels == data->sample_spec.channels);
+    pa_return_null_if_fail(pa_cvolume_compatible(&data->volume, &data->sample_spec));
 
     if (!data->muted_is_set)
         data->muted = FALSE;
-- 
1.6.0.3


0015-convert-argument-to-boolean-int-in-PA_UNLIKELY-too.patch:

--- NEW FILE 0015-convert-argument-to-boolean-int-in-PA_UNLIKELY-too.patch ---
>From ab1139ffd3b33e55cd0a480e6e6ed86f5f1b53f1 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Tue, 21 Oct 2008 18:27:25 +0200
Subject: [PATCH] convert argument to boolean int in PA_UNLIKELY, too

---
 src/pulsecore/macro.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index 39e9b58..2d031da 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -40,7 +40,7 @@
 #ifndef PA_LIKELY
 #ifdef __GNUC__
 #define PA_LIKELY(x) (__builtin_expect(!!(x),1))
-#define PA_UNLIKELY(x) (__builtin_expect((x),0))
+#define PA_UNLIKELY(x) (__builtin_expect(!!(x),0))
 #else
 #define PA_LIKELY(x) (x)
 #define PA_UNLIKELY(x) (x)
-- 
1.6.0.3


0016-include-log.h-near-the-end-so-that-macro.h-can-be-in.patch:

--- NEW FILE 0016-include-log.h-near-the-end-so-that-macro.h-can-be-in.patch ---
>From b041aac9b104008240cf4f3571de6a4637d94b1d Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Tue, 21 Oct 2008 18:40:01 +0200
Subject: [PATCH] include log.h near the end so that macro.h can be included in log.h and defines pa_bool_t properly

---
 src/pulsecore/macro.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index 2d031da..cf02696 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -30,7 +30,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <pulsecore/log.h>
 #include <pulse/gccmacro.h>
 
 #ifndef PACKAGE
@@ -221,4 +220,7 @@ typedef int pa_bool_t;
 
 #endif
 
+/* We include this at the very last place */
+#include <pulsecore/log.h>
+
 #endif
-- 
1.6.0.3


0017-Try-to-catch-certain-driver-errors.patch:

--- NEW FILE 0017-Try-to-catch-certain-driver-errors.patch ---
>From 0796f5a2d6bf8e175a16d7f58cd0a18783fb4590 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Tue, 21 Oct 2008 20:00:36 +0200
Subject: [PATCH] Try to catch certain driver errors

... by verifying return values of snd_pcm_avail_update() and
snd_pcm_begin_mmap() for their sanenness.
---
 src/modules/alsa-util.c          |   60 ++++++++++++++++++++++++++++++++++++++
 src/modules/alsa-util.h          |    3 ++
 src/modules/module-alsa-sink.c   |    6 ++--
 src/modules/module-alsa-source.c |    6 ++--
 4 files changed, 69 insertions(+), 6 deletions(-)

diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c
index ffe7795..39cea49 100644
--- a/src/modules/alsa-util.c
+++ b/src/modules/alsa-util.c
@@ -30,6 +30,7 @@
 
 #include <pulse/sample.h>
 #include <pulse/xmalloc.h>
+#include <pulse/timeval.h>
 
 #include <pulsecore/log.h>
 #include <pulsecore/macro.h>
@@ -1109,3 +1110,62 @@ pa_rtpoll_item* pa_alsa_build_pollfd(snd_pcm_t *pcm, pa_rtpoll *rtpoll) {
 
     return item;
 }
+
+snd_pcm_sframes_t pa_alsa_safe_avail_update(snd_pcm_t *pcm, size_t hwbuf_size, const pa_sample_spec *ss) {
+    snd_pcm_sframes_t n;
+    size_t k;
+
+    pa_assert(pcm);
+    pa_assert(hwbuf_size > 0);
+    pa_assert(ss);
+
+    /* Some ALSA driver expose weird bugs, let's inform the user about
+     * what is going on */
+
+    n = snd_pcm_avail_update(pcm);
+
+    if (n <= 0)
+        return n;
+
+    k = (size_t) n * pa_frame_size(ss);
+
+    if (k >= hwbuf_size * 3 ||
+        k >= pa_bytes_per_second(ss)*10)
+        pa_log("snd_pcm_avail_update() returned a value that is exceptionally large: %lu bytes (%lu ms) "
+               "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.",
+               (unsigned long) k, (unsigned long) pa_bytes_to_usec(k, ss) / PA_USEC_PER_MSEC);
+
+    return n;
+}
+
+int pa_alsa_safe_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas, snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames, size_t hwbuf_size, const pa_sample_spec *ss) {
+    int r;
+    snd_pcm_uframes_t before;
+    size_t k;
+
+    pa_assert(pcm);
+    pa_assert(areas);
+    pa_assert(offset);
+    pa_assert(frames);
+    pa_assert(hwbuf_size > 0);
+    pa_assert(ss);
+
+    before = *frames;
+
+    r = snd_pcm_mmap_begin(pcm, areas, offset, frames);
+
+    if (r < 0)
+        return r;
+
+    k = (size_t) *frames * pa_frame_size(ss);
+
+    if (*frames > before ||
+        k >= hwbuf_size * 3 ||
+        k >= pa_bytes_per_second(ss)*10)
+
+        pa_log("snd_pcm_mmap_begin() returned a value that is exceptionally large: %lu bytes (%lu ms) "
+               "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.",
+               (unsigned long) k, (unsigned long) pa_bytes_to_usec(k, ss) / PA_USEC_PER_MSEC);
+
+    return r;
+}
diff --git a/src/modules/alsa-util.h b/src/modules/alsa-util.h
index b66adc1..aaa01c7 100644
--- a/src/modules/alsa-util.h
+++ b/src/modules/alsa-util.h
@@ -92,4 +92,7 @@ int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents);
 
 pa_rtpoll_item* pa_alsa_build_pollfd(snd_pcm_t *pcm, pa_rtpoll *rtpoll);
 
+snd_pcm_sframes_t pa_alsa_safe_avail_update(snd_pcm_t *pcm, size_t hwbuf_size, const pa_sample_spec *ss);
+int pa_alsa_safe_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas, snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames, size_t hwbuf_size, const pa_sample_spec *ss);
+
 #endif
diff --git a/src/modules/module-alsa-sink.c b/src/modules/module-alsa-sink.c
index 4044de1..af83103 100644
--- a/src/modules/module-alsa-sink.c
+++ b/src/modules/module-alsa-sink.c
@@ -261,7 +261,7 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
         /* First we determine how many samples are missing to fill the
          * buffer up to 100% */
 
-        if (PA_UNLIKELY((n = snd_pcm_avail_update(u->pcm_handle)) < 0)) {
+        if (PA_UNLIKELY((n = pa_alsa_safe_avail_update(u->pcm_handle, u->hwbuf_size, &u->sink->sample_spec)) < 0)) {
 
             if ((r = try_recover(u, "snd_pcm_avail_update", (int) n)) == 0)
                 continue;
@@ -299,7 +299,7 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
 
 /*             pa_log_debug("%lu frames to write", (unsigned long) frames); */
 
-            if (PA_UNLIKELY((err = snd_pcm_mmap_begin(u->pcm_handle, &areas, &offset, &frames)) < 0)) {
+            if (PA_UNLIKELY((err = pa_alsa_safe_mmap_begin(u->pcm_handle, &areas, &offset, &frames, u->hwbuf_size, &u->sink->sample_spec)) < 0)) {
 
                 if ((r = try_recover(u, "snd_pcm_mmap_begin", err)) == 0)
                     continue;
@@ -374,7 +374,7 @@ static int unix_write(struct userdata *u, pa_usec_t *sleep_usec) {
 
         snd_pcm_hwsync(u->pcm_handle);
 
-        if (PA_UNLIKELY((n = snd_pcm_avail_update(u->pcm_handle)) < 0)) {
+        if (PA_UNLIKELY((n = pa_alsa_safe_avail_update(u->pcm_handle, u->hwbuf_size, &u->sink->sample_spec)) < 0)) {
 
             if ((r = try_recover(u, "snd_pcm_avail_update", (int) n)) == 0)
                 continue;
diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c
index a743776..dd6ca97 100644
--- a/src/modules/module-alsa-source.c
+++ b/src/modules/module-alsa-source.c
@@ -255,7 +255,7 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
 
         snd_pcm_hwsync(u->pcm_handle);
 
-        if (PA_UNLIKELY((n = snd_pcm_avail_update(u->pcm_handle)) < 0)) {
+        if (PA_UNLIKELY((n = pa_alsa_safe_avail_update(u->pcm_handle, u->hwbuf_size, &u->source->sample_spec)) < 0)) {
 
             if ((r = try_recover(u, "snd_pcm_avail_update", (int) n)) == 0)
                 continue;
@@ -282,7 +282,7 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
 
 /*             pa_log_debug("%lu frames to read", (unsigned long) frames); */
 
-            if (PA_UNLIKELY((err = snd_pcm_mmap_begin(u->pcm_handle, &areas, &offset, &frames)) < 0)) {
+            if (PA_UNLIKELY((err = pa_alsa_safe_mmap_begin(u->pcm_handle, &areas, &offset, &frames, u->hwbuf_size, &u->source->sample_spec)) < 0)) {
 
                 if ((r = try_recover(u, "snd_pcm_mmap_begin", err)) == 0)
                     continue;
@@ -353,7 +353,7 @@ static int unix_read(struct userdata *u, pa_usec_t *sleep_usec) {
 
         snd_pcm_hwsync(u->pcm_handle);
 
-        if (PA_UNLIKELY((n = snd_pcm_avail_update(u->pcm_handle)) < 0)) {
+        if (PA_UNLIKELY((n = pa_alsa_safe_avail_update(u->pcm_handle, u->hwbuf_size, &u->source->sample_spec)) < 0)) {
 
             if ((r = try_recover(u, "snd_pcm_avail_update", (int) n)) == 0)
                 continue;
-- 
1.6.0.3


0018-make-the-debug-trap-macro-a-proper-macro-in-macro.h.patch:

--- NEW FILE 0018-make-the-debug-trap-macro-a-proper-macro-in-macro.h.patch ---
>From 8e2a48a7a2baa49a900b9c42e8d08aca5db90d1f Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Tue, 21 Oct 2008 22:04:22 +0200
Subject: [PATCH] make the debug trap macro a proper macro in macro.h

---
 src/pulsecore/macro.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index cf02696..f9ce949 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -220,6 +220,12 @@ typedef int pa_bool_t;
 
 #endif
 
+#if defined(__i386__) || defined(__x86_64__)
+#define PA_DEBUG_TRAP __asm__("int $3")
+#else
+#define PA_DEBUG_TRAP raise(SIGTRAP)
+#endif
+
 /* We include this at the very last place */
 #include <pulsecore/log.h>
 
-- 
1.6.0.3


0019-don-t-set-the-volume-of-pacat-unless-it-is-explicitl.patch:

--- NEW FILE 0019-don-t-set-the-volume-of-pacat-unless-it-is-explicitl.patch ---
>From bfdad535da00ca0a06aeafd774d3168b4f79c82c Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Wed, 22 Oct 2008 22:48:53 +0200
Subject: [PATCH] don't set the volume of pacat unless it is explicitly set

---
 src/utils/pacat.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/utils/pacat.c b/src/utils/pacat.c
index 99df5b9..ea736e2 100644
--- a/src/utils/pacat.c
+++ b/src/utils/pacat.c
@@ -57,6 +57,7 @@ static char *stream_name = NULL, *client_name = NULL, *device = NULL;
 
 static int verbose = 0;
 static pa_volume_t volume = PA_VOLUME_NORM;
+static int volume_is_set = 0;
 
 static pa_sample_spec sample_spec = {
     .format = PA_SAMPLE_S16LE,
@@ -283,7 +284,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
 
             if (mode == PLAYBACK) {
                 pa_cvolume cv;
-                if ((r = pa_stream_connect_playback(stream, device, latency > 0 ? &buffer_attr : NULL, flags, pa_cvolume_set(&cv, sample_spec.channels, volume), NULL)) < 0) {
+                if ((r = pa_stream_connect_playback(stream, device, latency > 0 ? &buffer_attr : NULL, flags, volume_is_set ? pa_cvolume_set(&cv, sample_spec.channels, volume) : NULL, NULL)) < 0) {
                     fprintf(stderr, _("pa_stream_connect_playback() failed: %s\n"), pa_strerror(pa_context_errno(c)));
                     goto fail;
                 }
@@ -627,6 +628,7 @@ int main(int argc, char *argv[]) {
             case ARG_VOLUME: {
                 int v = atoi(optarg);
                 volume = v < 0 ? 0U : (pa_volume_t) v;
+                volume_is_set = 1;
                 break;
             }
 
-- 
1.6.0.3


0020-warn-if-ALSA-wakes-us-up-and-there-is-actually-nothi.patch:

--- NEW FILE 0020-warn-if-ALSA-wakes-us-up-and-there-is-actually-nothi.patch ---
>From 09279f76342a1f3b261c04232821c3dc225312c3 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Wed, 22 Oct 2008 23:55:52 +0200
Subject: [PATCH] warn if ALSA wakes us up and there is actually nothing to do

---
 src/modules/alsa-util.c          |    6 +++++
 src/modules/module-alsa-sink.c   |   41 +++++++++++++++++++++++++++----------
 src/modules/module-alsa-source.c |   41 +++++++++++++++++++++++++++----------
 3 files changed, 66 insertions(+), 22 deletions(-)

diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c
index 39cea49..20dc400 100644
--- a/src/modules/alsa-util.c
+++ b/src/modules/alsa-util.c
@@ -1051,6 +1051,12 @@ int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents) {
         pa_log_warn("Got POLLNVAL from ALSA");
     if (revents & POLLHUP)
         pa_log_warn("Got POLLHUP from ALSA");
+    if (revents & POLLPRI)
+        pa_log_warn("Got POLLPRI from ALSA");
+    if (revents & POLLIN)
+        pa_log_warn("Got POLLIN from ALSA");
+    if (revents & POLLOUT)
+        pa_log_warn("Got POLLOUT from ALSA");
 
     state = snd_pcm_state(pcm);
     pa_log_warn("PCM state is %s", snd_pcm_state_name(state));
diff --git a/src/modules/module-alsa-sink.c b/src/modules/module-alsa-sink.c
index af83103..6dea172 100644
--- a/src/modules/module-alsa-sink.c
+++ b/src/modules/module-alsa-sink.c
@@ -241,7 +241,7 @@ static size_t check_left_to_play(struct userdata *u, snd_pcm_sframes_t n) {
     return left_to_play;
 }
 
-static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
+static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled) {
     int work_done = 0;
     pa_usec_t max_sleep_usec = 0, process_usec = 0;
     size_t left_to_play;
@@ -279,14 +279,23 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
             * need to guarantee that clients only have to keep around
             * a single hw buffer length. */
 
-            if (pa_bytes_to_usec(left_to_play, &u->sink->sample_spec) > process_usec+max_sleep_usec/2)
+            if (!polled &&
+                pa_bytes_to_usec(left_to_play, &u->sink->sample_spec) > process_usec+max_sleep_usec/2)
                 break;
 
-        if (PA_UNLIKELY(n <= u->hwbuf_unused_frames))
+        if (PA_UNLIKELY(n <= u->hwbuf_unused_frames)) {
+
+            if (polled)
+                pa_log("ALSA woke us up to write new data to the device, but there was actually nothing to write! "
+                       "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.");
+
             break;
+        }
 
         n -= u->hwbuf_unused_frames;
 
+        polled = FALSE;
+
 /*         pa_log_debug("Filling up"); */
 
         for (;;) {
@@ -357,7 +366,7 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
     return work_done;
 }
 
-static int unix_write(struct userdata *u, pa_usec_t *sleep_usec) {
+static int unix_write(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled) {
     int work_done = 0;
     pa_usec_t max_sleep_usec = 0, process_usec = 0;
     size_t left_to_play;
@@ -392,14 +401,23 @@ static int unix_write(struct userdata *u, pa_usec_t *sleep_usec) {
             * need to guarantee that clients only have to keep around
             * a single hw buffer length. */
 
-            if (pa_bytes_to_usec(left_to_play, &u->sink->sample_spec) > process_usec+max_sleep_usec/2)
+            if (!polled &&
+                pa_bytes_to_usec(left_to_play, &u->sink->sample_spec) > process_usec+max_sleep_usec/2)
                 break;
 
-        if (PA_UNLIKELY(n <= u->hwbuf_unused_frames))
+        if (PA_UNLIKELY(n <= u->hwbuf_unused_frames)) {
+
+            if (polled)
+                pa_log("ALSA woke us up to write new data to the device, but there was actually nothing to write! "
+                       "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.");
+
             break;
+        }
 
         n -= u->hwbuf_unused_frames;
 
+        polled = FALSE;
+
         for (;;) {
             snd_pcm_sframes_t frames;
             void *p;
@@ -1084,6 +1102,7 @@ finish:
 
 static void thread_func(void *userdata) {
     struct userdata *u = userdata;
+    unsigned short revents = 0;
 
     pa_assert(u);
 
@@ -1110,9 +1129,9 @@ static void thread_func(void *userdata) {
                         goto fail;
 
             if (u->use_mmap)
-                work_done = mmap_write(u, &sleep_usec);
+                work_done = mmap_write(u, &sleep_usec, revents & POLLOUT);
             else
-                work_done = unix_write(u, &sleep_usec);
+                work_done = unix_write(u, &sleep_usec, revents & POLLOUT);
 
             if (work_done < 0)
                 goto fail;
@@ -1180,7 +1199,6 @@ static void thread_func(void *userdata) {
         /* Tell ALSA about this and process its response */
         if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
             struct pollfd *pollfd;
-            unsigned short revents = 0;
             int err;
             unsigned n;
 
@@ -1191,7 +1209,7 @@ static void thread_func(void *userdata) {
                 goto fail;
             }
 
-            if (revents & (POLLERR|POLLNVAL|POLLHUP|POLLPRI)) {
+            if (revents & (POLLIN|POLLERR|POLLNVAL|POLLHUP|POLLPRI)) {
                 if (pa_alsa_recover_from_poll(u->pcm_handle, revents) < 0)
                     goto fail;
 
@@ -1201,7 +1219,8 @@ static void thread_func(void *userdata) {
 
             if (revents && u->use_tsched)
                 pa_log_debug("Wakeup from ALSA!%s%s", (revents & POLLIN) ? " INPUT" : "", (revents & POLLOUT) ? " OUTPUT" : "");
-        }
+        } else
+            revents = 0;
     }
 
 fail:
diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c
index dd6ca97..f796ef1 100644
--- a/src/modules/module-alsa-source.c
+++ b/src/modules/module-alsa-source.c
@@ -238,7 +238,7 @@ static size_t check_left_to_record(struct userdata *u, snd_pcm_sframes_t n) {
     return left_to_record;
 }
 
-static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
+static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled) {
     int work_done = 0;
     pa_usec_t max_sleep_usec = 0, process_usec = 0;
     size_t left_to_record;
@@ -266,11 +266,20 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
         left_to_record = check_left_to_record(u, n);
 
         if (u->use_tsched)
-            if (pa_bytes_to_usec(left_to_record, &u->source->sample_spec) > process_usec+max_sleep_usec/2)
+            if (!polled &&
+                pa_bytes_to_usec(left_to_record, &u->source->sample_spec) > process_usec+max_sleep_usec/2)
                 break;
 
-        if (PA_UNLIKELY(n <= 0))
+        if (PA_UNLIKELY(n <= 0)) {
+
+            if (polled)
+                pa_log("ALSA woke us up to read new data from the device, but there was actually nothing to read! "
+                       "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio device.");
+
             break;
+        }
+
+        polled = FALSE;
 
         for (;;) {
             int err;
@@ -336,7 +345,7 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
     return work_done;
 }
 
-static int unix_read(struct userdata *u, pa_usec_t *sleep_usec) {
+static int unix_read(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled) {
     int work_done = 0;
     pa_usec_t max_sleep_usec = 0, process_usec = 0;
     size_t left_to_record;
@@ -364,11 +373,20 @@ static int unix_read(struct userdata *u, pa_usec_t *sleep_usec) {
         left_to_record = check_left_to_record(u, n);
 
         if (u->use_tsched)
-            if (pa_bytes_to_usec(left_to_record, &u->source->sample_spec) > process_usec+max_sleep_usec/2)
+            if (!polled &&
+                pa_bytes_to_usec(left_to_record, &u->source->sample_spec) > process_usec+max_sleep_usec/2)
                 break;
 
-        if (PA_UNLIKELY(n <= 0))
+        if (PA_UNLIKELY(n <= 0)) {
+
+            if (polled)
+                pa_log("ALSA woke us up to read new data from the device, but there was actually nothing to read! "
+                       "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.");
+
             return work_done;
+        }
+
+        polled = FALSE;
 
         for (;;) {
             void *p;
@@ -950,6 +968,7 @@ static void source_update_requested_latency_cb(pa_source *s) {
 
 static void thread_func(void *userdata) {
     struct userdata *u = userdata;
+    unsigned short revents = 0;
 
     pa_assert(u);
 
@@ -972,9 +991,9 @@ static void thread_func(void *userdata) {
             pa_usec_t sleep_usec = 0;
 
             if (u->use_mmap)
-                work_done = mmap_read(u, &sleep_usec);
+                work_done = mmap_read(u, &sleep_usec, revents & POLLIN);
             else
-                work_done = unix_read(u, &sleep_usec);
+                work_done = unix_read(u, &sleep_usec, revents & POLLIN);
 
             if (work_done < 0)
                 goto fail;
@@ -1016,7 +1035,6 @@ static void thread_func(void *userdata) {
         /* Tell ALSA about this and process its response */
         if (PA_SOURCE_IS_OPENED(u->source->thread_info.state)) {
             struct pollfd *pollfd;
-            unsigned short revents = 0;
             int err;
             unsigned n;
 
@@ -1027,7 +1045,7 @@ static void thread_func(void *userdata) {
                 goto fail;
             }
 
-            if (revents & (POLLERR|POLLNVAL|POLLHUP|POLLPRI)) {
+            if (revents & (POLLOUT|POLLERR|POLLNVAL|POLLHUP|POLLPRI)) {
                 if (pa_alsa_recover_from_poll(u->pcm_handle, revents) < 0)
                     goto fail;
 
@@ -1036,7 +1054,8 @@ static void thread_func(void *userdata) {
 
             if (revents && u->use_tsched)
                 pa_log_debug("Wakeup from ALSA!%s%s", (revents & POLLIN) ? " INPUT" : "", (revents & POLLOUT) ? " OUTPUT" : "");
-        }
+        } else
+            revents = 0;
     }
 
 fail:
-- 
1.6.0.3


0021-fix-build.patch:

--- NEW FILE 0021-fix-build.patch ---
>From 6f4b228742398ef1cc28257aa82ddffdd5884e70 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart at poettering.net>
Date: Thu, 23 Oct 2008 23:23:39 +0200
Subject: [PATCH] fix build

---
 src/pulsecore/sink-input.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 5368f31..bed3d32 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -119,6 +119,7 @@ pa_sink_input* pa_sink_input_new(
     pa_sink_input *i;
     pa_resampler *resampler = NULL;
     char st[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
+    pa_channel_map original_cm;
 
     pa_assert(core);
     pa_assert(data);
@@ -152,7 +153,6 @@ pa_sink_input* pa_sink_input_new(
 
     if (!data->volume_is_set) {
         pa_cvolume_reset(&data->volume, data->sample_spec.channels);
-        pa_cvolume_reset(&data->virtual_volume, data->sample_spec.channels);
     }
 
     pa_return_null_if_fail(pa_cvolume_valid(&data->volume));
-- 
1.6.0.3



Index: pulseaudio.spec
===================================================================
RCS file: /cvs/pkgs/rpms/pulseaudio/devel/pulseaudio.spec,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- pulseaudio.spec	9 Oct 2008 06:02:06 -0000	1.57
+++ pulseaudio.spec	23 Oct 2008 21:41:50 -0000	1.58
@@ -3,7 +3,7 @@
 Name:		pulseaudio
 Summary: 	Improved Linux sound server
 Version:	0.9.13
-Release:	2%{?dist}
+Release:	3%{?dist}
 License:	GPLv2+
 Group:		System Environment/Daemons
 Source0:	http://0pointer.de/lennart/projects/pulseaudio/pulseaudio-%{version}.tar.gz
@@ -24,6 +24,27 @@
 BuildRequires: intltool
 Requires:	%{name}-core-libs = %{version}-%{release}
 Obsoletes:	pulseaudio-devel
+Patch1: 0001-Initialize-exit_idle_time-to-1-instead-of-0-when-i.patch
+Patch2: 0002-Unload-module-bluetooth-device-if-the-remote-device.patch
+Patch3: 0003-instead-of-resetting-virtual_volume-unconditionally.patch
+Patch4: 0004-use-pa_channel_map_init_extend-instead-of-pa_chann.patch
+Patch5: 0005-if-the-channel-map-was-modified-due-to-PA_SINK_INPUT.patch
+Patch6: 0006-define-0dB-in-PA-as-maximum-amplification.patch
+Patch7: 0007-Fix-a-potential-C-C99-ism-add-a-log-message-on-er.patch
+Patch8: 0008-Fix-two-typos-that-broke-tunnels.patch
+Patch9: 0009-properly-remove-dbus-matches-an-filters-when-unloadi.patch
+Patch10: 0010-Fix-possible-invalid-read-while-attempting-to-load-m.patch
+Patch11: 0011-always-check-for-libtool-prefix-binary-name-to-avoid.patch
+Patch12: 0012-Fix-spelling-of-privilige.patch
+Patch13: 0013-Make-missing-git-changelog.perl-non-fatal.patch
+Patch14: 0014-fix-invalid-validity-check.patch
+Patch15: 0015-convert-argument-to-boolean-int-in-PA_UNLIKELY-too.patch
+Patch16: 0016-include-log.h-near-the-end-so-that-macro.h-can-be-in.patch
+Patch17: 0017-Try-to-catch-certain-driver-errors.patch
+Patch18: 0018-make-the-debug-trap-macro-a-proper-macro-in-macro.h.patch
+Patch19: 0019-don-t-set-the-volume-of-pacat-unless-it-is-explicitl.patch
+Patch20: 0020-warn-if-ALSA-wakes-us-up-and-there-is-actually-nothi.patch
+Patch21: 0021-fix-build.patch
 
 %description
 PulseAudio is a sound server for Linux and other Unix like operating 
@@ -160,6 +181,28 @@
 
 %prep
 %setup -q -T -b0
+%patch1 -p1 -b .0001-Initialize-exit_idle_time-to-1-instead-of-0-when-i.patch
+%patch2 -p1 -b .0002-Unload-module-bluetooth-device-if-the-remote-device.patch
+%patch3 -p1 -b .0003-instead-of-resetting-virtual_volume-unconditionally.patch
+%patch4 -p1 -b .0004-use-pa_channel_map_init_extend-instead-of-pa_chann.patch
+%patch5 -p1 -b .0005-if-the-channel-map-was-modified-due-to-PA_SINK_INPUT.patch
+%patch6 -p1 -b .0006-define-0dB-in-PA-as-maximum-amplification.patch
+%patch7 -p1 -b .0007-Fix-a-potential-C-C99-ism-add-a-log-message-on-er.patch
+%patch8 -p1 -b .0008-Fix-two-typos-that-broke-tunnels.patch
+%patch9 -p1 -b .0009-properly-remove-dbus-matches-an-filters-when-unloadi.patch
+%patch10 -p1 -b .0010-Fix-possible-invalid-read-while-attempting-to-load-m.patch
+%patch11 -p1 -b .0011-always-check-for-libtool-prefix-binary-name-to-avoid.patch
+%patch12 -p1 -b .0012-Fix-spelling-of-privilige.patch
+%patch13 -p1 -b .0013-Make-missing-git-changelog.perl-non-fatal.patch
+%patch14 -p1 -b .0014-fix-invalid-validity-check.patch
+%patch15 -p1 -b .0015-convert-argument-to-boolean-int-in-PA_UNLIKELY-too.patch
+%patch16 -p1 -b .0016-include-log.h-near-the-end-so-that-macro.h-can-be-in.patch
+%patch17 -p1 -b .0017-Try-to-catch-certain-driver-errors.patch
+%patch18 -p1 -b .0018-make-the-debug-trap-macro-a-proper-macro-in-macro.h.patch
+%patch19 -p1 -b .0019-don-t-set-the-volume-of-pacat-unless-it-is-explicitl.patch
+%patch20 -p1 -b .0020-warn-if-ALSA-wakes-us-up-and-there-is-actually-nothi.patch
+%patch21 -p1 -b .0021-fix-build.patch
+
 
 %build
 %configure --disable-ltdl-install --disable-static --disable-rpath --with-system-user=pulse --with-system-group=pulse --with-realtime-group=pulse-rt --with-access-group=pulse-access
@@ -391,6 +434,9 @@
 %{_mandir}/man1/pax11publish.1.gz
 
 %changelog
+* Thu Oct 23 2008 Lennart Poettering <lpoetter at redhat.com> 0.9.13-3
+- Backport a couple of fixes from current git master
+
 * Thu Oct 9 2008 Matthhias Clasen <mclasen at redhat.com> 0.9.13-2
 - Handle locales properly
 




More information about the scm-commits mailing list