diff mbox series

[Bluez,v2,3/3] audio/avdtp: Report failure in disconnected state

Message ID 20201105142838.Bluez.v2.3.Ib69ea31cb69840b941b725a1d889473c5e6cac97@changeid
State New
Headers show
Series [Bluez,v2,1/3] policy: add checks before connecting | expand

Commit Message

Archie Pusaka Nov. 5, 2020, 6:29 a.m. UTC
From: Archie Pusaka <apusaka@chromium.org>

A2DP are relying on the disconnected state callback to do cleanup.
If failure occurs when AVDTP are already in the disconnected state,
we didn't make any transition state, therefore A2DP would miss this
event.

This patch allows the transition to disconnected state, even though
we are previously already in the disconnected state.

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
---

(no changes since v1)

 profiles/audio/avdtp.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index 4c39088b8f..16fa20bba7 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -2612,6 +2612,11 @@  static int send_req(struct avdtp *session, gboolean priority,
 	if (session->state == AVDTP_SESSION_STATE_DISCONNECTED) {
 		session->io = l2cap_connect(session);
 		if (!session->io) {
+			/* Report disconnection anyways, as the other layers
+			 * are using this state for cleanup.
+			 */
+			avdtp_set_state(session,
+					AVDTP_SESSION_STATE_DISCONNECTED);
 			err = -EIO;
 			goto failed;
 		}