PA_LLIST_HEAD(pa_dbus_pending, pending);
pa_hashmap *devices;
pa_hashmap *transports;
- pa_hook hook;
+ pa_hook hooks[PA_BLUETOOTH_HOOK_MAX];
pa_bool_t filter_added;
};
return;
d->dead = dead;
- pa_hook_fire(&d->discovery->hook, d);
+ pa_hook_fire(&d->discovery->hooks[PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED], d);
}
static void remove_all_devices(pa_bluetooth_discovery *y) {
pa_assert(PA_REFCNT_VALUE(y) > 0);
pa_assert(address);
- if (!pa_hook_is_firing(&y->hook))
+ if (!pa_hook_is_firing(&y->hooks[PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED]))
pa_bluetooth_discovery_sync(y);
while ((d = pa_hashmap_iterate(y->devices, &state, NULL)))
pa_assert(PA_REFCNT_VALUE(y) > 0);
pa_assert(path);
- if (!pa_hook_is_firing(&y->hook))
+ if (!pa_hook_is_firing(&y->hooks[PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED]))
pa_bluetooth_discovery_sync(y);
if ((d = pa_hashmap_get(y->devices, path)))
pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
DBusError err;
pa_bluetooth_discovery *y;
+ unsigned i;
static const DBusObjectPathVTable vtable_endpoint = {
.message_function = endpoint_handler,
};
y->devices = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
y->transports = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
PA_LLIST_HEAD_INIT(pa_dbus_pending, y->pending);
- pa_hook_init(&y->hook, y);
+
+ for (i = 0; i < PA_BLUETOOTH_HOOK_MAX; i++)
+ pa_hook_init(&y->hooks[i], y);
+
pa_shared_set(c, "bluetooth-discovery", y);
if (setup_dbus(y) < 0)
}
void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
+ unsigned i;
+
pa_assert(y);
pa_assert(PA_REFCNT_VALUE(y) > 0);
pa_dbus_connection_unref(y->connection);
}
- pa_hook_done(&y->hook);
+ for (i = 0; i < PA_BLUETOOTH_HOOK_MAX; i++)
+ pa_hook_done(&y->hooks[i]);
if (y->core)
pa_shared_remove(y->core, "bluetooth-discovery");
pa_dbus_sync_pending_list(&y->pending);
}
-pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *y) {
+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->hook;
+ return &y->hooks[hook];
}
const char*pa_bluetooth_get_form_factor(uint32_t class) {
#define PA_BLUETOOTH_PROFILE_COUNT PROFILE_OFF
+/* Hook data: pa_bluetooth_discovery pointer. */
+typedef enum pa_bluetooth_hook {
+ PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED, /* Call data: pa_bluetooth_device */
+ PA_BLUETOOTH_HOOK_MAX
+} pa_bluetooth_hook_t;
+
/* Hook data: pa_bluetooth_transport pointer. */
typedef enum pa_bluetooth_transport_hook {
PA_BLUETOOTH_TRANSPORT_HOOK_NREC_CHANGED, /* Call data: NULL. */
int pa_bluetooth_transport_acquire(pa_bluetooth_transport *t, const char *accesstype, size_t *imtu, size_t *omtu);
void pa_bluetooth_transport_release(pa_bluetooth_transport *t, const char *accesstype);
-pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *d);
+pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *y, pa_bluetooth_hook_t hook);
const char* pa_bluetooth_get_form_factor(uint32_t class);
if (!(device = find_device(u, address, path)))
goto fail;
- u->discovery_slot = pa_hook_connect(pa_bluetooth_discovery_hook(u->discovery), PA_HOOK_NORMAL,
- (pa_hook_cb_t) discovery_hook_cb, u);
-
u->device = device;
+ u->discovery_slot =
+ pa_hook_connect(pa_bluetooth_discovery_hook(u->discovery, PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED),
+ PA_HOOK_NORMAL, (pa_hook_cb_t) discovery_hook_cb, u);
+
u->uuid_added_slot = pa_hook_connect(&device->hooks[PA_BLUETOOTH_DEVICE_HOOK_UUID_ADDED], PA_HOOK_NORMAL,
(pa_hook_cb_t) uuid_added_cb, u);