[pulseaudio-discuss] [RFCv0 12/21] bluetooth: Implement transport acquire for hf_audio_agent transports

jprvita at gmail.com jprvita at gmail.com
Tue Feb 4 14:03:57 PST 2014


From: João Paulo Rechi Vita <jprvita at openbossa.org>

---
 src/modules/bluetooth/hfaudioagent-ofono.c | 35 +++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/src/modules/bluetooth/hfaudioagent-ofono.c b/src/modules/bluetooth/hfaudioagent-ofono.c
index d381a29..a565601 100644
--- a/src/modules/bluetooth/hfaudioagent-ofono.c
+++ b/src/modules/bluetooth/hfaudioagent-ofono.c
@@ -23,6 +23,8 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
+
 #include <pulsecore/core-util.h>
 #include <pulsecore/dbus-shared.h>
 #include <pulsecore/shared.h>
@@ -121,7 +123,38 @@ static void hf_audio_card_free(void *data) {
 }
 
 static int hf_audio_agent_transport_acquire(pa_bluetooth_transport *t, bool optional, size_t *imtu, size_t *omtu) {
-    return -1;
+    hf_audio_agent_data *hfdata = t->userdata;
+    hf_audio_card *hfac = pa_hashmap_get(hfdata->hf_audio_cards, t->path);
+
+    if (!optional) {
+        DBusMessage *m;
+
+        pa_assert_se(m = dbus_message_new_method_call(t->owner, t->path, "org.ofono.HandsfreeAudioCard", "Connect"));
+        pa_assert_se(dbus_connection_send(pa_dbus_connection_get(hfdata->connection), m, NULL));
+
+        return -1;
+    }
+
+    /* The correct block size should take into account the SCO MTU from
+     * the Bluetooth adapter and (for adapters in the USB bus) the MxPS
+     * value from the Isoc USB endpoint in use by btusb and should be
+     * made available to userspace by the Bluetooth kernel subsystem.
+     * Meanwhile the empiric value 48 will be used. */
+    if (imtu)
+        *imtu = 48;
+    if (omtu)
+        *omtu = 48;
+
+    if (hfac) {
+        t->codec = hfac->codec;
+
+        /* Do the socket deferred setup */
+        if (recv(hfac->fd, NULL, 0, 0) < 0)
+            pa_log_error("Deferred setup failed on fd %d: %s (%d)", hfac->fd, strerror(errno), errno);
+
+        return hfac->fd;
+    } else
+        return -1;
 }
 
 static void hf_audio_agent_transport_release(pa_bluetooth_transport *t) {
-- 
1.8.3.1



More information about the pulseaudio-discuss mailing list