[pulseaudio-discuss] [PATCH next v0 5/8] bluetooth: Add device pointer to transport

Mikel Astiz mikel.astiz.oss at gmail.com
Wed Dec 5 08:23:15 PST 2012


From: Mikel Astiz <mikel.astiz at bmw-carit.de>

Transports always have an associated device, so add the pointer as a
member to the structure, and remove the discovery pointer since it
already exists in the device object.
---
 src/modules/bluetooth/bluetooth-util.c | 17 ++++++++++-------
 src/modules/bluetooth/bluetooth-util.h |  2 +-
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index e2d2e62..0daf1c9 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1022,13 +1022,14 @@ int pa_bluetooth_transport_acquire(pa_bluetooth_transport *t, const char *access
     uint16_t i, o;
 
     pa_assert(t);
-    pa_assert(t->y);
+    pa_assert(t->device);
+    pa_assert(t->device->discovery);
 
     dbus_error_init(&err);
 
     pa_assert_se(m = dbus_message_new_method_call(t->owner, t->path, "org.bluez.MediaTransport", "Acquire"));
     pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_STRING, &accesstype, DBUS_TYPE_INVALID));
-    r = dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(t->y->connection), m, -1, &err);
+    r = dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(t->device->discovery->connection), m, -1, &err);
 
     if (dbus_error_is_set(&err) || !r) {
         dbus_error_free(&err);
@@ -1058,13 +1059,14 @@ void pa_bluetooth_transport_release(pa_bluetooth_transport *t, const char *acces
     DBusError err;
 
     pa_assert(t);
-    pa_assert(t->y);
+    pa_assert(t->device);
+    pa_assert(t->device->discovery);
 
     dbus_error_init(&err);
 
     pa_assert_se(m = dbus_message_new_method_call(t->owner, t->path, "org.bluez.MediaTransport", "Release"));
     pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_STRING, &accesstype, DBUS_TYPE_INVALID));
-    dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(t->y->connection), m, -1, &err);
+    dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(t->device->discovery->connection), m, -1, &err);
 
     if (dbus_error_is_set(&err)) {
         pa_log("Failed to release transport %s: %s", t->path, err.message);
@@ -1089,12 +1091,13 @@ static int setup_dbus(pa_bluetooth_discovery *y) {
     return 0;
 }
 
-static pa_bluetooth_transport *transport_new(pa_bluetooth_discovery *y, const char *owner, const char *path, enum profile p, const uint8_t *config, int size) {
+static pa_bluetooth_transport *transport_new(pa_bluetooth_device *d, const char *owner, const char *path, enum profile p,
+                                             const uint8_t *config, int size) {
     pa_bluetooth_transport *t;
     unsigned i;
 
     t = pa_xnew0(pa_bluetooth_transport, 1);
-    t->y = y;
+    t->device = d;
     t->owner = pa_xstrdup(owner);
     t->path = pa_xstrdup(path);
     t->profile = p;
@@ -1186,7 +1189,7 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
 
     sender = dbus_message_get_sender(m);
 
-    t = transport_new(y, sender, path, p, config, size);
+    t = transport_new(d, sender, path, p, config, size);
     if (nrec)
         t->nrec = nrec;
     pa_hashmap_put(d->transports, t->path, t);
diff --git a/src/modules/bluetooth/bluetooth-util.h b/src/modules/bluetooth/bluetooth-util.h
index 33ef4cf..89e8390 100644
--- a/src/modules/bluetooth/bluetooth-util.h
+++ b/src/modules/bluetooth/bluetooth-util.h
@@ -71,7 +71,7 @@ typedef enum pa_bluetooth_transport_hook {
 } pa_bluetooth_transport_hook_t;
 
 struct pa_bluetooth_transport {
-    pa_bluetooth_discovery *y;
+    pa_bluetooth_device *device;
     char *owner;
     char *path;
     enum profile profile;
-- 
1.7.11.7



More information about the pulseaudio-discuss mailing list