diff mbox series

[BlueZ] shared/bap: Fix attempting to disable stream when it is idle

Message ID 20220912214257.173804-1-luiz.dentz@gmail.com
State New
Headers show
Series [BlueZ] shared/bap: Fix attempting to disable stream when it is idle | expand

Commit Message

Luiz Augusto von Dentz Sept. 12, 2022, 9:42 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

If the stream is already in idle state do not attempt to disable it
again.
---
 src/shared/bap.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/src/shared/bap.c b/src/shared/bap.c
index c5f1134d8d8a..7b23a33474bd 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -1050,13 +1050,15 @@  static void bap_stream_free(void *data)
 	free(stream);
 }
 
-static void bap_ep_detach(struct bt_bap_endpoint *ep)
+static void bap_stream_detach(struct bt_bap_stream *stream)
 {
-	struct bt_bap_stream *stream = ep->stream;
+	struct bt_bap_endpoint *ep = stream->ep;
 
-	if (!stream)
+	if (!ep)
 		return;
 
+	DBG(stream->bap, "stream %p ep %p", stream, ep);
+
 	queue_remove(stream->bap->streams, stream);
 	bap_stream_clear_cfm(stream);
 
@@ -1281,7 +1283,7 @@  static void bap_stream_state_changed(struct bt_bap_stream *stream)
 	/* Post notification updates */
 	switch (stream->ep->state) {
 	case BT_ASCS_ASE_STATE_IDLE:
-		bap_ep_detach(stream->ep);
+		bap_stream_detach(stream);
 		break;
 	case BT_ASCS_ASE_STATE_QOS:
 		break;
@@ -1838,7 +1840,8 @@  static uint8_t stream_disable(struct bt_bap_stream *stream, struct iovec *rsp)
 {
 	DBG(stream->bap, "stream %p", stream);
 
-	if (!stream || stream->ep->state == BT_BAP_STREAM_STATE_QOS)
+	if (!stream || stream->ep->state == BT_BAP_STREAM_STATE_QOS ||
+			stream->ep->state == BT_BAP_STREAM_STATE_IDLE)
 		return 0;
 
 	ascs_ase_rsp_success(rsp, stream->ep->id);