bap: Remove interface
Subsystems (2)
cover bap: Remove interface
This patch removes the BAP plugin interface and moves the required APIs and data structures inside shared/bap, to avoid making calls between plugins.
Iulia Tanasescu (6):
shared/bap: Make bap_get_session public
bap: Remove bap_get_session
bap: Move default qos to shared/bap shared/bap: Add APIs to convert iso_qos to bap_qos
bap: Remove interface
bass: Free stream path
Makefile.plugins | 2 +- profiles/audio/bap.c | 107 +----------------------------------------- profiles/audio/bap.h | 17 ------- profiles/audio/bass.c | 16 +++---- src/shared/bap.c | 99 ++++++++++++++++++++++++++++++++++++-- src/shared/bap.h | 9 ++++ 6 files changed, 115 insertions(+), 135 deletions(-) delete mode 100644 profiles/audio/bap.h
Signature · 1 line
2.43.0
PATCH 1/6 shared/bap: Make bap_get_session public
This makes bap_get_session public, so that a reference to the bap session can be obtained and processed from the BASS plugin, for the Broadcast Assistant implementation.
In case a session is not found, this commit also adds a NULL check for the new bap that is created, in case the provided db reference is NULL and therefore a session fails to be added, to avoid any invalid memory access.
--- src/shared/bap.c | 9 ++++++--- src/shared/bap.h | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-)
src/shared/bap.c +6 -3
@@ -662,7 +662,7 @@ static void bap_disconnected(int err, void *user_data)bt_bap_detach (bap); } -static struct bt_bap *bap_get_session (struct bt_att *att,struct gatt_db *db) +struct bt_bap *bt_bap_get_session (struct bt_att *att,struct gatt_db *db) {const struct queue_entry *entry;struct bt_bap *bap;
@@ -675,6 +675,9 @@ static struct bt_bap *bap_get_session(struct bt_att *att, struct gatt_db *db) } bap =bt_bap_new (db,NULL ); +if (!bap) +return NULL ; + bap->att = att;bt_bap_attach (bap,NULL );
@@ -845,7 +848,7 @@ static void ascs_ase_read(struct gatt_db_attribute *attrib,struct bt_ascs_ase_status rsp;if (ase) - bap =bap_get_session (att, ase->ascs->bdb->db); + bap =bt_bap_get_session (att, ase->ascs->bdb->db);if (bap) ep =bap_get_endpoint (bap->local_eps, bap->ldb, attrib);
@@ -3437,7 +3440,7 @@ static void ascs_ase_cp_write(struct gatt_db_attribute *attrib, void *user_data) {struct bt_ascs *ascs = user_data; -struct bt_bap *bap =bap_get_session (att, ascs->bdb->db); +struct bt_bap *bap =bt_bap_get_session (att, ascs->bdb->db);struct iovec iov = { .iov_base = (void *) value, .iov_len = len,
src/shared/bap.h +2 -0
@@ -296,3 +296,5 @@ unsigned int bt_bap_bcode_cb_register(struct bt_bap *bap, bt_bap_destroy_func_t destroy);bool bt_bap_bcode_cb_unregister (struct bt_bap *bap,unsigned int id); + +struct bt_bap *bt_bap_get_session (struct bt_att *att,struct gatt_db *db);
Signature · 1 line
2.43.0
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=941567
---Test result---
Test Summary:
CheckPatch PENDING 0.20 seconds GitLint PENDING 0.19 seconds BuildEll PASS 20.40 seconds BluezMake PASS 1495.76 seconds MakeCheck PASS 13.39 seconds MakeDistcheck PASS 158.10 seconds CheckValgrind PASS 214.09 seconds CheckSmatch WARNING 284.59 seconds bluezmakeextell PASS 98.07 seconds IncrementalBuild PENDING 0.28 seconds ScanBuild PASS 864.70 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:src/shared/bap.c:313:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:313:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:313:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:313:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:313:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:313:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:313:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:313:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:313:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structures
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
PATCH 2/6 bap: Remove bap_get_session
In reply to Iulia TanasescuThis removes the bap_get_session API from the BAP plugin interface and replaces the call inside BASS with the shared/bap API.
--- profiles/audio/bap.c | 11 ----------- profiles/audio/bap.h | 2 -- profiles/audio/bass.c | 2 +- 3 files changed, 1 insertion(+), 14 deletions(-)
profiles/audio/bap.c +0 -11
@@ -2708,17 +2708,6 @@ static bool match_device(const void *data, const void *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;
profiles/audio/bap.h +0 -2
@@ -9,8 +9,6 @@extern struct bt_iso_qos bap_sink_pa_qos; -struct bt_bap *bap_get_session (struct btd_device *device); -void bap_iso_qos_to_bap_qos (struct bt_iso_qos *iso_qos,struct bt_bap_qos *bap_qos); void bap_qos_to_iso_qos(struct bt_bap_qos *bap_qos,
profiles/audio/bass.c +1 -1
@@ -1113,7 +1113,7 @@ static void bis_probe(uint8_t bis, uint8_t sgrp, struct iovec *caps,/* Only client sessions must be handled */ continue ; - bap =bap_get_session (data->device); + bap =bt_bap_get_session (bt_bass_get_att (data->bass),NULL );if (!bap)continue ;
Signature · 1 line
2.43.0
PATCH 3/6 bap: Move default qos to shared/bap
In reply to Iulia TanasescuThis moves the default BAP QoS structure to shared/bap, to be accessible from other plugins without involving the BAP plugin.
--- profiles/audio/bap.c | 39 --------------------------------------- profiles/audio/bap.h | 2 -- src/shared/bap.c | 39 +++++++++++++++++++++++++++++++++++++++ src/shared/bap.h | 2 ++ 4 files changed, 41 insertions(+), 41 deletions(-)
profiles/audio/bap.c +0 -39
@@ -115,45 +115,6 @@ struct bap_data {static struct queue *sessions; -/* Structure holding the parameters for Periodic Advertisement create sync. -* The full QOS is populated at the time the user selects and endpoint and -* configures it using SetConfiguration. -*/ -struct bt_iso_qos bap_sink_pa_qos = { - .bcast = { - .options =0x00 , - .skip =0x0000 , - .sync_timeout =BT_ISO_SYNC_TIMEOUT , - .sync_cte_type =0x00 , -/* TODO: The following parameters are not needed for PA Sync. -* They will be removed when the kernel checks will be removed. -*/ - .big =BT_ISO_QOS_BIG_UNSET , - .bis =BT_ISO_QOS_BIS_UNSET , - .encryption =0x00 , - .bcode = {0x00 }, - .mse =0x00 , - .timeout =BT_ISO_SYNC_TIMEOUT , - .sync_factor =0x07 , - .packing =0x00 , - .framing =0x00 , - .in = { - .interval =10000 , - .latency =10 , - .sdu =40 , - .phy =0x02 , - .rtn =2 , - }, - .out = { - .interval =10000 , - .latency =10 , - .sdu =40 , - .phy =0x02 , - .rtn =2 , - } - } -}; -static bool bap_data_set_user_data (struct bap_data *data,void *user_data) {if (!data)
profiles/audio/bap.h +0 -2
@@ -7,8 +7,6 @@* */ -extern struct bt_iso_qos bap_sink_pa_qos; -void bap_iso_qos_to_bap_qos (struct bt_iso_qos *iso_qos,struct bt_bap_qos *bap_qos); void bap_qos_to_iso_qos(struct bt_bap_qos *bap_qos,
src/shared/bap.c +39 -0
@@ -349,6 +349,45 @@ static struct queue *bap_db;static struct queue *bap_cbs;static struct queue *sessions; +/* Structure holding the parameters for Periodic Advertisement create sync. +* The full QOS is populated at the time the user selects and endpoint and +* configures it using SetConfiguration. +*/ +struct bt_iso_qos bap_sink_pa_qos = { + .bcast = { + .options =0x00 , + .skip =0x0000 , + .sync_timeout =BT_ISO_SYNC_TIMEOUT , + .sync_cte_type =0x00 , +/* TODO: The following parameters are not needed for PA Sync. +* They will be removed when the kernel checks will be removed. +*/ + .big =BT_ISO_QOS_BIG_UNSET , + .bis =BT_ISO_QOS_BIS_UNSET , + .encryption =0x00 , + .bcode = {0x00 }, + .mse =0x00 , + .timeout =BT_ISO_SYNC_TIMEOUT , + .sync_factor =0x07 , + .packing =0x00 , + .framing =0x00 , + .in = { + .interval =10000 , + .latency =10 , + .sdu =40 , + .phy =0x02 , + .rtn =2 , + }, + .out = { + .interval =10000 , + .latency =10 , + .sdu =40 , + .phy =0x02 , + .rtn =2 , + } + } +}; +static void bap_stream_set_io (void *data,void *user_data);static void stream_find_io (void *data,void *user_data);static void bap_stream_get_dir (void *data,void *user_data);
src/shared/bap.h +2 -0
@@ -50,6 +50,8 @@ typedef void (*bt_bap_bcode_func_t)(struct bt_bap_stream *stream, bt_bap_bcode_reply_t reply, void *reply_data, void *user_data); +extern struct bt_iso_qos bap_sink_pa_qos; +/* Local PAC related functions */ struct bt_bap_pac_qos {uint8_t framing;
Signature · 1 line
2.43.0
PATCH 4/6 shared/bap: Add APIs to convert iso_qos to bap_qos
In reply to Iulia TanasescuThis adds APIs to convert iso_qos to bap_qos and reversed.
--- src/shared/bap.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ src/shared/bap.h | 5 +++++ 2 files changed, 56 insertions(+)
src/shared/bap.c +51 -0
@@ -7505,3 +7505,54 @@ bool bt_bap_bcode_cb_unregister(struct bt_bap *bap, unsigned int id)return false; } + +void bt_bap_iso_qos_to_bap_qos (struct bt_iso_qos *iso_qos, +struct bt_bap_qos *bap_qos) +{ + bap_qos->bcast.big = iso_qos->bcast.big; + bap_qos->bcast.bis = iso_qos->bcast.bis; + bap_qos->bcast.sync_factor = iso_qos->bcast.sync_factor; + bap_qos->bcast.packing = iso_qos->bcast.packing; + bap_qos->bcast.framing = iso_qos->bcast.framing; + bap_qos->bcast.encryption = iso_qos->bcast.encryption; +if (bap_qos->bcast.encryption) + bap_qos->bcast.bcode =util_iov_new (iso_qos->bcast.bcode, +sizeof (iso_qos->bcast.bcode)); + bap_qos->bcast.options = iso_qos->bcast.options; + bap_qos->bcast.skip = iso_qos->bcast.skip; + bap_qos->bcast.sync_timeout = iso_qos->bcast.sync_timeout; + bap_qos->bcast.sync_cte_type = + iso_qos->bcast.sync_cte_type; + bap_qos->bcast.mse = iso_qos->bcast.mse; + bap_qos->bcast.timeout = iso_qos->bcast.timeout; + bap_qos->bcast.io_qos.interval = + iso_qos->bcast.in.interval; + bap_qos->bcast.io_qos.latency = iso_qos->bcast.in.latency; + bap_qos->bcast.io_qos.phy = iso_qos->bcast.in.phy; + bap_qos->bcast.io_qos.rtn = iso_qos->bcast.in.rtn; + bap_qos->bcast.io_qos.sdu = iso_qos->bcast.in.sdu; +} + +void bt_bap_qos_to_iso_qos (struct bt_bap_qos *bap_qos, +struct bt_iso_qos *iso_qos) +{ +memset (iso_qos,0 ,sizeof (*iso_qos)); + + iso_qos->bcast.big = bap_qos->bcast.big; + iso_qos->bcast.bis = bap_qos->bcast.bis; + iso_qos->bcast.sync_factor = bap_qos->bcast.sync_factor; + iso_qos->bcast.packing = bap_qos->bcast.packing; + iso_qos->bcast.framing = bap_qos->bcast.framing; + iso_qos->bcast.encryption = bap_qos->bcast.encryption; +if (bap_qos->bcast.bcode && bap_qos->bcast.bcode->iov_base) +memcpy (iso_qos->bcast.bcode, bap_qos->bcast.bcode->iov_base, + bap_qos->bcast.bcode->iov_len); + iso_qos->bcast.options = bap_qos->bcast.options; + iso_qos->bcast.skip = bap_qos->bcast.skip; + iso_qos->bcast.sync_timeout = bap_qos->bcast.sync_timeout; + iso_qos->bcast.sync_cte_type = bap_qos->bcast.sync_cte_type; + iso_qos->bcast.mse = bap_qos->bcast.mse; + iso_qos->bcast.timeout = bap_qos->bcast.timeout; +memcpy (&iso_qos->bcast.out, &bap_qos->bcast.io_qos, +sizeof (struct bt_iso_io_qos )); +}
src/shared/bap.h +5 -0
@@ -300,3 +300,8 @@ unsigned int bt_bap_bcode_cb_register(struct bt_bap *bap,bool bt_bap_bcode_cb_unregister (struct bt_bap *bap,unsigned int id);struct bt_bap *bt_bap_get_session (struct bt_att *att,struct gatt_db *db); + +void bt_bap_iso_qos_to_bap_qos (struct bt_iso_qos *iso_qos, +struct bt_bap_qos *bap_qos); +void bt_bap_qos_to_iso_qos (struct bt_bap_qos *bap_qos, +struct bt_iso_qos *iso_qos);
Signature · 1 line
2.43.0
PATCH 5/6 bap: Remove interface
In reply to Iulia TanasescuThis removes the BAP plugin interface and updates the BAP and BASS plugins to use shared/bap APIs.
--- Makefile.plugins | 2 +- profiles/audio/bap.c | 57 ++----------------------------------------- profiles/audio/bap.h | 13 ---------- profiles/audio/bass.c | 6 ++--- 4 files changed, 5 insertions(+), 73 deletions(-) delete mode 100644 profiles/audio/bap.h
Makefile.plugins +1 -1
@@ -113,7 +113,7 @@ endif if BAP builtin_modules += bap -builtin_sources += profiles/audio/bap.h profiles/audio/bap.c +builtin_sources += profiles/audio/bap.c endif if BASS
profiles/audio/bap.c +2 -55
81 lines not on this page · raw message
profiles/audio/bap.h deleted +0 -13
@@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* -* -* BlueZ - Bluetooth protocol stack for Linux -* -* Copyright 2024 NXP -* -*/ - -void bap_iso_qos_to_bap_qos (struct bt_iso_qos *iso_qos, -struct bt_bap_qos *bap_qos); -void bap_qos_to_iso_qos (struct bt_bap_qos *bap_qos, -struct bt_iso_qos *iso_qos);
profiles/audio/bass.c +2 -4
@@ -52,8 +52,6 @@#include "src/log.h" #include "src/error.h" -#include "bap.h" -#define BASS_UUID_STR "0000184f-0000-1000-8000-00805f9b34fb"#define BCAAS_UUID_STR "00001852-0000-1000-8000-00805f9b34fb"
@@ -370,7 +368,7 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state,queue_foreach (links, append_stream, &iso_bc_addr); -bap_qos_to_iso_qos (bap_qos, &qos); +bt_bap_qos_to_iso_qos (bap_qos, &qos); if (!bt_io_set(dg->io, &gerr, BT_IO_OPT_QOS, &qos,
@@ -532,7 +530,7 @@ static gboolean big_info_cb(GIOChannel *io, GIOCondition cond, iov.iov_len = base.base_len;/* Create BAP QoS structure */ -bap_iso_qos_to_bap_qos (&qos, &bap_qos); +bt_bap_iso_qos_to_bap_qos (&qos, &bap_qos);bt_bap_parse_base (&iov, &bap_qos, bass_debug, bis_handler, dg);
Signature · 1 line
2.43.0
PATCH 6/6 bass: Free stream path
In reply to Iulia TanasescuThis frees BASS setup paths, to avoid memory leaks like below:
==5877==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 43 byte(s) in 1 object(s) allocated from:
0x7ab1adefd9c7 in malloc ../../../../src/libsanitizer/asan/
asan_malloc_linux.cpp:69
0x7ab1ad08f937 in __vasprintf_internal libio/vasprintf.c:116
0x7ab1ad135d62 in ___asprintf_chk debug/asprintf_chk.c:34
0x5c2197401338 in asprintf /usr/include/x86_64-linux-gnu/bits/
stdio2.h:137
0x5c2197401338 in setup_configure_stream profiles/audio/bass.c:420
---
profiles/audio/bass.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)profiles/audio/bass.c +4 -4
@@ -116,6 +116,7 @@ struct bass_delegator {struct bass_setup {struct bass_delegator *dg; +char *path;struct bt_bap_stream *stream;uint8_t bis;struct bt_bap_qos qos;
@@ -411,19 +412,17 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state,static void setup_configure_stream (struct bass_setup *setup) { -char *path; - setup->stream =bt_bap_stream_new (setup->dg->bap, setup->lpac,NULL , &setup->qos, setup->config);if (!setup->stream)return ; -if (asprintf (&path,"%s/bis%d" , +if (asprintf (&setup->path,"%s/bis%d" ,device_get_path (setup->dg->device), setup->bis) <0 )return ; -bt_bap_stream_set_user_data (setup->stream, path); +bt_bap_stream_set_user_data (setup->stream, setup->path);bt_bap_stream_config (setup->stream, &setup->qos, setup->config,NULL ,NULL );
@@ -649,6 +648,7 @@ static void setup_free(void *data)util_iov_free (setup->qos.bcast.bcode,1 );util_iov_free (setup->meta,1 );util_iov_free (setup->config,1 ); +free (setup->path);/* Clear bis index from the bis sync bitmask, if it * has been previously set.
Signature · 1 line
2.43.0
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 12 lines · On Fri, 7 Mar 2025 17:44:51 +0200 you wrote:
This patch removes the BAP plugin interface and moves the required APIs and data structures inside shared/bap, to avoid making calls between plugins.
Iulia Tanasescu (6):
shared/bap: Makebap_get_sessionpublic
bap: Removebap_get_session
bap: Move default qos to shared/bap shared/bap: Add APIs to convertiso_qostobap_qos
bap: Remove interface
bass: Free stream path
Quoted 1 line
[...]
Here is the summary with links:
- [BlueZ,1/6] shared/bap: Make bap_get_session public
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=8f280aadbbae - [BlueZ,2/6] bap: Remove bap_get_session https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=fd622a5bb2e3 - [BlueZ,3/6] bap: Move default qos to shared/bap https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=5204f17cb9d3 - [BlueZ,4/6] shared/bap: Add APIs to convert iso_qos to bap_qos https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=6a03579d170e - [BlueZ,5/6] bap: Remove interface https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=8850bad1e027 - [BlueZ,6/6] bass: Free stream path https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=debc77530f24
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html