diff mbox series

[BlueZ,2/2] shared/bap: Fix not sending ASE Receiver Stop Ready

Message ID 20230511000155.3721222-2-luiz.dentz@gmail.com (mailing list archive)
State Accepted
Commit 24b4ba1a393618b0c6b3b33f6eaa1371bfe97a6f
Headers show
Series [BlueZ,1/2] client/player: Fix crashes accessing metadata | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Luiz Augusto von Dentz May 11, 2023, 12:01 a.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This fixes not sending ASE Receiver Stop Ready if stream is on disabling
state when CIS is disconnected.

Fixes: https://github.com/bluez/bluez/issues/516
---
 src/shared/bap.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/src/shared/bap.c b/src/shared/bap.c
index 6131c312865a..f194f466fde1 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -1115,6 +1115,18 @@  static bool match_stream_io(const void *data, const void *user_data)
 	return stream->io == io;
 }
 
+static void stream_stop_disabling(void *data, void *user_data)
+{
+	struct bt_bap_stream *stream = data;
+
+	if (stream->io || stream->ep->state != BT_ASCS_ASE_STATE_DISABLING)
+		return;
+
+	DBG(stream->bap, "stream %p", stream);
+
+	bt_bap_stream_stop(stream, NULL, NULL);
+}
+
 static bool bap_stream_io_detach(struct bt_bap_stream *stream)
 {
 	struct bt_bap_stream *link;
@@ -1133,6 +1145,9 @@  static bool bap_stream_io_detach(struct bt_bap_stream *stream)
 		/* Detach link if in QoS state */
 		if (link->ep->state == BT_ASCS_ASE_STATE_QOS)
 			bap_stream_io_detach(link);
+	} else {
+		/* Links without IO on disabling state shall be stopped. */
+		queue_foreach(stream->links, stream_stop_disabling, NULL);
 	}
 
 	stream_io_unref(io);