diff mbox series

[BlueZ,5/7] shared/bap: Check the state of all the streams with the same BIG ID

Message ID 20240201152835.196617-6-silviu.barbulescu@nxp.com (mailing list archive)
State Superseded
Headers show
Series Add support for multiple BISes on the 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/IncrementalBuild success Incremental Build PASS

Commit Message

Silviu Florian Barbulescu Feb. 1, 2024, 3:28 p.m. UTC
Add a function to check the state of all the streams with the same BIG ID

---
 src/shared/bap.c | 26 ++++++++++++++++++++++++++
 src/shared/bap.h |  2 ++
 2 files changed, 28 insertions(+)
diff mbox series

Patch

diff --git a/src/shared/bap.c b/src/shared/bap.c
index a4c6a1bcd..244bd8c4e 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -5884,3 +5884,29 @@  struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream)
 
 	return base_iov;
 }
+
+/*
+ * Check the state of all streams with the same BIG ID.
+ * If all these streams are in the checked state, return true.
+ * Else, return false.
+ */
+bool bt_bap_test_bcast_streams_state(struct bt_bap_stream *stream,
+						uint8_t test_state)
+{
+	const struct queue_entry *entry;
+	struct bt_bap_stream *e_str;
+
+	for (entry = queue_get_entries(stream->bap->streams);
+				entry; entry = entry->next) {
+		e_str = entry->data;
+
+		if ((e_str == stream) ||
+			(e_str->qos.bcast.big != stream->qos.bcast.big))
+			continue;
+
+		if (e_str->ep->state != test_state)
+			return false;
+	}
+
+	return true;
+}
diff --git a/src/shared/bap.h b/src/shared/bap.h
index 2c3550921..9d46c5ad4 100644
--- a/src/shared/bap.h
+++ b/src/shared/bap.h
@@ -323,3 +323,5 @@  void bt_bap_update_bcast_source(struct bt_bap_pac *pac,
 bool bt_bap_pac_bcast_is_local(struct bt_bap *bap, struct bt_bap_pac *pac);
 
 struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream);
+bool bt_bap_test_bcast_streams_state(struct bt_bap_stream *stream,
+						uint8_t test_state);