[pulseaudio-discuss] [PATCH v0 13/16] bluetooth: Add hook to tell transport was removed

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


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

Add a hook to report that the transport was removed from D-Bus, and thus
references to it should be released.
---
 src/modules/bluetooth/bluetooth-util.c | 5 ++++-
 src/modules/bluetooth/bluetooth-util.h | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 803a24d..986f5c0 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -171,8 +171,10 @@ static void device_free(pa_bluetooth_device *d) {
 
     pa_assert(d);
 
-    while ((t = pa_hashmap_steal_first(d->transports)))
+    while ((t = pa_hashmap_steal_first(d->transports))) {
+        pa_hook_fire(&t->hooks[PA_BLUETOOTH_TRANSPORT_HOOK_REMOVED], NULL);
         pa_bluetooth_transport_unref(t);
+    }
 
     pa_hashmap_free(d->transports, NULL, NULL);
 
@@ -1203,6 +1205,7 @@ static DBusMessage *endpoint_clear_configuration(DBusConnection *c, DBusMessage
         if ((t = pa_hashmap_get(d->transports, path))) {
             pa_log_debug("Clearing transport %s profile %d", t->path, t->profile);
             pa_hashmap_remove(d->transports, t->path);
+            pa_hook_fire(&t->hooks[PA_BLUETOOTH_TRANSPORT_HOOK_REMOVED], NULL);
             pa_bluetooth_transport_unref(t);
             break;
         }
diff --git a/src/modules/bluetooth/bluetooth-util.h b/src/modules/bluetooth/bluetooth-util.h
index e102521..35fb41b 100644
--- a/src/modules/bluetooth/bluetooth-util.h
+++ b/src/modules/bluetooth/bluetooth-util.h
@@ -66,6 +66,7 @@ enum profile {
 /* Hook data: pa_bluetooth_transport pointer. */
 typedef enum pa_bluetooth_transport_hook {
     PA_BLUETOOTH_TRANSPORT_HOOK_NREC_CHANGED, /* Call data: NULL. */
+    PA_BLUETOOTH_TRANSPORT_HOOK_REMOVED, /* Call data: NULL. */
     PA_BLUETOOTH_TRANSPORT_HOOK_MAX
 } pa_bluetooth_transport_hook_t;
 
-- 
1.7.11.4



More information about the pulseaudio-discuss mailing list