bluetooth: Implement transport acquire for hf_audio_agent transports
authorJoão Paulo Rechi Vita <jprvita@openbossa.org>
Wed, 10 Jul 2013 01:22:28 +0000 (22:22 -0300)
committerJaska Uimonen <jaska.uimonen@intel.com>
Fri, 7 Mar 2014 10:43:58 +0000 (12:43 +0200)
src/modules/bluetooth/hfaudioagent-ofono.c

index 2e16a48..3684bed 100644 (file)
@@ -121,7 +121,33 @@ 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;
+        return hfac->fd;
+    } else
+        return -1;
 }
 
 static void hf_audio_agent_transport_release(pa_bluetooth_transport *t) {