diff mbox series

[BlueZ,02/10] shared/bap: Update bt_bap_verify_bis to receive caps

Message ID 20240716142207.4298-3-iulia.tanasescu@nxp.com
State New
Headers show
Series Initial implementation of BAP Broadcast Assistant | expand

Commit Message

Iulia Tanasescu July 16, 2024, 2:21 p.m. UTC
This updates bt_bap_verify_bis to receive the already merged L2 and L3
capabilities, instead of computing it internally.
---
 profiles/audio/bap.c | 11 ++++++++---
 src/shared/bap.c     | 15 ++++-----------
 src/shared/bap.h     |  6 ++----
 unit/test-bap.c      |  7 ++++---
 4 files changed, 18 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index afa938091..2f37d33eb 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -1191,12 +1191,17 @@  static bool parse_base(struct bap_data *bap_data, struct bt_iso_base *base,
 					l3_caps->iov_len, NULL, print_ltv,
 					func);
 
+			merged_caps = bt_bap_merge_caps(l2_caps, l3_caps);
+			if (!merged_caps) {
+				free(path);
+				continue;
+			}
+
 			/* Check if this BIS matches any local PAC */
 			bt_bap_verify_bis(bap_data->bap, bis_index, &codec,
-					l2_caps, l3_caps, &matched_lpac,
-					&merged_caps);
+					merged_caps, &matched_lpac);
 
-			if (matched_lpac == NULL || merged_caps == NULL) {
+			if (matched_lpac == NULL) {
 				free(path);
 				continue;
 			}
diff --git a/src/shared/bap.c b/src/shared/bap.c
index 1259ee3c9..3381ffdd4 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -6639,29 +6639,22 @@  struct iovec *bt_bap_merge_caps(struct iovec *l2_caps, struct iovec *l3_caps)
 
 void bt_bap_verify_bis(struct bt_bap *bap, uint8_t bis_index,
 		struct bt_bap_codec *codec,
-		struct iovec *l2_caps,
-		struct iovec *l3_caps,
-		struct bt_bap_pac **lpac,
-		struct iovec **caps)
+		struct iovec *caps,
+		struct bt_bap_pac **lpac)
 {
-	struct iovec *merged_caps;
 	struct bt_ltv_match match_data;
 
-	merged_caps = bt_bap_merge_caps(l2_caps, l3_caps);
-	if (!merged_caps)
+	if (!caps)
 		return;
 
 	/* Check each BIS Codec Specific Configuration LTVs against our Codec
 	 * Specific Capabilities and if the BIS matches create a PAC with it
 	 */
-	match_data = bap_check_bis(bap->ldb, merged_caps);
+	match_data = bap_check_bis(bap->ldb, caps);
 	if (match_data.found == true) {
-		*caps = merged_caps;
 		*lpac = match_data.data;
 		DBG(bap, "Matching BIS %i", bis_index);
 	} else {
-		util_iov_free(merged_caps, 1);
-		*caps = NULL;
 		*lpac = NULL;
 	}
 
diff --git a/src/shared/bap.h b/src/shared/bap.h
index e63161dca..3e68f00e2 100644
--- a/src/shared/bap.h
+++ b/src/shared/bap.h
@@ -255,8 +255,6 @@  struct iovec *bt_bap_merge_caps(struct iovec *l2_caps, struct iovec *l3_caps);
 
 void bt_bap_verify_bis(struct bt_bap *bap, uint8_t bis_index,
 		struct bt_bap_codec *codec,
-		struct iovec *l2_caps,
-		struct iovec *l3_caps,
-		struct bt_bap_pac **lpac,
-		struct iovec **caps);
+		struct iovec *caps,
+		struct bt_bap_pac **lpac);
 
diff --git a/unit/test-bap.c b/unit/test-bap.c
index 9dd7a45e8..4b47d6363 100644
--- a/unit/test-bap.c
+++ b/unit/test-bap.c
@@ -587,12 +587,13 @@  static void bsnk_pac_added(struct bt_bap_pac *pac, void *user_data)
 		codec.id = LC3_ID;
 
 	for (uint8_t i = 0; i < data->cfg->streams; i++) {
-		bt_bap_verify_bis(data->bap, bis_idx++, &codec,
-				&data->cfg->cc, NULL, &lpac, &cc);
+		cc = bt_bap_merge_caps(&data->cfg->cc, NULL);
+		g_assert(cc);
+
+		bt_bap_verify_bis(data->bap, bis_idx++, &codec, cc, &lpac);
 
 		g_assert(lpac);
 		g_assert(pac == lpac);
-		g_assert(cc);
 
 		stream = bt_bap_stream_new(data->bap,
 			pac, NULL, &data->cfg->qos, cc);