summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanu Kaskinen <tanuk@iki.fi>2013-01-16 03:36:03 +0200
committerDavid Henningsson <david.henningsson@canonical.com>2013-01-17 11:45:27 +0100
commite02e290d7cccd0cfbc89bacf5c0be7934ee58ece (patch)
treedd9be09f8d034d8d981b77fdf94cd68d717469e1
parent3ffa0bc62afd8dbfa1d1cd5cef2177a96c461343 (diff)
Call change_cb() only when there's an actual change.
Calling change_cb() whenever anything happens in the ownership of the bus name caused trouble in PulseAudio in this scenario: 1. PulseAudio is using a device and owns the corresponding service name. 2. Another application requests device release. 3. PulseAudio releases the device. 4. Change in the bus name ownership: PulseAudio gives up the ownership, and nobody owns the name. 5. reserve-monitor notices that, and notifies PulseAudio. 6. Since reserve-monitor reports the device as "not busy", PulseAudio decides to reserve the bus name immediately back to itself and opens the device again. The other application will forcibly take the bus name to itself, as it should according to the protocol, but the other application may have trouble opening the device if it tries to do that before PulseAudio has had time to react to the NameLost signal. This can be solved by not calling change_cb() if there are no changes in the device busy status. In this scenario the device is considered "not busy" while PulseAudio is owning the bus name, so PulseAudio gets no notification when the ownership changes from PulseAudio to nobody.
-rw-r--r--src/modules/reserve-monitor.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/modules/reserve-monitor.c b/src/modules/reserve-monitor.c
index ab453e61..4097a6f0 100644
--- a/src/modules/reserve-monitor.c
+++ b/src/modules/reserve-monitor.c
@@ -85,6 +85,8 @@ static DBusHandlerResult filter_handler(
goto invalid;
if (strcmp(name, m->service_name) == 0) {
+ unsigned old_busy = m->busy;
+
m->busy = !!(new && *new);
/* If we ourselves own the device, then don't consider this 'busy' */
@@ -96,7 +98,7 @@ static DBusHandlerResult filter_handler(
m->busy = FALSE;
}
- if (m->change_cb) {
+ if (m->busy != old_busy && m->change_cb) {
m->ref++;
m->change_cb(m);
rm_release(m);