public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ bluez v3] shared/bap: Add stream state check in stream_disable
@ 2025-07-02  1:15 Yang Li via B4 Relay
  2025-07-02  3:54 ` [BlueZ,bluez,v3] " bluez.test.bot
  2025-07-02 13:01 ` [PATCH BlueZ bluez v3] " Luiz Augusto von Dentz
  0 siblings, 2 replies; 6+ messages in thread
From: Yang Li via B4 Relay @ 2025-07-02  1:15 UTC (permalink / raw)
  To: Linux Bluetooth; +Cc: Yang Li

From: Yang Li <yang.li@amlogic.com>

Add a state check so that stream_disable() is a no-op when the stream
is not in ENABLING or STREAMING state. This prevents unexpected state
transitions or redundant operations during cleanup.

Signed-off-by: Yang Li <yang.li@amlogic.com>
---
Changes in v3:
- Optimizing the code
- Link to v2: https://patch.msgid.link/20250630-bap_for_big_sync_lost-v2-0-1491b608cda5@amlogic.com

bap for big sync lost

To: Linux Bluetooth <linux-bluetooth@vger.kernel.org>
Signed-off-by: Yang Li <yang.li@amlogic.com>

Changes in v2:
- Add state check in stream_disable.
- Add type check in stream_io_disconnected.
- Link to v1: https://patch.msgid.link/20250624-bap_for_big_sync_lost-v1-1-0df90a0f55d0@amlogic.com
---
 src/shared/bap.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/shared/bap.c b/src/shared/bap.c
index 40e1c974b..1790b277b 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -2131,14 +2131,20 @@ static uint8_t stream_disable(struct bt_bap_stream *stream, struct iovec *rsp)
 
 	ascs_ase_rsp_success(rsp, stream->ep->id);
 
-	/* Sink can autonomously transit to QOS while source needs to go to
-	 * Disabling until BT_ASCS_STOP is received.
-	 */
-	if (stream->ep->dir == BT_BAP_SINK)
-		stream_set_state(stream, BT_BAP_STREAM_STATE_QOS);
-
-	if (stream->ep->dir == BT_BAP_SOURCE)
-		stream_set_state(stream, BT_BAP_STREAM_STATE_DISABLING);
+	switch (stream->ep->state) {
+		case BT_ASCS_ASE_STATE_ENABLING:
+		case BT_ASCS_ASE_STATE_STREAMING:
+			if (stream->ep->dir == BT_BAP_SINK)
+				stream_set_state(stream, BT_BAP_STREAM_STATE_QOS);
+			else if (stream->ep->dir == BT_BAP_SOURCE)
+				/* Sink can autonomously transit to QOS while source needs to go to
+				* Disabling until BT_ASCS_STOP is received.
+				*/
+				stream_set_state(stream, BT_BAP_STREAM_STATE_DISABLING);
+			break;
+		default:
+			break;
+	}
 
 	return 0;
 }

---
base-commit: 55a6763cde8a2309fd23a96479ee4cf2fc23a442
change-id: 20250624-bap_for_big_sync_lost-63476c679dbb

Best regards,
-- 
Yang Li <yang.li@amlogic.com>



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

end of thread, other threads:[~2025-07-04  1:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-02  1:15 [PATCH BlueZ bluez v3] shared/bap: Add stream state check in stream_disable Yang Li via B4 Relay
2025-07-02  3:54 ` [BlueZ,bluez,v3] " bluez.test.bot
2025-07-02 13:01 ` [PATCH BlueZ bluez v3] " Luiz Augusto von Dentz
2025-07-03  8:40   ` Yang Li
2025-07-03 13:17     ` Luiz Augusto von Dentz
2025-07-04  1:16       ` Yang Li

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