[pulseaudio-discuss] [PATCH 3/5] bluetooth: Fire DEVICE_CONNECTION_CHANGED in set_device_info_valid()

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Fri Nov 15 06:29:39 PST 2013


Normally DEVICE_CONNECTION_CHANGED is fired when the first transport
becomes connected, but it may happen that the first transport becomes
connected already before the device properties have been received. In
that case the hook should be fired at the time the device properties
are received. This patch makes the hook to be fired at the right time.
---
 src/modules/bluetooth/bluez5-util.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c
index e326695..b9a61b4 100644
--- a/src/modules/bluetooth/bluez5-util.c
+++ b/src/modules/bluetooth/bluez5-util.c
@@ -439,13 +439,19 @@ static void device_remove(pa_bluetooth_discovery *y, const char *path) {
 }
 
 static void set_device_info_valid(pa_bluetooth_device *device, int valid) {
+    bool old_any_connected;
+
     pa_assert(device);
     pa_assert(valid == -1 || valid == 0 || valid == 1);
 
     if (valid == device->device_info_valid)
         return;
 
+    old_any_connected = pa_bluetooth_device_any_transport_connected(device);
     device->device_info_valid = valid;
+
+    if (pa_bluetooth_device_any_transport_connected(device) != old_any_connected)
+        pa_hook_fire(&device->discovery->hooks[PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED], device);
 }
 
 static void device_remove_all(pa_bluetooth_discovery *y) {
@@ -455,7 +461,6 @@ static void device_remove_all(pa_bluetooth_discovery *y) {
 
     while ((d = pa_hashmap_steal_first(y->devices))) {
         set_device_info_valid(d, -1);
-        pa_hook_fire(&y->hooks[PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED], d);
         device_free(d);
    }
 }
-- 
1.8.3.1



More information about the pulseaudio-discuss mailing list