[PATCH BlueZ v2 10/16] bass: Add APIs to probe/remove Broadcasters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This adds BASS APIs to probe/remove Broadcasters probed by BAP.

The BAP plugin might probe Broadcasters that were either scanned
autonomously, or that were added by a Broadcast Assistant through
BASS.

After performing long-lived PA sync with a Broadcaster added by a
Broadcast Assistant, the BAP plugin will call the BASS probe API,
to inform BASS that PA has been established with the Broadcast Source
and to provide a reference to the created bt_bap session. Once a
Broadcaster has been probed, BASS will update the PA sync state inside
the corresponding Broadcast Receive State characteristic and
the peer Broadcast Assistant will be notified about the update.

Once the BAP session with a Broadcaster is deleted, the BASS remove
API will be called, to inform BASS that the Source is no longer active.
The BASS plugin will update the PA sync field of the corresponding
Broadcast Receive State characteristic and it will notify the peer
Broadcast Assistant that PA sync is no longer established with the
Source.
---
 profiles/audio/bass.c | 51 +++++++++++++++++++++++++++++++++++++++++++
 profiles/audio/bass.h |  3 +++
 2 files changed, 54 insertions(+)

diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c
index ee378e141..933eecabd 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 5bef92946..7e20385e5 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);
-- 
2.39.2





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux