[PATCH BlueZ 06/10] bap: Add API to get bt_bap matching device

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

 



This adds a public BAP API to obtain a reference to the bt_bap session
with a peer device.
---
 Makefile.plugins     |  2 +-
 profiles/audio/bap.c | 21 +++++++++++++++++++++
 profiles/audio/bap.h | 10 ++++++++++
 3 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100644 profiles/audio/bap.h

diff --git a/Makefile.plugins b/Makefile.plugins
index 44fda4536..9dd8134b4 100644
--- a/Makefile.plugins
+++ b/Makefile.plugins
@@ -115,7 +115,7 @@ endif
 
 if BAP
 builtin_modules += bap
-builtin_sources += profiles/audio/bap.c
+builtin_sources += profiles/audio/bap.h profiles/audio/bap.c
 endif
 
 if BASS
diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index 6d8289418..fe5390e6a 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -56,6 +56,8 @@
 #include "src/log.h"
 #include "src/error.h"
 
+#include "bap.h"
+
 #define ISO_SOCKET_UUID "6fbaf188-05e0-496a-9885-d6ddfdb4e03e"
 #define PACS_UUID_STR "00001850-0000-1000-8000-00805f9b34fb"
 #define BCAAS_UUID_STR "00001852-0000-1000-8000-00805f9b34fb"
@@ -2751,6 +2753,25 @@ static void pac_removed_broadcast(struct bt_bap_pac *pac, void *user_data)
 	ep_unregister(ep);
 }
 
+static bool match_device(const void *data, const void *match_data)
+{
+	const struct bap_data *bdata = data;
+	const struct btd_device *device = match_data;
+
+	return bdata->device == device;
+}
+
+struct bt_bap *bap_get_session(struct btd_device *device)
+{
+	struct bap_data *data;
+
+	data = queue_find(sessions, match_device, device);
+	if (!data)
+		return NULL;
+
+	return data->bap;
+}
+
 static struct bap_data *bap_data_new(struct btd_device *device)
 {
 	struct bap_data *data;
diff --git a/profiles/audio/bap.h b/profiles/audio/bap.h
new file mode 100644
index 000000000..66f8db887
--- /dev/null
+++ b/profiles/audio/bap.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright 2024 NXP
+ *
+ */
+
+struct bt_bap *bap_get_session(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