|
|
2b72d0 |
From e02e290d7cccd0cfbc89bacf5c0be7934ee58ece Mon Sep 17 00:00:00 2001
|
|
|
2b72d0 |
From: Tanu Kaskinen <tanuk@iki.fi>
|
|
|
2b72d0 |
Date: Wed, 16 Jan 2013 03:36:03 +0200
|
|
|
2b72d0 |
Subject: [PATCH 4/7] Call change_cb() only when there's an actual change.
|
|
|
2b72d0 |
|
|
|
2b72d0 |
Calling change_cb() whenever anything happens in the ownership of the
|
|
|
2b72d0 |
bus name caused trouble in PulseAudio in this scenario:
|
|
|
2b72d0 |
|
|
|
2b72d0 |
1. PulseAudio is using a device and owns the corresponding service
|
|
|
2b72d0 |
name.
|
|
|
2b72d0 |
2. Another application requests device release.
|
|
|
2b72d0 |
3. PulseAudio releases the device.
|
|
|
2b72d0 |
4. Change in the bus name ownership: PulseAudio gives up the
|
|
|
2b72d0 |
ownership, and nobody owns the name.
|
|
|
2b72d0 |
5. reserve-monitor notices that, and notifies PulseAudio.
|
|
|
2b72d0 |
6. Since reserve-monitor reports the device as "not busy", PulseAudio
|
|
|
2b72d0 |
decides to reserve the bus name immediately back to itself and
|
|
|
2b72d0 |
opens the device again.
|
|
|
2b72d0 |
|
|
|
2b72d0 |
The other application will forcibly take the bus name to itself, as
|
|
|
2b72d0 |
it should according to the protocol, but the other application may
|
|
|
2b72d0 |
have trouble opening the device if it tries to do that before
|
|
|
2b72d0 |
PulseAudio has had time to react to the NameLost signal.
|
|
|
2b72d0 |
|
|
|
2b72d0 |
This can be solved by not calling change_cb() if there are no changes
|
|
|
2b72d0 |
in the device busy status. In this scenario the device is considered
|
|
|
2b72d0 |
"not busy" while PulseAudio is owning the bus name, so PulseAudio gets
|
|
|
2b72d0 |
no notification when the ownership changes from PulseAudio to nobody.
|
|
|
2b72d0 |
---
|
|
|
2b72d0 |
src/modules/reserve-monitor.c | 4 +++-
|
|
|
2b72d0 |
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
|
2b72d0 |
|
|
|
2b72d0 |
diff --git a/src/modules/reserve-monitor.c b/src/modules/reserve-monitor.c
|
|
|
2b72d0 |
index ab453e6..4097a6f 100644
|
|
|
2b72d0 |
--- a/src/modules/reserve-monitor.c
|
|
|
2b72d0 |
+++ b/src/modules/reserve-monitor.c
|
|
|
2b72d0 |
@@ -85,6 +85,8 @@ static DBusHandlerResult filter_handler(
|
|
|
2b72d0 |
goto invalid;
|
|
|
2b72d0 |
|
|
|
2b72d0 |
if (strcmp(name, m->service_name) == 0) {
|
|
|
2b72d0 |
+ unsigned old_busy = m->busy;
|
|
|
2b72d0 |
+
|
|
|
2b72d0 |
m->busy = !!(new && *new);
|
|
|
2b72d0 |
|
|
|
2b72d0 |
/* If we ourselves own the device, then don't consider this 'busy' */
|
|
|
2b72d0 |
@@ -96,7 +98,7 @@ static DBusHandlerResult filter_handler(
|
|
|
2b72d0 |
m->busy = FALSE;
|
|
|
2b72d0 |
}
|
|
|
2b72d0 |
|
|
|
2b72d0 |
- if (m->change_cb) {
|
|
|
2b72d0 |
+ if (m->busy != old_busy && m->change_cb) {
|
|
|
2b72d0 |
m->ref++;
|
|
|
2b72d0 |
m->change_cb(m);
|
|
|
2b72d0 |
rm_release(m);
|
|
|
2b72d0 |
--
|
|
|
2b72d0 |
1.8.1.4
|
|
|
2b72d0 |
|