[pulseaudio-discuss] [PATCH v0 02/16] bluetooth: Ignore Device.DisconnectRequested

Mikel Astiz mikel.astiz.oss at gmail.com
Fri Sep 28 08:45:26 PDT 2012


From: Mikel Astiz <mikel.astiz at bmw-carit.de>

Handling the signal DisconnectRequested should be unnecessary since the
profile-specific interfaces will be later disconnected, leading to
module unload.

Additionally, the signal is problematic: if an interface (i.e.
A2DP AudioSource) is playing at the time DisconnectRequested is
signaled, the following sequence can occur:

1. AudioSource is playing
2. DisconnectRequested is received
3. Module is unloaded due to DisconnectRequested
4. AudioSource state changes from playing to connected
5. module-bluetooth-discover loads the module
6. AudioSource state changes from connected to disconnected

Therefore the module is unnecessarily loaded, to be unloaded immediately
afterwards. This can easily be reproduced if a device is unpaired while
the audio is streaming.

The simplest solution to this consists of removing step 3, by just
ignoring the DisconnectRequested signal. This reverts commit
8169a6a6c921215c1353e8a34fccbdc4e2e20440.
---
 src/modules/bluetooth/bluetooth-util.c | 18 ------------------
 1 file changed, 18 deletions(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index cb7b69d..245923d 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -863,22 +863,6 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
 
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
-    } else if (dbus_message_is_signal(m, "org.bluez.Device", "DisconnectRequested")) {
-        pa_bluetooth_device *d;
-
-        if ((d = pa_hashmap_get(y->devices, dbus_message_get_path(m)))) {
-            /* Device will disconnect in 2 sec */
-            d->audio_state = PA_BT_AUDIO_STATE_DISCONNECTED;
-            d->audio_sink_state = PA_BT_AUDIO_STATE_DISCONNECTED;
-            d->audio_source_state = PA_BT_AUDIO_STATE_DISCONNECTED;
-            d->headset_state = PA_BT_AUDIO_STATE_DISCONNECTED;
-            d->hfgw_state = PA_BT_AUDIO_STATE_DISCONNECTED;
-
-            run_callback(y, d, FALSE);
-        }
-
-        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
     } else if (dbus_message_is_signal(m, "org.freedesktop.DBus", "NameOwnerChanged")) {
         const char *name, *old_owner, *new_owner;
 
@@ -1472,7 +1456,6 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
                 "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceRemoved'",
                 "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceCreated'",
                 "type='signal',sender='org.bluez',interface='org.bluez.Device',member='PropertyChanged'",
-                "type='signal',sender='org.bluez',interface='org.bluez.Device',member='DisconnectRequested'",
                 "type='signal',sender='org.bluez',interface='org.bluez.Audio',member='PropertyChanged'",
                 "type='signal',sender='org.bluez',interface='org.bluez.Headset',member='PropertyChanged'",
                 "type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'",
@@ -1538,7 +1521,6 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
                                "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceRemoved'",
                                "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceCreated'",
                                "type='signal',sender='org.bluez',interface='org.bluez.Device',member='PropertyChanged'",
-                               "type='signal',sender='org.bluez',interface='org.bluez.Device',member='DisconnectRequested'",
                                "type='signal',sender='org.bluez',interface='org.bluez.Audio',member='PropertyChanged'",
                                "type='signal',sender='org.bluez',interface='org.bluez.Headset',member='PropertyChanged'",
                                "type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'",
-- 
1.7.11.4



More information about the pulseaudio-discuss mailing list