public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1] shared/bap: Fix not starting released operation
@ 2025-02-28 17:13 Luiz Augusto von Dentz
  2025-02-28 18:32 ` [BlueZ,v1] " bluez.test.bot
  2025-02-28 20:40 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2025-02-28 17:13 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

The release operation is intended to release CIS resources:

  'Releases resources associated with an ASE, immediately decouples the
  ASE from any previously coupled CIS, and tears down any CIS previously
  established for the ASE for one or more ASEs.

  Valid only if ASE_State field value = 0x01 (Codec Configured),
  0x02 (QoS Configured), 0x03 (Enabling), 0x04 (Streaming), or 0x05
  (Disabling).'

But as the stated in ASCS specification release can also be used with
the likes of Codec/QoS Configured which may not require the CIS to be
established and in that case released operation shall start
autonomously:

  'The Released operation shall be initiated autonomously by the server
  if:
  The Release operation for an ASE has been completed and the server
  controller has indicated that the underlying CIS for the ASE has been
  torn down.'
---
 src/shared/bap.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/shared/bap.c b/src/shared/bap.c
index 8b860ce8b984..f7e42fc15a81 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -2099,7 +2099,24 @@ static uint8_t stream_release(struct bt_bap_stream *stream, struct iovec *rsp)
 
 	ascs_ase_rsp_success(rsp, stream->ep->id);
 
-	stream_set_state(stream, BT_BAP_STREAM_STATE_RELEASING);
+	/* In case the stream IO is already down the released transition needs
+	 * to take action immeditely.
+	 */
+	if (!stream->io) {
+		switch (bt_bap_stream_get_state(stream)) {
+		case BT_BAP_STREAM_STATE_CONFIG:
+			/* Released (no caching) */
+			stream_set_state(stream, BT_BAP_STREAM_STATE_RELEASING);
+			stream_set_state(stream, BT_BAP_STREAM_STATE_IDLE);
+			break;
+		default:
+			/* Released (caching) */
+			stream_set_state(stream, BT_BAP_STREAM_STATE_RELEASING);
+			stream_set_state(stream, BT_BAP_STREAM_STATE_CONFIG);
+			break;
+		}
+	} else
+		stream_set_state(stream, BT_BAP_STREAM_STATE_RELEASING);
 
 	return 0;
 }
-- 
2.48.1


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

end of thread, other threads:[~2025-02-28 20:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-28 17:13 [PATCH BlueZ v1] shared/bap: Fix not starting released operation Luiz Augusto von Dentz
2025-02-28 18:32 ` [BlueZ,v1] " bluez.test.bot
2025-02-28 20:40 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth

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