[pulseaudio-discuss] [PATCH] reserve-monitor: Don't trigger on our own events
David Henningsson
david.henningsson at canonical.com
Fri Jan 11 05:04:54 PST 2013
This fixes a bug where pulseaudio would give up the device (due to
a request from JACK), but then immediately grab it again because
the monitor callback fired, telling that the device is now available.
(Note: the protocol does not specify a timeout, i e if pulseaudio
is requested to give its device up but JACK does not grab the dbus name,
at what point is PulseAudio allowed to re-grab it?)
Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---
src/modules/reserve-monitor.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
Will commit this to stable-3.x and master in a few days if there are
no objections.
@Lennart, would you mind committing this to the upstream reserve.git repo as well?
diff --git a/src/modules/reserve-monitor.c b/src/modules/reserve-monitor.c
index ab453e6..ac74849 100644
--- a/src/modules/reserve-monitor.c
+++ b/src/modules/reserve-monitor.c
@@ -59,6 +59,23 @@ struct rm_monitor {
"member='NameOwnerChanged'," \
"arg0='%s'"
+/* If we ourselves own the device, then don't consider this 'busy' */
+static unsigned is_really_busy(
+ DBusConnection *c,
+ const char *name) {
+
+ const char *un;
+
+ if (!name || !(*name))
+ return FALSE;
+
+ if ((un = dbus_bus_get_unique_name(c)))
+ if (strcmp(name, un) == 0)
+ return FALSE;
+
+ return TRUE;
+}
+
static DBusHandlerResult filter_handler(
DBusConnection *c,
DBusMessage *s,
@@ -85,18 +102,9 @@ static DBusHandlerResult filter_handler(
goto invalid;
if (strcmp(name, m->service_name) == 0) {
- m->busy = !!(new && *new);
-
- /* If we ourselves own the device, then don't consider this 'busy' */
- if (m->busy) {
- const char *un;
-
- if ((un = dbus_bus_get_unique_name(c)))
- if (strcmp(new, un) == 0)
- m->busy = FALSE;
- }
+ m->busy = is_really_busy(c, new);
- if (m->change_cb) {
+ if (m->change_cb && (is_really_busy(c, old) || m->busy)) {
m->ref++;
m->change_cb(m);
rm_release(m);
--
1.7.9.5
More information about the pulseaudio-discuss
mailing list