Skip to contentSkip to conversation

audio: Fix stale AVDTP connecting state

PATCH Applied Kun Ma 3 participants 3 messages Sep 30 Bluetooth drivers

lore
Share & tools
lore

Kun Ma

author
#0 lore raw

PATCH 1/1 audio: Fix stale AVDTP connecting state

When a remote dual-role A2DP device reconnects autonomously, both sink and source services transition to their respective CONNECTING states upon AVDTP_SESSION_STATE_CONNECTING.

If the remote device only configures one direction (e.g. initiating a stream from remote Source to local Sink), the unused direction's state remains stuck in CONNECTING even after the underlying AVDTP session has reached AVDTP_SESSION_STATE_CONNECTED.

Subsequently, when policy or userspace attempts to initiate audio playback (e.g. via sink_connect() or source_connect()), the call fails immediately with -EBUSY due to this stale CONNECTING state.

Fix this by only returning -EBUSY if the underlying AVDTP session is actually still in AVDTP_SESSION_STATE_CONNECTING. In addition, check if a stream already exists on that service to prevent concurrent stream allocations while the session is connected.

---
 profiles/audio/sink.c   | 6 +++++-
 profiles/audio/source.c | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
profiles/audio/sink.c +5 -1
index 81d5a3a6b..3363f421f 100644
@@ -281,7 +281,11 @@ int sink_connect(struct btd_service *service)
 	if (sink->connect_id > 0 || sink->disconnect_id > 0)
 		return -EBUSY;
 
-	if (sink->state == SINK_STATE_CONNECTING)
+	if (sink->state == SINK_STATE_CONNECTING &&
+	    sink->session_state == AVDTP_SESSION_STATE_CONNECTING)
+		return -EBUSY;
+
+	if (sink->stream)
 		return -EBUSY;
 
 	if (sink->stream_state >= AVDTP_STATE_OPEN)
profiles/audio/source.c +5 -1
index 6be4de74e..54f9c4a4e 100644
@@ -282,7 +282,11 @@ int source_connect(struct btd_service *service)
 	if (source->connect_id > 0 || source->disconnect_id > 0)
 		return -EBUSY;
 
-	if (source->state == SOURCE_STATE_CONNECTING)
+	if (source->state == SOURCE_STATE_CONNECTING &&
+	    source->session_state == AVDTP_SESSION_STATE_CONNECTING)
+		return -EBUSY;
+
+	if (source->stream)
 		return -EBUSY;
 
 	if (source->stream_state >= AVDTP_STATE_OPEN)
Signature · 1 line
2.55.0
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1176758/

---Test result---

Test Summary:

CheckPatch                    PASS      0.33 seconds
GitLint                       PASS      0.24 seconds
BuildEll                      PASS      21.32 seconds
BluezMake                     PASS      396.35 seconds
MakeCheck                     PASS      3.27 seconds
MakeDistcheck                 PASS      148.40 seconds
CheckValgrind                 PASS      155.46 seconds
CheckSmatch                   PASS      297.88 seconds
bluezmakeextell               PASS      97.33 seconds
TestFunctional                PASS      1153.77 seconds
IncrementalBuild              PASS      394.45 seconds
ScanBuild                     PASS      1136.70 seconds

https://github.com/bluez/bluez/pull/2614

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Kun Ma
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 10 lines · On Wed, 30 Sep 2026 18:12:40 +0800 you wrote:

When a remote dual-role A2DP device reconnects autonomously, both sink and source services transition to their respective CONNECTING states upon AVDTP_SESSION_STATE_CONNECTING.

If the remote device only configures one direction (e.g. initiating a stream from remote Source to local Sink), the unused direction's state remains stuck in CONNECTING even after the underlying AVDTP session has reached AVDTP_SESSION_STATE_CONNECTED.

[...]

Here is the summary with links:
- [BlueZ] audio: Fix stale AVDTP connecting state

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=eda4262191ba

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html