Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ] shared/bap: reset local ep states on bap session detach
@ 2025-08-10 18:18 Pauli Virtanen
  2025-08-10 19:57 ` [BlueZ] " bluez.test.bot
  2025-08-11 14:38 ` [PATCH BlueZ] " Luiz Augusto von Dentz
  0 siblings, 2 replies; 6+ messages in thread
From: Pauli Virtanen @ 2025-08-10 18:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

When detaching BAP session, the session is removed from the global list,
and streams do not go through normal state change cleanup, so local
endpoint states are not cleaned up. This causes problems as ASE may be
in busy state even though there is no stream.

Fix by resetting all ASE to IDLE state after detaching all streams.
---
 src/shared/bap.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/shared/bap.c b/src/shared/bap.c
index ed5c322b4..d4beb9818 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -5664,6 +5664,14 @@ static void stream_foreach_detach(void *data, void *user_data)
 	stream_set_state(stream, BT_BAP_STREAM_STATE_IDLE);
 }
 
+static void ep_foreach_detach(void *data, void *user_data)
+{
+	struct bt_bap_endpoint *ep = data;
+
+	ep->state = BT_ASCS_ASE_STATE_IDLE;
+	ep->old_state = BT_ASCS_ASE_STATE_IDLE;
+}
+
 static void bap_req_detach(void *data)
 {
 	struct bt_bap_req *req = data;
@@ -5696,6 +5704,7 @@ void bt_bap_detach(struct bt_bap *bap)
 	bap->att = NULL;
 
 	queue_foreach(bap->streams, stream_foreach_detach, bap);
+	queue_foreach(bap->local_eps, ep_foreach_detach, bap);
 	queue_foreach(bap_cbs, bap_detached, bap);
 }
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-08-11 17:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-10 18:18 [PATCH BlueZ] shared/bap: reset local ep states on bap session detach Pauli Virtanen
2025-08-10 19:57 ` [BlueZ] " bluez.test.bot
2025-08-11 14:38 ` [PATCH BlueZ] " Luiz Augusto von Dentz
2025-08-11 16:54   ` Pauli Virtanen
2025-08-11 17:05     ` Pauli Virtanen
2025-08-11 17:05     ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox