[pulseaudio-discuss] [PATCH] bluetooth: ofono: Use Acquire method if available

Luiz Augusto von Dentz luiz.dentz at gmail.com
Fri May 5 13:51:08 UTC 2017


From: Luiz Augusto von Dentz <luiz.von.dentz at intel.com>

Attempt to use Acquire method if available falling back to Connect in
case it fails.
---
 src/modules/bluetooth/backend-ofono.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/modules/bluetooth/backend-ofono.c b/src/modules/bluetooth/backend-ofono.c
index 6e9a366..a5e6b31 100644
--- a/src/modules/bluetooth/backend-ofono.c
+++ b/src/modules/bluetooth/backend-ofono.c
@@ -163,6 +163,18 @@ static int hf_audio_agent_transport_acquire(pa_bluetooth_transport *t, bool opti
         if (card->connecting)
             return -EAGAIN;
 
+        /* Try acquiring the stream first */
+        dbus_error_init(&derr);
+        pa_assert_se(m = dbus_message_new_method_call(t->owner, t->path, "org.ofono.HandsfreeAudioCard", "Acquire"));
+        r = dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(card->backend->connection), m, -1, &derr);
+        if (r && (dbus_message_get_args(r, NULL,
+                              DBUS_TYPE_UNIX_FD, &card->fd,
+                              DBUS_TYPE_BYTE, &card->codec,
+                              DBUS_TYPE_INVALID) == true)) {
+             goto done;
+        }
+
+        /* Fallback to Connect as this might be an old version of ofono */
         card->connecting = true;
 
         dbus_error_init(&derr);
@@ -175,6 +187,7 @@ static int hf_audio_agent_transport_acquire(pa_bluetooth_transport *t, bool opti
             return -EAGAIN;
     }
 
+done:
     /* 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
-- 
2.9.3



More information about the pulseaudio-discuss mailing list