Diff between 06d20a80249b177ed2c3794c68334e1935eacaec and f3a43bd0e4af7a6b4265a6664b1bd70a2beaf29e

Changed Files

File Additions Deletions Status
profiles/audio/bass.c +51 -0 modified
profiles/audio/bass.h +3 -0 modified

Full Patch

diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c
index ee378e1..933eeca 100644
--- a/profiles/audio/bass.c
+++ b/profiles/audio/bass.c
@@ -102,6 +102,7 @@ struct bass_assistant {
 struct bass_delegator {
 	struct btd_device *device;	/* Broadcast source device */
 	struct bt_bcast_src *src;
+	struct bt_bap *bap;
 };
 
 static struct queue *sessions;
@@ -115,6 +116,56 @@ static void bass_debug(const char *str, void *user_data)
 	DBG_IDX(0xffff, "%s", str);
 }
 
+static bool delegator_match_device(const void *data, const void *match_data)
+{
+	const struct bass_delegator *dg = data;
+	const struct btd_device *device = match_data;
+
+	return dg->device == device;
+}
+
+bool bass_bcast_probe(struct btd_device *device, struct bt_bap *bap)
+{
+	struct bass_delegator *dg;
+
+	dg = queue_find(delegators, delegator_match_device, device);
+	if (!dg)
+		return false;
+
+	DBG("%p", dg);
+
+	dg->bap = bap;
+
+	/* Update Broadcast Receive State characteristic value and notify
+	 * peers.
+	 */
+	if (bt_bass_set_pa_sync(dg->src, BT_BASS_SYNCHRONIZED_TO_PA))
+		DBG("Failed to update Broadcast Receive State characteristic");
+
+	return true;
+}
+
+bool bass_bcast_remove(struct btd_device *device)
+{
+	struct bass_delegator *dg;
+
+	dg = queue_remove_if(delegators, delegator_match_device, device);
+	if (!dg)
+		return false;
+
+	DBG("%p", dg);
+
+	/* Update Broadcast Receive State characteristic value and notify
+	 * peers.
+	 */
+	if (bt_bass_set_pa_sync(dg->src, BT_BASS_NOT_SYNCHRONIZED_TO_PA))
+		DBG("Failed to update Broadcast Receive State characteristic");
+
+	free(dg);
+
+	return true;
+}
+
 static void assistant_set_state(struct bass_assistant *assistant,
 					enum assistant_state state)
 {
diff --git a/profiles/audio/bass.h b/profiles/audio/bass.h
index 5bef929..7e20385 100644
--- a/profiles/audio/bass.h
+++ b/profiles/audio/bass.h
@@ -11,3 +11,6 @@ void bass_add_stream(struct btd_device *device, struct iovec *meta,
 			struct iovec *caps, struct bt_iso_qos *qos,
 			uint8_t sgrp, uint8_t bis);
 void bass_remove_stream(struct btd_device *device);
+
+bool bass_bcast_probe(struct btd_device *device, struct bt_bap *bap);
+bool bass_bcast_remove(struct btd_device *device);