[pulseaudio-discuss] [PATCH 3/5] bluetooth: ofono: Detect if Connect has been called

Luiz Augusto von Dentz luiz.dentz at gmail.com
Mon Apr 24 15:33:47 UTC 2017


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

This detects if profile has already been called and we are waiting
the response.
---
 src/modules/bluetooth/backend-ofono.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/modules/bluetooth/backend-ofono.c b/src/modules/bluetooth/backend-ofono.c
index 3fbf153..57c947b 100644
--- a/src/modules/bluetooth/backend-ofono.c
+++ b/src/modules/bluetooth/backend-ofono.c
@@ -65,6 +65,7 @@ struct hf_audio_card {
     char *remote_address;
     char *local_address;
 
+    bool connecting;
     int fd;
     uint8_t codec;
 
@@ -158,8 +159,12 @@ static int hf_audio_agent_transport_acquire(pa_bluetooth_transport *t, bool opti
     if (!optional && card->fd < 0) {
         DBusMessage *m;
 
+        if (card->connecting)
+            return -1;
+
         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(card->backend->connection), m, NULL));
+	card->connecting = true;
 
         return -1;
     }
@@ -535,6 +540,8 @@ static DBusMessage *hf_audio_agent_new_connection(DBusConnection *c, DBusMessage
 
     card = pa_hashmap_get(backend->cards, path);
 
+    card->connecting = false;
+
     if (!card || codec != HFP_AUDIO_CODEC_CVSD || card->transport->state == PA_BLUETOOTH_TRANSPORT_STATE_PLAYING) {
         pa_log_warn("New audio connection invalid arguments (path=%s fd=%d, codec=%d)", path, fd, codec);
         pa_assert_se(r = dbus_message_new_error(m, "org.ofono.Error.InvalidArguments", "Invalid arguments in method call"));
-- 
2.9.3



More information about the pulseaudio-discuss mailing list