[PATCH BlueZ bluez v2 2/2] shared/bap: Add stream state check in stream_disable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Yang Li <yang.li@xxxxxxxxxxx>

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@xxxxxxxxxxx>
---
 src/shared/bap.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/shared/bap.c b/src/shared/bap.c
index 984ae782d..5445ddd14 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -2134,10 +2134,14 @@ static uint8_t stream_disable(struct bt_bap_stream *stream, struct iovec *rsp)
 	/* 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)
+	if (stream->ep->dir == BT_BAP_SINK &&
+	   (stream->ep->state == BT_ASCS_ASE_STATE_ENABLING ||
+	    stream->ep->state == BT_ASCS_ASE_STATE_STREAMING))
 		stream_set_state(stream, BT_BAP_STREAM_STATE_QOS);
 
-	if (stream->ep->dir == BT_BAP_SOURCE)
+	if (stream->ep->dir == BT_BAP_SOURCE &&
+	   (stream->ep->state == BT_ASCS_ASE_STATE_ENABLING ||
+	    stream->ep->state == BT_ASCS_ASE_STATE_STREAMING))
 		stream_set_state(stream, BT_BAP_STREAM_STATE_DISABLING);
 
 	return 0;

-- 
2.42.0






[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux