Merge lp:~zequence/pulseaudio/ubuntu.quantal-fix into lp:~ubuntu-audio-dev/pulseaudio/ubuntu.quantal

Proposed by Kaj Ailomaa
Status: Merged
Merge reported by: David Henningsson
Merged at revision: not available
Proposed branch: lp:~zequence/pulseaudio/ubuntu.quantal-fix
Merge into: lp:~ubuntu-audio-dev/pulseaudio/ubuntu.quantal
Diff against target: 244 lines (+224/-0)
3 files modified
debian/changelog (+8/-0)
debian/patches/0102-reserve-card.patch (+215/-0)
debian/patches/series (+1/-0)
To merge this branch: bzr merge lp:~zequence/pulseaudio/ubuntu.quantal-fix
Reviewer Review Type Date Requested Status
Ubuntu Audio Development Team Pending
Review via email: mp+164788@code.launchpad.net

Description of the change

Adds a patch that fixes LP: #1163638

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2012-10-04 12:44:16 +0000
+++ debian/changelog 2013-05-20 18:29:27 +0000
@@ -1,3 +1,11 @@
1pulseaudio (1:2.1-0ubuntu4.1) UNRELEASED; urgency=low
2
3 * 0102-reserve-card.patch:
4 make pulseaudio let go of reserved cards when acquired by jack
5 (LP: #1163638)
6
7 -- Kaj Ailomaa <zequence@mousike.me> Thu, 16 May 2013 17:23:44 +0200
8
1pulseaudio (1:2.1-0ubuntu4) quantal-proposed; urgency=low9pulseaudio (1:2.1-0ubuntu4) quantal-proposed; urgency=low
210
3 * 0101-alsa-mixer-Remove-analog-output-lfe-on-mono.patch:11 * 0101-alsa-mixer-Remove-analog-output-lfe-on-mono.patch:
412
=== added file 'debian/patches/0102-reserve-card.patch'
--- debian/patches/0102-reserve-card.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/0102-reserve-card.patch 2013-05-20 18:29:27 +0000
@@ -0,0 +1,215 @@
1From: Kaj Ailomaa <zequence@mousike.me>
2Description: Fixes an issue where pulseaudio was not giving up a reserved card
3Origin/Author: upstream, commits dd7cf7ad5ef17e217505fa41ace0c699fe79dada, 6be6766b58b3fa668a95563ac72ebe9970643cad, cb0f3d287857d5385f4a879f8ab565d71bc8f068 and 58def1fd1de0de7d5732519539503a7ad83f24a2
4Ubuntu-Bug: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1163638
5Index: pulseaudio-2.1/src/modules/reserve-monitor.c
6===================================================================
7--- pulseaudio-2.1.orig/src/modules/reserve-monitor.c 2009-12-07 13:10:37.000000000 +0100
8+++ pulseaudio-2.1/src/modules/reserve-monitor.c 2013-05-15 20:07:20.995250003 +0200
9@@ -32,6 +32,7 @@
10 #include <assert.h>
11
12 #include "reserve-monitor.h"
13+#include "reserve.h"
14
15 struct rm_monitor {
16 int ref;
17@@ -59,6 +60,23 @@
18 "member='NameOwnerChanged'," \
19 "arg0='%s'"
20
21+static unsigned get_busy(
22+ DBusConnection *c,
23+ const char *name_owner) {
24+
25+ const char *un;
26+
27+ if (!name_owner || !*name_owner)
28+ return FALSE;
29+
30+ /* If we ourselves own the device, then don't consider this 'busy' */
31+ if ((un = dbus_bus_get_unique_name(c)))
32+ if (strcmp(name_owner, un) == 0)
33+ return FALSE;
34+
35+ return TRUE;
36+}
37+
38 static DBusHandlerResult filter_handler(
39 DBusConnection *c,
40 DBusMessage *s,
41@@ -85,18 +103,11 @@
42 goto invalid;
43
44 if (strcmp(name, m->service_name) == 0) {
45- m->busy = !!(new && *new);
46+ unsigned old_busy = m->busy;
47
48- /* If we ourselves own the device, then don't consider this 'busy' */
49- if (m->busy) {
50- const char *un;
51-
52- if ((un = dbus_bus_get_unique_name(c)))
53- if (strcmp(new, un) == 0)
54- m->busy = FALSE;
55- }
56+ m->busy = get_busy(c, new);
57
58- if (m->change_cb) {
59+ if (m->busy != old_busy && m->change_cb) {
60 m->ref++;
61 m->change_cb(m);
62 rm_release(m);
63@@ -113,11 +124,12 @@
64 int rm_watch(
65 rm_monitor **_m,
66 DBusConnection *connection,
67- const char*device_name,
68+ const char *device_name,
69 rm_change_cb_t change_cb,
70 DBusError *error) {
71
72 rm_monitor *m = NULL;
73+ char *name_owner;
74 int r;
75 DBusError _error;
76
77@@ -176,12 +188,11 @@
78
79 m->matching = 1;
80
81- m->busy = dbus_bus_name_has_owner(m->connection, m->service_name, error);
82-
83- if (dbus_error_is_set(error)) {
84- r = -EIO;
85+ if ((r = rd_dbus_get_name_owner(m->connection, m->service_name, &name_owner, error)) < 0)
86 goto fail;
87- }
88+
89+ m->busy = get_busy(m->connection, name_owner);
90+ free(name_owner);
91
92 *_m = m;
93 return 0;
94Index: pulseaudio-2.1/src/modules/reserve.c
95===================================================================
96--- pulseaudio-2.1.orig/src/modules/reserve.c 2009-12-07 13:10:37.000000000 +0100
97+++ pulseaudio-2.1/src/modules/reserve.c 2013-05-15 20:07:23.723250100 +0200
98@@ -293,6 +293,7 @@
99
100 rd_device *d;
101 DBusError error;
102+ char *name_owner = NULL;
103
104 dbus_error_init(&error);
105
106@@ -310,6 +311,21 @@
107 goto invalid;
108
109 if (strcmp(name, d->service_name) == 0 && d->owning) {
110+ /* Verify the actual owner of the name to avoid leaked NameLost
111+ * signals from previous reservations. The D-Bus daemon will send
112+ * all messages asynchronously in the correct order, but we could
113+ * potentially process them too late due to the pseudo-blocking
114+ * call mechanism used during both acquisition and release. This
115+ * can happen if we release the device and immediately after
116+ * reacquire it before NameLost is processed. */
117+ if (!d->gave_up) {
118+ const char *un;
119+
120+ if ((un = dbus_bus_get_unique_name(c)) && rd_dbus_get_name_owner(c, d->service_name, &name_owner, &error) == 0)
121+ if (strcmp(name_owner, un) == 0)
122+ goto invalid; /* Name still owned by us */
123+ }
124+
125 d->owning = 0;
126
127 if (!d->gave_up) {
128@@ -326,6 +342,7 @@
129 }
130
131 invalid:
132+ free(name_owner);
133 dbus_error_free(&error);
134
135 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
136@@ -606,3 +623,59 @@
137
138 return d->userdata;
139 }
140+
141+int rd_dbus_get_name_owner(
142+ DBusConnection *connection,
143+ const char *name,
144+ char **name_owner,
145+ DBusError *error) {
146+
147+ DBusMessage *msg, *reply;
148+ int r;
149+
150+ *name_owner = NULL;
151+
152+ if (!(msg = dbus_message_new_method_call(DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, "GetNameOwner"))) {
153+ r = -ENOMEM;
154+ goto fail;
155+ }
156+
157+ if (!dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) {
158+ r = -ENOMEM;
159+ goto fail;
160+ }
161+
162+ reply = dbus_connection_send_with_reply_and_block(connection, msg, DBUS_TIMEOUT_USE_DEFAULT, error);
163+ dbus_message_unref(msg);
164+ msg = NULL;
165+
166+ if (reply) {
167+ if (!dbus_message_get_args(reply, error, DBUS_TYPE_STRING, name_owner, DBUS_TYPE_INVALID)) {
168+ dbus_message_unref(reply);
169+ r = -EIO;
170+ goto fail;
171+ }
172+
173+ *name_owner = strdup(*name_owner);
174+ dbus_message_unref(reply);
175+
176+ if (!*name_owner) {
177+ r = -ENOMEM;
178+ goto fail;
179+ }
180+
181+ } else if (dbus_error_has_name(error, "org.freedesktop.DBus.Error.NameHasNoOwner"))
182+ dbus_error_free(error);
183+ else {
184+ r = -EIO;
185+ goto fail;
186+ }
187+
188+ return 0;
189+
190+fail:
191+ if (msg)
192+ dbus_message_unref(msg);
193+
194+ return r;
195+}
196Index: pulseaudio-2.1/src/modules/reserve.h
197===================================================================
198--- pulseaudio-2.1.orig/src/modules/reserve.h 2011-10-28 14:44:20.000000000 +0200
199+++ pulseaudio-2.1/src/modules/reserve.h 2013-05-15 20:07:20.997250003 +0200
200@@ -72,6 +72,15 @@
201 * userdata was set. */
202 void* rd_get_userdata(rd_device *d);
203
204+/* Helper function to get the unique connection name owning a given
205+ * name. Returns 0 on success, a negative errno style return value on
206+ * error. */
207+int rd_dbus_get_name_owner(
208+ DBusConnection *connection,
209+ const char *name,
210+ char **name_owner,
211+ DBusError *error);
212+
213 #ifdef __cplusplus
214 }
215 #endif
0216
=== modified file 'debian/patches/series'
--- debian/patches/series 2012-10-04 12:44:16 +0000
+++ debian/patches/series 2013-05-20 18:29:27 +0000
@@ -12,3 +12,4 @@
120020-stream-Return-error-in-case-a-client-peeks-to-early.patch120020-stream-Return-error-in-case-a-client-peeks-to-early.patch
130100-resampler-Fix-volume-on-downmix-to-mono.patch130100-resampler-Fix-volume-on-downmix-to-mono.patch
140101-alsa-mixer-Remove-analog-output-lfe-on-mono.patch140101-alsa-mixer-Remove-analog-output-lfe-on-mono.patch
150102-reserve-card.patch

Subscribers

People subscribed via source and target branches