From 8a304f7fd9607850052fc6ac9c13c63c9d36205a Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Mon, 11 Aug 2025 21:48:52 +0300 Subject: [PATCH] shared/bap: reset local ep state on stream detach When removing streams in bt_bap_detach(), they are detached directly without going through normal state transitions. As BAP Unicast Server, this leaves local endpoints to the state they were in, so they persist if client connects again. This is not wanted. For server streams, clear the local ASE state on detach. At that point, the ASE is either already idle or the session is detached. Don't modify state of remote endpoints (BAP Client streams), as only remote server should do that. --- src/shared/bap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/shared/bap.c b/src/shared/bap.c index c0f0c4f3c..9b7395223 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -1357,6 +1357,12 @@ static void bap_ucast_detach(struct bt_bap_stream *stream) bap_stream_clear_cfm(stream); ep->stream = NULL; + + if (!stream->client) { + ep->state = BT_ASCS_ASE_STATE_IDLE; + ep->old_state = BT_ASCS_ASE_STATE_IDLE; + } + bt_bap_stream_unref(stream); } -- 2.47.3