public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 0/3] bass: Register bis probe/remove callbacks
@ 2025-02-25  8:44 Iulia Tanasescu
  2025-02-25  8:44 ` [PATCH BlueZ 1/3] shared/bap: Add support to register bis callbacks Iulia Tanasescu
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Iulia Tanasescu @ 2025-02-25  8:44 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: claudia.rosu, mihai-octavian.urzica, andrei.istodorescu,
	luiz.dentz, Iulia Tanasescu

This removes the bass_add_stream and bass_remove_stream APIs and
implements a method to register bis probe/remove callbacks with
shared/bap, to avoid making direct plugin calls between BAP and
BASS.

Iulia Tanasescu (3):
  shared/bap: Add support to register bis callbacks
  bass: Create BASS session with Broadcasters
  bass: Register bis probe/remove callbacks

 profiles/audio/bap.c  |  6 +--
 profiles/audio/bass.c | 62 +++++++++++++++++++++++++--
 profiles/audio/bass.h |  5 ---
 src/shared/bap.c      | 97 +++++++++++++++++++++++++++++++++++++++++++
 src/shared/bap.h      | 12 +++++-
 5 files changed, 169 insertions(+), 13 deletions(-)


base-commit: 4465c577778d812702d752dfd2812e25a2f69b31
-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH BlueZ v2 1/3] shared/bap: Add support to register bis callbacks
@ 2025-02-27 15:17 Iulia Tanasescu
  2025-02-27 16:31 ` bass: Register bis probe/remove callbacks bluez.test.bot
  0 siblings, 1 reply; 7+ messages in thread
From: Iulia Tanasescu @ 2025-02-27 15:17 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: claudia.rosu, mihai-octavian.urzica, andrei.istodorescu,
	luiz.dentz, Iulia Tanasescu

This adds support for registering BIS probe/remove calllbacks with
shared/bap. This is needed by the BAP Broadcast Assistant (BASS Client)
implementation, so that the BAP plugin can notify BISes discovered
after parsing the BASE to BASS, avoiding direct function calls
between plugins.
---
 src/shared/bap.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++
 src/shared/bap.h |  12 ++++-
 2 files changed, 124 insertions(+), 1 deletion(-)

diff --git a/src/shared/bap.c b/src/shared/bap.c
index 6ffeefa41..ede32af5c 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -80,6 +80,14 @@ struct bt_bap_state {
 	void *data;
 };
 
+struct bt_bap_bis_cb {
+	unsigned int id;
+	bt_bap_bis_func_t probe;
+	bt_bap_func_t remove;
+	bt_bap_destroy_func_t destroy;
+	void *data;
+};
+
 struct bt_bap_cb {
 	unsigned int id;
 	bt_bap_func_t attached;
@@ -180,6 +188,7 @@ struct bt_bap {
 	struct queue *pac_cbs;
 	struct queue *ready_cbs;
 	struct queue *state_cbs;
+	struct queue *bis_cbs;
 
 	bt_bap_debug_func_t debug_func;
 	bt_bap_destroy_func_t debug_destroy;
@@ -4190,6 +4199,16 @@ static void bap_state_free(void *data)
 	free(state);
 }
 
+static void bap_bis_cb_free(void *data)
+{
+	struct bt_bap_bis_cb *bis_cb = data;
+
+	if (bis_cb->destroy)
+		bis_cb->destroy(bis_cb->data);
+
+	free(bis_cb);
+}
+
 static void bap_ep_free(void *data)
 {
 	struct bt_bap_endpoint *ep = data;
@@ -4228,6 +4247,7 @@ static void bap_free(void *data)
 	queue_destroy(bap->pac_cbs, pac_changed_free);
 	queue_destroy(bap->ready_cbs, bap_ready_free);
 	queue_destroy(bap->state_cbs, bap_state_free);
+	queue_destroy(bap->bis_cbs, bap_bis_cb_free);
 	queue_destroy(bap->local_eps, free);
 	queue_destroy(bap->remote_eps, bap_ep_free);
 
@@ -4310,6 +4330,7 @@ struct bt_bap *bt_bap_new(struct gatt_db *ldb, struct gatt_db *rdb)
 	bap->ready_cbs = queue_new();
 	bap->streams = queue_new();
 	bap->state_cbs = queue_new();
+	bap->bis_cbs = queue_new();
 	bap->local_eps = queue_new();
 
 	if (!rdb)
@@ -5519,6 +5540,98 @@ bool bt_bap_state_unregister(struct bt_bap *bap, unsigned int id)
 	return false;
 }
 
+unsigned int bt_bap_bis_cb_register(struct bt_bap *bap,
+				bt_bap_bis_func_t probe,
+				bt_bap_func_t remove,
+				void *user_data,
+				bt_bap_destroy_func_t destroy)
+{
+	struct bt_bap_bis_cb *bis_cb;
+	static unsigned int id;
+
+	if (!bap)
+		return 0;
+
+	bis_cb = new0(struct bt_bap_bis_cb, 1);
+	bis_cb->id = ++id ? id : ++id;
+	bis_cb->probe = probe;
+	bis_cb->remove = remove;
+	bis_cb->destroy = destroy;
+	bis_cb->data = user_data;
+
+	queue_push_tail(bap->bis_cbs, bis_cb);
+
+	return bis_cb->id;
+}
+
+static bool match_bis_cb_id(const void *data, const void *match_data)
+{
+	const struct bt_bap_bis_cb *bis_cb = data;
+	unsigned int id = PTR_TO_UINT(match_data);
+
+	return (bis_cb->id == id);
+}
+
+bool bt_bap_bis_cb_unregister(struct bt_bap *bap, unsigned int id)
+{
+	struct bt_bap_bis_cb *bis_cb;
+
+	if (!bap)
+		return false;
+
+	bis_cb = queue_remove_if(bap->bis_cbs, match_bis_cb_id,
+						UINT_TO_PTR(id));
+	if (!bis_cb)
+		return false;
+
+	bap_bis_cb_free(bis_cb);
+
+	return false;
+}
+
+void bt_bap_bis_probe(struct bt_bap *bap, uint8_t bis, uint8_t sgrp,
+	struct iovec *caps, struct iovec *meta, struct bt_bap_qos *qos)
+{
+	const struct queue_entry *entry;
+
+	if (!bt_bap_ref_safe(bap))
+		return;
+
+	entry = queue_get_entries(bap->bis_cbs);
+
+	while (entry) {
+		struct bt_bap_bis_cb *cb = entry->data;
+
+		entry = entry->next;
+
+		if (cb->probe)
+			cb->probe(bis, sgrp, caps, meta, qos, cb->data);
+	}
+
+	bt_bap_unref(bap);
+}
+
+void bt_bap_bis_remove(struct bt_bap *bap)
+{
+	const struct queue_entry *entry;
+
+	if (!bt_bap_ref_safe(bap))
+		return;
+
+	entry = queue_get_entries(bap->bis_cbs);
+
+	while (entry) {
+		struct bt_bap_bis_cb *cb = entry->data;
+
+		entry = entry->next;
+
+		if (cb->remove)
+			cb->remove(bap, cb->data);
+	}
+
+	bt_bap_unref(bap);
+}
+
 const char *bt_bap_stream_statestr(uint8_t state)
 {
 	switch (state) {
diff --git a/src/shared/bap.h b/src/shared/bap.h
index 200dc8f13..adb531b4c 100644
--- a/src/shared/bap.h
+++ b/src/shared/bap.h
@@ -4,7 +4,7 @@
  *  BlueZ - Bluetooth protocol stack for Linux
  *
  *  Copyright (C) 2022  Intel Corporation. All rights reserved.
- *  Copyright 2023-2024 NXP
+ *  Copyright 2023-2025 NXP
  *
  */
 
@@ -269,3 +269,13 @@ bool bt_bap_parse_base(struct iovec *base,
 			bt_bap_bis_func_t handler,
 			void *user_data);
 
+unsigned int bt_bap_bis_cb_register(struct bt_bap *bap,
+				bt_bap_bis_func_t probe,
+				bt_bap_func_t remove,
+				void *user_data,
+				bt_bap_destroy_func_t destroy);
+bool bt_bap_bis_cb_unregister(struct bt_bap *bap, unsigned int id);
+
+void bt_bap_bis_probe(struct bt_bap *bap, uint8_t bis, uint8_t sgrp,
+	struct iovec *caps, struct iovec *meta, struct bt_bap_qos *qos);
+void bt_bap_bis_remove(struct bt_bap *bap);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-02-27 16:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-25  8:44 [PATCH BlueZ 0/3] bass: Register bis probe/remove callbacks Iulia Tanasescu
2025-02-25  8:44 ` [PATCH BlueZ 1/3] shared/bap: Add support to register bis callbacks Iulia Tanasescu
2025-02-25 10:12   ` bass: Register bis probe/remove callbacks bluez.test.bot
2025-02-25 15:05   ` [PATCH BlueZ 1/3] shared/bap: Add support to register bis callbacks Luiz Augusto von Dentz
2025-02-25  8:44 ` [PATCH BlueZ 2/3] bass: Create BASS session with Broadcasters Iulia Tanasescu
2025-02-25  8:44 ` [PATCH BlueZ 3/3] bass: Register bis probe/remove callbacks Iulia Tanasescu
  -- strict thread matches above, loose matches on Subject: below --
2025-02-27 15:17 [PATCH BlueZ v2 1/3] shared/bap: Add support to register bis callbacks Iulia Tanasescu
2025-02-27 16:31 ` bass: Register bis probe/remove callbacks bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox