[pulseaudio-discuss] [RFC next v0 08/11] bluetooth: Add transport acquire/release callbacks to backend
Mikel Astiz
mikel.astiz.oss at gmail.com
Wed May 15 01:46:53 PDT 2013
From: Mikel Astiz <mikel.astiz at bmw-carit.de>
Transport acquisition and release are backend-dependant so add the
necessary callbacks to struct pa_bluetooth_backend.
---
src/modules/bluetooth/bluetooth-util.c | 28 ++++++++++++++++++++++++++++
src/modules/bluetooth/bluetooth-util.h | 5 +++++
2 files changed, 33 insertions(+)
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 744a036..d89c7a7 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1474,6 +1474,18 @@ bool pa_bluetooth_device_any_audio_connected(const pa_bluetooth_device *d) {
}
int pa_bluetooth_transport_acquire(pa_bluetooth_transport *t, bool optional, size_t *imtu, size_t *omtu) {
+ struct pa_bluetooth_discovery *y;
+ pa_bluetooth_backend *backend;
+
+ pa_assert(t);
+ pa_assert(t->device);
+ pa_assert_se(y = t->device->discovery);
+ pa_assert_se(backend = y->profiles[t->profile].backend);
+
+ return backend->transport_acquire(y->profiles[t->profile].backend_private, t, optional, imtu, omtu);
+}
+
+static int bluez_backend_transport_acquire(void *bp, pa_bluetooth_transport *t, bool optional, size_t *imtu, size_t *omtu) {
DBusMessage *m, *r;
DBusError err;
int ret;
@@ -1486,6 +1498,8 @@ int pa_bluetooth_transport_acquire(pa_bluetooth_transport *t, bool optional, siz
pa_assert(t->device->discovery);
pa_assert_se(p = t->backend_private);
+ assert(t);
+
dbus_error_init(&err);
if (t->device->discovery->version == BLUEZ_VERSION_4) {
@@ -1546,6 +1560,18 @@ fail:
}
void pa_bluetooth_transport_release(pa_bluetooth_transport *t) {
+ struct pa_bluetooth_discovery *y;
+ pa_bluetooth_backend *backend;
+
+ pa_assert(t);
+ pa_assert(t->device);
+ pa_assert_se(y = t->device->discovery);
+ pa_assert_se(backend = y->profiles[t->profile].backend);
+
+ return backend->transport_release(y->profiles[t->profile].backend_private, t);
+}
+
+static void bluez_backend_transport_release(void *bp, pa_bluetooth_transport *t) {
DBusMessage *m;
DBusError err;
bluez_transport_private *p;
@@ -2033,6 +2059,8 @@ static DBusHandlerResult endpoint_handler(DBusConnection *c, DBusMessage *m, voi
pa_bluetooth_backend bluez_backend = {
.transport_removed = bluez_backend_transport_removed,
+ .transport_acquire = bluez_backend_transport_acquire,
+ .transport_release = bluez_backend_transport_release,
};
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 e683551..3495a1b 100644
--- a/src/modules/bluetooth/bluetooth-util.h
+++ b/src/modules/bluetooth/bluetooth-util.h
@@ -182,9 +182,14 @@ 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);
+typedef int (*pa_bt_backend_transport_acquire_cb)(void *bp, pa_bluetooth_transport *t, bool optional, size_t *imtu,
+ size_t *omtu);
+typedef void (*pa_bt_backend_transport_release_cb)(void *bp, pa_bluetooth_transport *t);
struct pa_bluetooth_backend {
pa_bt_backend_transport_removed_cb transport_removed;
+ pa_bt_backend_transport_acquire_cb transport_acquire;
+ pa_bt_backend_transport_release_cb transport_release;
};
int pa_bt_backend_register(pa_bluetooth_discovery *y, pa_bluetooth_backend *b, enum profile p, void *bp);
--
1.8.1.4
More information about the pulseaudio-discuss
mailing list