]> code.delx.au - pulseaudio/commitdiff
bluetooth: Create infrastrucure for bluetooth hooks
authorJoão Paulo Rechi Vita <jprvita@openbossa.org>
Wed, 18 Sep 2013 21:16:56 +0000 (16:16 -0500)
committerTanu Kaskinen <tanu.kaskinen@linux.intel.com>
Sun, 29 Sep 2013 13:54:36 +0000 (16:54 +0300)
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
src/modules/bluetooth/bluez5-util.h

index 36f1b264c17f9b6a331517835657d956679aec3e..bfb335946955c5f4f6728af9c55f2500006527dc 100644 (file)
@@ -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);
index 56602bf48432c887d11956b3d84d9c8a39b86c29..afbd8e9b245d315461b0329f5824de1ea6baccfe 100644 (file)
 
 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);