[RFC next v0 07/11] bluetooth: Add device removed callback to backend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Mikel Astiz <mikel.astiz@xxxxxxxxxxxx>

This callback notifies the backend that the core needs to destroy the
transport.
---
 src/modules/bluetooth/bluetooth-util.c | 12 ++++++++++--
 src/modules/bluetooth/bluetooth-util.h |  3 +++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index be82331..744a036 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -274,9 +274,11 @@ static void transport_free(pa_bluetooth_transport *t) {
     pa_xfree(t);
 }
 
-static void bluez_backend_transport_removed(bluez_backend_private *bbp, pa_bluetooth_transport *t) {
+static void bluez_backend_transport_removed(void *bp, pa_bluetooth_transport *t) {
+    bluez_backend_private *bbp;
     bluez_transport_private *p;
 
+    pa_assert_se(bbp = bp);
     pa_assert(t);
     pa_assert_se(p = t->backend_private);
 
@@ -291,11 +293,16 @@ static void device_free(pa_bluetooth_device *d) {
     pa_assert(d);
 
     for (i = 0; i < PA_BLUETOOTH_PROFILE_COUNT; i++) {
+        pa_bluetooth_backend *backend;
+
         if (!(t = d->transports[i]))
             continue;
 
         d->transports[i] = NULL;
-        bluez_backend_transport_removed(&d->discovery->backend_private, t);
+
+        if ((backend = d->discovery->profiles[i].backend))
+            backend->transport_removed(d->discovery->profiles[i].backend_private, t);
+
         t->state = PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED;
         pa_hook_fire(&d->discovery->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED], t);
         transport_free(t);
@@ -2025,6 +2032,7 @@ static DBusHandlerResult endpoint_handler(DBusConnection *c, DBusMessage *m, voi
 }
 
 pa_bluetooth_backend bluez_backend = {
+    .transport_removed = bluez_backend_transport_removed,
 };
 
 static void bluez_backend_init(pa_bluetooth_discovery *y) {
diff --git a/src/modules/bluetooth/bluetooth-util.h b/src/modules/bluetooth/bluetooth-util.h
index a4d365e..e683551 100644
--- a/src/modules/bluetooth/bluetooth-util.h
+++ b/src/modules/bluetooth/bluetooth-util.h
@@ -181,7 +181,10 @@ const char *pa_bt_profile_to_string(enum profile profile);
 struct pa_bluetooth_backend;
 typedef struct pa_bluetooth_backend pa_bluetooth_backend;
 
+typedef void (*pa_bt_backend_transport_removed_cb)(void *bp, pa_bluetooth_transport *t);
+
 struct pa_bluetooth_backend {
+    pa_bt_backend_transport_removed_cb transport_removed;
 };
 
 int pa_bt_backend_register(pa_bluetooth_discovery *y, pa_bluetooth_backend *b, enum profile p, void *bp);
-- 
1.8.1.4



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux