diff mbox series

[BlueZ,3/7] bap: Create a new endpoint to be available for the next BIS configuration

Message ID 20240201152835.196617-4-silviu.barbulescu@nxp.com
State New
Headers show
Series Add support for multiple BISes on the bcast source | expand

Commit Message

Silviu Florian Barbulescu Feb. 1, 2024, 3:28 p.m. UTC
Add support to create a new endpoint to be available for the next
BIS configuration.
Broadcast source requires the creation of multiple endpoints, one
for each BIS for the multiple BISes scenario.

---
 profiles/audio/bap.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index 209f21471..9300e98ec 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -916,6 +916,10 @@  static void setup_free(void *data)
 	free(setup);
 }
 
+static struct bap_ep *ep_register_bcast(struct bap_data *data,
+					struct bt_bap_pac *lpac,
+					struct bt_bap_pac *rpac);
+
 static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg,
 								void *data)
 {
@@ -972,6 +976,10 @@  static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg,
 		else {
 			setup->base = bt_bap_stream_get_base(setup->stream);
 			setup->id = 0;
+			/* Create a new endpoint for a new BIS */
+			if (!ep_register_bcast(ep->data, ep->lpac, ep->rpac))
+				error("Unable to register endpoint for pac %p",
+						ep->lpac);
 		}
 
 		return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
@@ -1150,9 +1158,14 @@  static struct bap_ep *ep_register_bcast(struct bap_data *data,
 		return NULL;
 	}
 
-	ep = queue_find(queue, match_ep, &match);
-	if (ep)
-		return ep;
+	/* Broadcast source creates multiple endpoints (multiple BISes)
+	 * for one pac so queue_find will return always true.
+	 */
+	if (bt_bap_pac_get_type(lpac) == BT_BAP_BCAST_SINK) {
+		ep = queue_find(queue, match_ep, &match);
+		if (ep)
+			return ep;
+	}
 
 	ep = new0(struct bap_ep, 1);
 	ep->data = data;