[pulseaudio-discuss] [PATCH v0 1/2] bluetooth: Fix premature acquire attempts

Mikel Astiz mikel.astiz.oss at gmail.com
Thu Feb 14 03:50:10 PST 2013


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

A transport should be considered connected only after the connection
procedure is complete, as expressed in audio_state_to_transport_state().

module-bluetooth-device should be loaded only after at least one
transport is not only created (during configuration), but also
connected.

This fixes the issue of premature acquire attempts sometimes experienced
when a headset is connected (issue not present in v3.0 though).
---
 src/modules/bluetooth/bluetooth-util.c          | 2 +-
 src/modules/bluetooth/module-bluetooth-device.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 98e795c..8ca4000 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1101,7 +1101,7 @@ bool pa_bluetooth_device_any_audio_connected(const pa_bluetooth_device *d) {
         return false;
 
     for (i = 0; i < PA_BLUETOOTH_PROFILE_COUNT; i++)
-        if (d->transports[i])
+        if (d->transports[i] && d->transports[i]->state != PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED)
             return true;
 
     return false;
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 33b2afa..052200a 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -1888,7 +1888,7 @@ static int setup_transport(struct userdata *u) {
 
     /* check if profile has a transport */
     t = u->device->transports[u->profile];
-    if (t == NULL) {
+    if (!t || t->state == PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED) {
         pa_log_warn("Profile has no transport");
         return -1;
     }
-- 
1.8.1



More information about the pulseaudio-discuss mailing list