[PATCH v4 02/41] bluetooth: Create infrastrucure for bluetooth hooks

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

 



From: Jo?o Paulo Rechi Vita <jprvita@xxxxxxxxxxxxx>

Create a pa_bluetooth_hook enum type and API to get pa_hooks from the
opaque pa_bluetooth_discovery struct.
---
 src/modules/bluetooth/bluez5-util.c | 12 ++++++++++++
 src/modules/bluetooth/bluez5-util.h |  6 ++++++
 2 files changed, 18 insertions(+)

diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c
index 36f1b26..bfb3359 100644
--- a/src/modules/bluetooth/bluez5-util.c
+++ b/src/modules/bluetooth/bluez5-util.c
@@ -44,8 +44,16 @@ struct pa_bluetooth_discovery {
     pa_dbus_connection *connection;
     bool filter_added;
     bool matches_added;
+    pa_hook hooks[PA_BLUETOOTH_HOOK_MAX];
 };
 
+pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *y, pa_bluetooth_hook_t hook) {
+    pa_assert(y);
+    pa_assert(PA_REFCNT_VALUE(y) > 0);
+
+    return &y->hooks[hook];
+}
+
 static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *userdata) {
     pa_bluetooth_discovery *y;
     DBusError err;
@@ -93,6 +101,7 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
     pa_bluetooth_discovery *y;
     DBusError err;
     DBusConnection *conn;
+    unsigned i;
 
     if ((y = pa_shared_get(c, "bluetooth-discovery")))
         return pa_bluetooth_discovery_ref(y);
@@ -101,6 +110,9 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
     PA_REFCNT_INIT(y);
     y->core = c;
 
+    for (i = 0; i < PA_BLUETOOTH_HOOK_MAX; i++)
+        pa_hook_init(&y->hooks[i], y);
+
     pa_shared_set(c, "bluetooth-discovery", y);
 
     dbus_error_init(&err);
diff --git a/src/modules/bluetooth/bluez5-util.h b/src/modules/bluetooth/bluez5-util.h
index 56602bf..afbd8e9 100644
--- a/src/modules/bluetooth/bluez5-util.h
+++ b/src/modules/bluetooth/bluez5-util.h
@@ -26,6 +26,12 @@
 
 typedef struct pa_bluetooth_discovery pa_bluetooth_discovery;
 
+typedef enum pa_bluetooth_hook {
+    PA_BLUETOOTH_HOOK_MAX
+} pa_bluetooth_hook_t;
+
+pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *y, pa_bluetooth_hook_t hook);
+
 pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core);
 pa_bluetooth_discovery* pa_bluetooth_discovery_ref(pa_bluetooth_discovery *y);
 void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y);
-- 
1.8.3.1



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

  Powered by Linux