diff mbox series

[v2,1/3] shared/bap:Update stream enable/disable flow bcast src

Message ID 20231002153352.3163-2-iulia.tanasescu@nxp.com (mailing list archive)
State Accepted
Commit 7a79ff88fd9576cd9935a8c0bab4906b7c38ea03
Headers show
Series Update transport acquire/release flow BAP bcast source | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Iulia Tanasescu Oct. 2, 2023, 3:33 p.m. UTC
From: Silviu Florian Barbulescu <silviu.barbulescu@nxp.com>

Update stream enable/disable flow for BAP broadcast source

---
 src/shared/bap.c | 100 +++++++++++++++++++++++++++++++++--------------
 1 file changed, 70 insertions(+), 30 deletions(-)

Comments

bluez.test.bot@gmail.com Oct. 2, 2023, 5:42 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=789347

---Test result---

Test Summary:
CheckPatch                    PASS      1.46 seconds
GitLint                       PASS      0.89 seconds
BuildEll                      PASS      28.53 seconds
BluezMake                     PASS      885.38 seconds
MakeCheck                     PASS      12.39 seconds
MakeDistcheck                 PASS      162.32 seconds
CheckValgrind                 PASS      261.73 seconds
CheckSmatch                   PASS      352.83 seconds
bluezmakeextell               PASS      108.54 seconds
IncrementalBuild              PASS      2179.90 seconds
ScanBuild                     PASS      1078.14 seconds



---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/src/shared/bap.c b/src/shared/bap.c
index 9e9ea1472..925501c48 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -1331,6 +1331,11 @@  static void stream_set_state_broadcast(struct bt_bap_stream *stream,
 	ep->old_state = ep->state;
 	ep->state = state;
 
+	DBG(bap, "stream %p dir 0x%02x: %s -> %s", stream,
+			bt_bap_stream_get_dir(stream),
+			bt_bap_stream_statestr(stream->ep->old_state),
+			bt_bap_stream_statestr(stream->ep->state));
+
 	bt_bap_ref(bap);
 
 	for (entry = queue_get_entries(bap->state_cbs); entry;
@@ -1347,6 +1352,9 @@  static void stream_set_state_broadcast(struct bt_bap_stream *stream,
 	case BT_ASCS_ASE_STATE_IDLE:
 		bap_stream_detach(stream);
 		break;
+	case BT_ASCS_ASE_STATE_RELEASING:
+		bap_stream_io_detach(stream);
+		break;
 	}
 
 	bt_bap_unref(bap);
@@ -1492,7 +1500,12 @@  static void ep_config_cb(struct bt_bap_stream *stream, int err)
 		return;
 
 	if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_BCAST) {
-		stream_set_state_broadcast(stream, BT_BAP_STREAM_STATE_CONFIG);
+		if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SINK)
+			stream_set_state_broadcast(stream,
+						BT_BAP_STREAM_STATE_QOS);
+		else if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE)
+			stream_set_state_broadcast(stream,
+						BT_BAP_STREAM_STATE_CONFIG);
 		return;
 	}
 
@@ -4914,8 +4927,13 @@  unsigned int bt_bap_stream_enable(struct bt_bap_stream *stream,
 		queue_foreach(stream->links, bap_stream_enable_link, metadata);
 		break;
 	case BT_BAP_STREAM_TYPE_BCAST:
-		stream_set_state_broadcast(stream,
-					BT_BAP_STREAM_STATE_STREAMING);
+		if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SINK)
+			stream_set_state_broadcast(stream,
+						BT_BAP_STREAM_STATE_CONFIG);
+		else if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE)
+			stream_set_state_broadcast(stream,
+						BT_BAP_STREAM_STATE_STREAMING);
+
 		return 1;
 	}
 
@@ -4933,30 +4951,40 @@  unsigned int bt_bap_stream_start(struct bt_bap_stream *stream,
 	if (!bap_stream_valid(stream))
 		return 0;
 
-	if (!stream->client) {
+	switch (bt_bap_stream_get_type(stream)) {
+	case BT_BAP_STREAM_TYPE_UCAST:
+		if (!stream->client) {
+			if (stream->ep->dir == BT_BAP_SINK)
+				stream_start(stream, NULL);
+			return 0;
+		}
+
 		if (stream->ep->dir == BT_BAP_SINK)
-			stream_start(stream, NULL);
-		return 0;
-	}
+			return 0;
 
-	if (stream->ep->dir == BT_BAP_SINK)
-		return 0;
+		memset(&start, 0, sizeof(start));
 
-	memset(&start, 0, sizeof(start));
+		start.ase = stream->ep->id;
 
-	start.ase = stream->ep->id;
+		iov.iov_base = &start;
+		iov.iov_len = sizeof(start);
 
-	iov.iov_base = &start;
-	iov.iov_len = sizeof(start);
+		req = bap_req_new(stream, BT_ASCS_START,
+					&iov, 1, func, user_data);
 
-	req = bap_req_new(stream, BT_ASCS_START, &iov, 1, func, user_data);
+		if (!bap_queue_req(stream->bap, req)) {
+			bap_req_free(req);
+			return 0;
+		}
 
-	if (!bap_queue_req(stream->bap, req)) {
-		bap_req_free(req);
-		return 0;
+		return req->id;
+	case BT_BAP_STREAM_TYPE_BCAST:
+		stream_set_state_broadcast(stream,
+					BT_BAP_STREAM_STATE_STREAMING);
+		return 1;
 	}
 
-	return req->id;
+	return 0;
 }
 
 static void bap_stream_disable_link(void *data, void *user_data)
@@ -4996,24 +5024,36 @@  unsigned int bt_bap_stream_disable(struct bt_bap_stream *stream,
 		return 0;
 	}
 
-	memset(&disable, 0, sizeof(disable));
+	switch (bt_bap_stream_get_type(stream)) {
+	case BT_BAP_STREAM_TYPE_UCAST:
+		memset(&disable, 0, sizeof(disable));
 
-	disable.ase = stream->ep->id;
+		disable.ase = stream->ep->id;
 
-	iov.iov_base = &disable;
-	iov.iov_len = sizeof(disable);
+		iov.iov_base = &disable;
+		iov.iov_len = sizeof(disable);
 
-	req = bap_req_new(stream, BT_ASCS_DISABLE, &iov, 1, func, user_data);
+		req = bap_req_new(stream, BT_ASCS_DISABLE, &iov, 1, func,
+							user_data);
 
-	if (!bap_queue_req(stream->bap, req)) {
-		bap_req_free(req);
-		return 0;
-	}
+		if (!bap_queue_req(stream->bap, req)) {
+			bap_req_free(req);
+			return 0;
+		}
 
-	if (disable_links)
-		queue_foreach(stream->links, bap_stream_disable_link, NULL);
+		if (disable_links)
+			queue_foreach(stream->links, bap_stream_disable_link,
+							NULL);
 
-	return req->id;
+		return req->id;
+
+	case BT_BAP_STREAM_TYPE_BCAST:
+		stream_set_state_broadcast(stream,
+					BT_BAP_STREAM_STATE_RELEASING);
+		return 1;
+	}
+
+	return 0;
 }
 
 unsigned int bt_bap_stream_stop(struct bt_bap_stream *stream,