bass: Rework Scan Delegator
v2 cover bass: Rework Scan Delegator
This patch reworks the Scan Delegator implementation in BASS, to manage BAP streams internally and leave BAP to just handle streams created by autonomous Broadcast Sink.
Thus, this also removes long-lived PA sync support from BAP and also the pa idle timer, since kernel support has been added to order PA/BIG sync requests.
Iulia Tanasescu (7):
shared/bap: Add helper to parse BASE
bap: Add helpers to convert iso_qos to/from bap_qos
bap: Rework BASE parsing
bap: Make default PA sync QoS public
bass: Rework Scan Delegator to handle BAP streams
bap: Remove API to probe device from BASS
bap: Remove PA idle timer logic
profiles/audio/bap.c | 687 +++++++++++------------------------------- profiles/audio/bap.h | 8 +- profiles/audio/bass.c | 362 ++++++++++++++++++---- profiles/audio/bass.h | 6 +- src/shared/bap.c | 125 ++++++++ src/shared/bap.h | 10 + 6 files changed, 626 insertions(+), 572 deletions(-)
base-commit: 5c65356cae64ddbc95210deb36ee66430645edf8
Signature · 1 line
2.43.0
PATCH v2 1/7 shared/bap: Add helper to parse BASE
This adds a shared/bap helper to parse BASE. Any plugin that wishes to parse a BASE structure can call this helper and provide a callback to process each BIS.
--- src/shared/bap.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++ src/shared/bap.h | 10 ++++ 2 files changed, 135 insertions(+)
src/shared/bap.c +125 -0
@@ -7067,3 +7067,128 @@ void bt_bap_verify_bis(struct bt_bap *bap, uint8_t bis_index, } } + +bool bt_bap_parse_base (struct iovec *iov, +struct bt_bap_qos *qos, +util_debug_func_t func, +bt_bap_bis_func_t handler, +void *user_data) +{ +uint32_t delay; +uint8_t sgrps; +bool ret = true; + +util_debug (func,NULL ,"BASE len: %ld" , iov->iov_len); + +if (!util_iov_pull_le24 (iov, &delay)) +return false; + +util_debug (func,NULL ,"PresentationDelay: %d" , delay); + +if (!util_iov_pull_u8 (iov, &sgrps)) +return false; + +util_debug (func,NULL ,"Number of Subgroups: %d" , sgrps); + +/* Loop subgroups */ +for (int idx =0 ; idx < sgrps; idx++) { +uint8_t num_bis; +struct bt_bap_codec *codec; +struct iovec l2_cc; +uint8_t l2_cc_len; +struct iovec meta; +uint8_t meta_len; + +util_debug (func,NULL ,"Subgroup #%d" , idx); + +if (!util_iov_pull_u8 (iov, &num_bis)) { + ret = false; + goto done; + } + +util_debug (func,NULL ,"Number of BISes: %d" , num_bis); + + codec =util_iov_pull_mem (iov,sizeof (*codec)); + +util_debug (func,NULL ,"Codec: ID %d CID 0x%2.2x VID 0x%2.2x" , + codec->id, codec->cid, codec->vid); + +/* Level 2 */ +/* Read Codec Specific Configuration */ +if (!util_iov_pull_u8 (iov, &l2_cc_len)) { + ret = false; + goto done; + } + + l2_cc.iov_base =util_iov_pull_mem (iov, l2_cc_len); + l2_cc.iov_len = l2_cc_len; + +/* Print Codec Specific Configuration */ +util_debug (func,NULL ,"CC len: %ld" , l2_cc.iov_len); +bt_bap_debug_config (l2_cc.iov_base, l2_cc.iov_len, + func,NULL ); + +/* Read Metadata */ +if (!util_iov_pull_u8 (iov, &meta_len)) { + ret = false; + goto done; + } + + meta.iov_base =util_iov_pull_mem (iov, meta_len); + meta.iov_len = meta_len; + +/* Print Metadata */ +util_debug (func,NULL ,"Metadata len: %i" , + (uint8_t )meta.iov_len); +bt_bap_debug_metadata (meta.iov_base, meta.iov_len, + func,NULL ); + +/* Level 3 */ +for (; num_bis; num_bis--) { +uint8_t bis_index; +struct iovec l3_cc; +uint8_t l3_cc_len; +struct iovec *bis_cc; + +if (!util_iov_pull_u8 (iov, &bis_index)) { + ret = false; + goto done; + } + +util_debug (func,NULL ,"BIS #%d" , bis_index); + +/* Read Codec Specific Configuration */ +if (!util_iov_pull_u8 (iov, &l3_cc_len)) { + ret = false; + goto done; + } + + l3_cc.iov_base =util_iov_pull_mem (iov, + l3_cc_len); + l3_cc.iov_len = l3_cc_len; + +/* Print Codec Specific Configuration */ +util_debug (func,NULL ,"CC Len: %d" , + (uint8_t )l3_cc.iov_len); + +bt_bap_debug_config (l3_cc.iov_base, + l3_cc.iov_len, + func,NULL ); + + bis_cc =bt_bap_merge_caps (&l2_cc, &l3_cc); +if (!bis_cc) +continue ; + +handler (bis_index, idx, bis_cc, &meta, + qos, user_data); + +util_iov_free (bis_cc,1 ); + } + } + +done: +if (!ret) +util_debug (func,NULL ,"Unable to parse Base" ); + +return ret; +}
src/shared/bap.h +10 -0
@@ -40,6 +40,10 @@ typedef void (*bt_bap_stream_func_t)(struct bt_bap_stream *stream, void *user_data);typedef void (*bt_bap_func_t )(struct bt_bap *bap,void *user_data); +typedef void (*bt_bap_bis_func_t )(uint8_t bis,uint8_t sgrp, +struct iovec *caps,struct iovec *meta, +struct bt_bap_qos *qos,void *user_data); +/* Local PAC related functions */ struct bt_bap_pac_qos {uint8_t framing;
@@ -259,3 +263,9 @@ void bt_bap_verify_bis(struct bt_bap *bap, uint8_t bis_index,struct iovec *caps, struct bt_bap_pac **lpac); +bool bt_bap_parse_base (struct iovec *base, +struct bt_bap_qos *qos, +util_debug_func_t func, +bt_bap_bis_func_t handler, +void *user_data); +
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=911224
---Test result---
Test Summary:
CheckPatch PENDING 0.23 seconds GitLint PENDING 0.24 seconds BuildEll PASS 20.47 seconds BluezMake PASS 1548.85 seconds MakeCheck PASS 13.40 seconds MakeDistcheck PASS 158.35 seconds CheckValgrind PASS 214.68 seconds CheckSmatch WARNING 274.03 seconds bluezmakeextell PASS 101.23 seconds IncrementalBuild PENDING 0.22 seconds ScanBuild PASS 858.25 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:296: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:296: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:296: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 v2 2/7 bap: Add helpers to convert iso_qos to/from bap_qos
In reply to Iulia TanasescuThis adds public BAP helpers to convert iso_qos to bap_qos and reversed. This is needed for the BASS plugin to handle the Scan Delegator (BASS Server) role internally (to create/handle BAP streams when receiving the Add Source command from a Broadcast Assistant).
--- profiles/audio/bap.c | 93 +++++++++++++++++++++++++------------------- profiles/audio/bap.h | 5 +++ 2 files changed, 58 insertions(+), 40 deletions(-)
profiles/audio/bap.c +53 -40
@@ -1041,6 +1041,57 @@ static void print_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v,util_hexdump (' ' , v, l, user_data,NULL ); } +void 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 )); +} + +void 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; +} +static void create_stream_for_bis (struct bap_data *bap_data,struct bt_bap_pac *lpac,struct bt_iso_qos *qos,struct iovec *caps,struct iovec *meta,char *path)
@@ -1050,28 +1101,7 @@ static void create_stream_for_bis(struct bap_data *bap_data, setup =setup_new (NULL );/* Create BAP QoS structure */ - setup->qos.bcast.big = qos->bcast.big; - setup->qos.bcast.bis = qos->bcast.bis; - setup->qos.bcast.sync_factor = qos->bcast.sync_factor; - setup->qos.bcast.packing = qos->bcast.packing; - setup->qos.bcast.framing = qos->bcast.framing; - setup->qos.bcast.encryption = qos->bcast.encryption; -if (setup->qos.bcast.encryption) - setup->qos.bcast.bcode =util_iov_new (qos->bcast.bcode, -sizeof (qos->bcast.bcode)); - setup->qos.bcast.options = qos->bcast.options; - setup->qos.bcast.skip = qos->bcast.skip; - setup->qos.bcast.sync_timeout = qos->bcast.sync_timeout; - setup->qos.bcast.sync_cte_type = - qos->bcast.sync_cte_type; - setup->qos.bcast.mse = qos->bcast.mse; - setup->qos.bcast.timeout = qos->bcast.timeout; - setup->qos.bcast.io_qos.interval = - qos->bcast.in.interval; - setup->qos.bcast.io_qos.latency = qos->bcast.in.latency; - setup->qos.bcast.io_qos.phy = qos->bcast.in.phy; - setup->qos.bcast.io_qos.rtn = qos->bcast.in.rtn; - setup->qos.bcast.io_qos.sdu = qos->bcast.in.sdu; +bap_iso_qos_to_bap_qos (qos, &setup->qos);queue_push_tail (bap_data->bcast_snks, setup);
@@ -3158,24 +3188,7 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data)queue_foreach (setups, setup_refresh_qos,NULL );/* Set the user requested QOS */ -memset (&qos,0 ,sizeof (qos)); - qos.bcast.big = setup->qos.bcast.big; - qos.bcast.bis = setup->qos.bcast.bis; - qos.bcast.sync_factor = setup->qos.bcast.sync_factor; - qos.bcast.packing = setup->qos.bcast.packing; - qos.bcast.framing = setup->qos.bcast.framing; - qos.bcast.encryption = setup->qos.bcast.encryption; -if (setup->qos.bcast.bcode && setup->qos.bcast.bcode->iov_base) -memcpy (qos.bcast.bcode, setup->qos.bcast.bcode->iov_base, - setup->qos.bcast.bcode->iov_len); - qos.bcast.options = setup->qos.bcast.options; - qos.bcast.skip = setup->qos.bcast.skip; - qos.bcast.sync_timeout = setup->qos.bcast.sync_timeout; - qos.bcast.sync_cte_type = setup->qos.bcast.sync_cte_type; - qos.bcast.mse = setup->qos.bcast.mse; - qos.bcast.timeout = setup->qos.bcast.timeout; -memcpy (&qos.bcast.out, &setup->qos.bcast.io_qos, -sizeof (struct bt_iso_io_qos )); +bap_qos_to_iso_qos (&setup->qos, &qos); if (!bt_io_set(io, &err, BT_IO_OPT_QOS, &qos,
profiles/audio/bap.h +5 -0
@@ -9,3 +9,8 @@struct bt_bap *bap_get_session (struct btd_device *device);void bap_scan_delegator_probe (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, +struct bt_iso_qos *iso_qos);
Signature · 1 line
2.43.0
PATCH v2 3/7 bap: Rework BASE parsing
In reply to Iulia TanasescuThis replaces the internal parse_base with bt_bap_parse_base from shared/bap. A bis callback is added to handle parsed streams.
The Broadcast Assistant implementation in the BASS plugin is also updated to use bap qos instead of iso qos, since the BISes are now parsed along with bap qos structure.
--- profiles/audio/bap.c | 207 ++++++++---------------------------------- profiles/audio/bass.c | 30 ++++-- profiles/audio/bass.h | 2 +- 3 files changed, 61 insertions(+), 178 deletions(-)
profiles/audio/bap.c +39 -168
@@ -1034,13 +1034,6 @@ static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) } } -static void print_ltv (size_t i,uint8_t l,uint8_t t,uint8_t *v, -void *user_data) -{ -util_debug (user_data,NULL ,"CC #%zu: l:%u t:%u" , i, l, t); -util_hexdump (' ' , v, l, user_data,NULL ); -} -void bap_qos_to_iso_qos (struct bt_bap_qos *bap_qos,struct bt_iso_qos *iso_qos) {
@@ -1093,15 +1086,16 @@ void bap_iso_qos_to_bap_qos(struct bt_iso_qos *iso_qos, }static void create_stream_for_bis (struct bap_data *bap_data, -struct bt_bap_pac *lpac,struct bt_iso_qos *qos, +struct bt_bap_pac *lpac,struct bt_bap_qos *qos,struct iovec *caps,struct iovec *meta,char *path) {struct bap_setup *setup; setup =setup_new (NULL ); + setup->qos = *qos; -/* Create BAP QoS structure */ -bap_iso_qos_to_bap_qos (qos, &setup->qos); +/* Create an internal copy for bcode */ + setup->qos.bcast.bcode =util_iov_dup (qos->bcast.bcode,1 );queue_push_tail (bap_data->bcast_snks, setup);
@@ -1116,170 +1110,37 @@ static void create_stream_for_bis(struct bap_data *bap_data, NULL, NULL); } -static bool parse_base (struct bap_data *bap_data,struct bt_iso_base *base, -struct bt_iso_qos *qos,util_debug_func_t func) +static void bis_handler (uint8_t bis,uint8_t sgrp,struct iovec *caps, +struct iovec *meta,struct bt_bap_qos *qos,void *user_data) { -struct iovec iov = { - .iov_base = base->base, - .iov_len = base->base_len, - }; -uint32_t pres_delay; -uint8_t num_subgroups; -bool ret = true; - -util_debug (func,NULL ,"BASE len: %ld" , iov.iov_len); - -if (!util_iov_pull_le24 (&iov, &pres_delay)) -return false; -util_debug (func,NULL ,"PresentationDelay: %d" , pres_delay); - -if (!util_iov_pull_u8 (&iov, &num_subgroups)) -return false; -util_debug (func,NULL ,"Number of Subgroups: %d" , num_subgroups); - -/* Loop subgroups */ -for (int idx =0 ; idx < num_subgroups; idx++) { -uint8_t num_bis; -struct bt_bap_codec codec; -struct iovec *l2_caps =NULL ; -struct iovec *meta =NULL ; - -util_debug (func,NULL ,"Subgroup #%d" , idx); - -if (!util_iov_pull_u8 (&iov, &num_bis)) { - ret = false; - goto fail; - } -util_debug (func,NULL ,"Number of BISes: %d" , num_bis); - -memcpy (&codec, -util_iov_pull_mem (&iov, -sizeof (struct bt_bap_codec )), -sizeof (struct bt_bap_codec )); -util_debug (func,NULL ,"Codec: ID %d CID 0x%2.2x VID 0x%2.2x" , - codec.id, codec.cid, codec.vid); - -/* Level 2 */ -/* Read Codec Specific Configuration */ - l2_caps = new0(struct iovec, 1); -if (!util_iov_pull_u8 (&iov, (void *)&l2_caps->iov_len)) { - ret = false; - goto group_fail; - } - -util_iov_memcpy (l2_caps,util_iov_pull_mem (&iov, - l2_caps->iov_len), - l2_caps->iov_len); - -/* Print Codec Specific Configuration */ -util_debug (func,NULL ,"CC len: %ld" , l2_caps->iov_len); -util_ltv_foreach (l2_caps->iov_base, l2_caps->iov_len,NULL , - print_ltv, func); - -/* Read Metadata */ - meta = new0(struct iovec, 1); -if (!util_iov_pull_u8 (&iov, (void *)&meta->iov_len)) { - ret = false; - goto group_fail; - } - -util_iov_memcpy (meta, -util_iov_pull_mem (&iov, meta->iov_len), - meta->iov_len); - -/* Print Metadata */ -util_debug (func,NULL ,"Metadata len: %i" , - (uint8_t )meta->iov_len); -util_hexdump (' ' , meta->iov_base, meta->iov_len, func,NULL ); - -/* Level 3 */ -for (; num_bis; num_bis--) { -uint8_t bis_index; -struct iovec *l3_caps; -struct iovec *merged_caps; -struct bt_bap_pac *matched_lpac; -char *path; -int err; - -if (!util_iov_pull_u8 (&iov, &bis_index)) { - ret = false; - goto group_fail; - } - -util_debug (func,NULL ,"BIS #%d" , bis_index); - err =asprintf (&path,"%s/bis%d" , -device_get_path (bap_data->device), - bis_index); -if (err <0 ) -continue ; - -/* Read Codec Specific Configuration */ - l3_caps = new0(struct iovec, 1); -if (!util_iov_pull_u8 (&iov, - (void *)&l3_caps->iov_len)) { -free (l3_caps); -free (path); - ret = false; - goto group_fail; - } - -util_iov_memcpy (l3_caps, -util_iov_pull_mem (&iov, - l3_caps->iov_len), - l3_caps->iov_len); - -/* Print Codec Specific Configuration */ -util_debug (func,NULL ,"CC Len: %d" , - (uint8_t )l3_caps->iov_len); -util_ltv_foreach (l3_caps->iov_base, - l3_caps->iov_len,NULL , print_ltv, - func); - - merged_caps =bt_bap_merge_caps (l2_caps, l3_caps); -if (!merged_caps) { -free (path); -continue ; - } - -bass_add_stream (bap_data->device, meta, merged_caps, - qos, idx, bis_index); - -if (!bass_check_bis (bap_data->device, bis_index)) { -/* If this Broadcast Sink is acting as a Scan -* Delegator, only attempt to create streams -* for the BISes required by the peer Broadcast -* Assistant. -*/ -continue ; - } +struct bap_data *data = user_data; +struct bt_bap_pac *lpac; +char *path; -/* Check if this BIS matches any local PAC */ -bt_bap_verify_bis (bap_data->bap, bis_index, - merged_caps, &matched_lpac); +bass_add_stream (data->device, meta, caps, qos, sgrp, bis); -if (matched_lpac ==NULL ) { -free (path); -continue ; - } +if (!bass_check_bis (data->device, bis)) +/* If this Broadcast Sink is acting as a Scan +* Delegator, only attempt to create streams +* for the BISes required by the peer Broadcast +* Assistant. +*/ +return ; -create_stream_for_bis (bap_data, matched_lpac, qos, - merged_caps, meta, path); - } +/* Check if this BIS matches any local PAC */ +bt_bap_verify_bis (data->bap, bis, + caps, &lpac); -group_fail: -if (l2_caps !=NULL ) -free (l2_caps); -if (meta !=NULL ) -free (meta); -if (!ret) -break ; - } +if (!lpac) +return ; -fail: -if (!ret) -util_debug (func,NULL ,"Unable to parse Base" ); +if (asprintf (&path,"%s/bis%d" , +device_get_path (data->device), + bis) <0 ) +return ; -return ret; +create_stream_for_bis (data, lpac, qos, + caps, meta, path); } static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond,
@@ -1290,6 +1151,8 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond,struct bap_data *data =btd_service_get_user_data (req->data.service);struct bt_iso_base base;struct bt_iso_qos qos; +struct iovec iov; +struct bt_bap_qos bap_qos = {0 };DBG ("BIG Info received" );
@@ -1329,7 +1192,15 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond,/* Analyze received BASE data and create remote media endpoints for each * BIS matching our capabilities */ -parse_base (data, &base, &qos, bap_debug); + iov.iov_base = base.base; + iov.iov_len = base.base_len; + +/* Create BAP QoS structure */ +bap_iso_qos_to_bap_qos (&qos, &bap_qos); + +bt_bap_parse_base (&iov, &bap_qos, bap_debug, bis_handler, data); + +util_iov_free (bap_qos.bcast.bcode,1 );service_set_connecting (req->data.service);
profiles/audio/bass.c +21 -9
@@ -92,7 +92,7 @@ struct bass_assistant {uint8_t sgrp;uint8_t bis;uint32_t bid; -struct bt_iso_qos qos; +struct bt_bap_qos qos;struct iovec *meta;struct iovec *caps;enum assistant_state state;
@@ -399,8 +399,8 @@ static int assistant_parse_qos(struct bass_assistant *assistant,return -EINVAL ; } -memcpy (assistant->qos.bcast.bcode, iov.iov_base, - iov.iov_len); +util_iov_free (assistant->qos.bcast.bcode,1 ); + assistant->qos.bcast.bcode =util_iov_dup (&iov,1 );return 0 ; }
@@ -592,7 +592,12 @@ static gboolean get_qos(const GDBusPropertyTable *property, {struct bass_assistant *assistant = data;DBusMessageIter dict; -uint8_t *bcode = assistant->qos.bcast.bcode; +uint8_t arr[BT_BASS_BCAST_CODE_SIZE ] = {0 }; +uint8_t *bcode = arr; + +if (assistant->qos.bcast.bcode) +memcpy (arr, assistant->qos.bcast.bcode->iov_base, +BT_BASS_BCAST_CODE_SIZE );dbus_message_iter_open_container (iter,DBUS_TYPE_ARRAY , DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
@@ -648,7 +653,7 @@ static void src_ad_search_bid(void *data, void *user_data)static struct bass_assistant *assistant_new (struct btd_adapter *adapter,struct btd_device *device,struct bass_data *data, -uint8_t sgrp,uint8_t bis,struct bt_iso_qos *qos, +uint8_t sgrp,uint8_t bis,struct bt_bap_qos *qos,struct iovec *meta,struct iovec *caps) {struct bass_assistant *assistant;
@@ -666,6 +671,10 @@ static struct bass_assistant *assistant_new(struct btd_adapter *adapter, assistant->sgrp = sgrp; assistant->bis = bis; assistant->qos = *qos; + +/* Create an internal copy for bcode */ + assistant->qos.bcast.bcode =util_iov_dup (qos->bcast.bcode,1 ); + assistant->meta =util_iov_dup (meta,1 ); assistant->caps =util_iov_dup (caps,1 );
@@ -689,7 +698,7 @@ static struct bass_assistant *assistant_new(struct btd_adapter *adapter, }void bass_add_stream (struct btd_device *device,struct iovec *meta, -struct iovec *caps,struct bt_iso_qos *qos, +struct iovec *caps,struct bt_bap_qos *qos,uint8_t sgrp,uint8_t bis) {const struct queue_entry *entry;
@@ -998,7 +1007,7 @@ static void bass_attached(struct bt_bass *bass, void *user_data)static void bass_handle_bcode_req (struct bass_assistant *assistant,int id) {struct bt_bass_bcast_audio_scan_cp_hdr hdr; -struct bt_bass_set_bcast_code_params params; +struct bt_bass_set_bcast_code_params params = {0 };struct iovec iov = {0 };int err;
@@ -1007,8 +1016,11 @@ static void bass_handle_bcode_req(struct bass_assistant *assistant, int id) hdr.op =BT_BASS_SET_BCAST_CODE ; params.id = id; -memcpy (params.bcast_code, assistant->qos.bcast.bcode, -BT_BASS_BCAST_CODE_SIZE ); + +if (assistant->qos.bcast.bcode) +memcpy (params.bcast_code, + assistant->qos.bcast.bcode->iov_base, +BT_BASS_BCAST_CODE_SIZE ); iov.iov_base =malloc0 (sizeof (params));if (!iov.iov_base)
profiles/audio/bass.h +1 -1
@@ -8,7 +8,7 @@*/ void bass_add_stream (struct btd_device *device,struct iovec *meta, -struct iovec *caps,struct bt_iso_qos *qos, +struct iovec *caps,struct bt_bap_qos *qos,uint8_t sgrp,uint8_t bis);void bass_remove_stream (struct btd_device *device);
Signature · 1 line
2.43.0
PATCH v2 4/7 bap: Make default PA sync QoS public
In reply to Iulia TanasescuThis make the default BAP QoS parameters for PA Create Sync public, to be available to other plugins that might need to listen for Broadcasters (like BASS).
--- profiles/audio/bap.c | 2 +- profiles/audio/bap.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
profiles/audio/bap.c +1 -1
@@ -150,7 +150,7 @@ static struct queue *adapters;* The full QOS is populated at the time the user selects and endpoint and * configures it using SetConfiguration. */ -static struct bt_iso_qos bap_sink_pa_qos = { +struct bt_iso_qos bap_sink_pa_qos = { .bcast = { .options =0x00 , .skip =0x0000 ,
profiles/audio/bap.h +2 -0
@@ -7,6 +7,8 @@* */ +extern struct bt_iso_qos bap_sink_pa_qos; +struct bt_bap *bap_get_session (struct btd_device *device);void bap_scan_delegator_probe (struct btd_device *device);
Signature · 1 line
2.43.0
PATCH v2 5/7 bass: Rework Scan Delegator to handle BAP streams
In reply to Iulia TanasescuThis updates the Scan Delegator implementation to be handled internally in
BASS: The BASS Server is responsible to handle Write Commands for the Add Source operation by creating long-lived PA sync, parsing the BASE, creating and configuring BAP streams, as well as enabling them.
--- profiles/audio/bap.c | 18 +-- profiles/audio/bass.c | 332 ++++++++++++++++++++++++++++++++++++------ profiles/audio/bass.h | 4 +- 3 files changed, 297 insertions(+), 57 deletions(-)
profiles/audio/bap.c +7 -11
@@ -1119,14 +1119,6 @@ static void bis_handler(uint8_t bis, uint8_t sgrp, struct iovec *caps,bass_add_stream (data->device, meta, caps, qos, sgrp, bis); -if (!bass_check_bis (data->device, bis)) -/* If this Broadcast Sink is acting as a Scan -* Delegator, only attempt to create streams -* for the BISes required by the peer Broadcast -* Assistant. -*/ -return ; -/* Check if this BIS matches any local PAC */ bt_bap_verify_bis (data->bap, bis, caps, &lpac);
@@ -1186,9 +1178,6 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond,g_io_channel_shutdown (io, TRUE,NULL ); } -/* Notify the BASS plugin about the session. */ -bass_bcast_probe (data->device, data->bap); -/* Analyze received BASE data and create remote media endpoints for each * BIS matching our capabilities */
@@ -2598,6 +2587,8 @@ static void bap_state_bcast_sink(struct bt_bap_stream *stream,return ; setup =bap_find_setup_by_stream (data, stream); +if (!setup) +return ;switch (new_state) {case BT_BAP_STREAM_STATE_IDLE :
@@ -3145,6 +3136,7 @@ static int bap_bcast_probe(struct btd_service *service)struct bap_bcast_pa_req *req;uint8_t type =BAP_PA_LONG_REQ ;struct bap_data *data; +int ret =0 ;if (!btd_adapter_has_exp_feature (adapter,EXP_FEAT_ISO_SOCKET )) {error ("BAP requires ISO Socket which is not enabled" );
@@ -3198,6 +3190,10 @@ static int bap_bcast_probe(struct btd_service *service)bt_bap_set_user_data (data->bap, service); +if (bass_bcast_probe (service, &ret)) +/* Return if probed device was handled inside BASS. */ +return ret; +/* Start the PA timer if it hasn't been started yet */ if (data->adapter->pa_timer_id ==0 ) data->adapter->pa_timer_id = g_timeout_add_seconds(
profiles/audio/bass.c +289 -43
465 lines not on this page · raw message
profiles/audio/bass.h +1 -3
@@ -12,11 +12,9 @@ void bass_add_stream(struct btd_device *device, struct iovec *meta, 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_probe (struct btd_service *service,int *ret);bool bass_bcast_remove (struct btd_device *device); -bool bass_check_bis (struct btd_device *device,uint8_t bis); -typedef void (*bt_bass_bcode_func_t )(void *user_data,int err); void bass_req_bcode(struct bt_bap_stream *stream,
Signature · 1 line
2.43.0
PATCH v2 6/7 bap: Remove API to probe device from BASS
In reply to Iulia TanasescuThis removes the BAP API to probe broadcasters from BASS, since BASS is now directly adding the Broadcast Audio Announcement Service UUID to the broadcaster device, and it will internally handle the probe.
--- profiles/audio/bap.c | 16 ---------------- profiles/audio/bap.h | 1 - 2 files changed, 17 deletions(-)
profiles/audio/bap.c +0 -16
@@ -3112,22 +3112,6 @@ static bool match_bap_adapter(const void *data, const void *match_data)return adapter->adapter == match_data; } -void bap_scan_delegator_probe (struct btd_device *device) -{ -struct bap_data *data; - -/* Create BAP session for the Broadcaster device */ - data =bap_data_new (device); - data->device = device; - -bap_data_add (data); - -/* Add Broadcast Audio Announcement Service UUID -* to device and probe service. -*/ -btd_device_add_uuid (device,BCAAS_UUID_STR ); -} -static int bap_bcast_probe (struct btd_service *service) {struct btd_device *device =btd_service_get_device (service);
profiles/audio/bap.h +0 -1
@@ -10,7 +10,6 @@extern struct bt_iso_qos bap_sink_pa_qos;struct bt_bap *bap_get_session (struct btd_device *device); -void bap_scan_delegator_probe (struct btd_device *device);void bap_iso_qos_to_bap_qos (struct bt_iso_qos *iso_qos,struct bt_bap_qos *bap_qos);
Signature · 1 line
2.43.0
PATCH v2 7/7 bap: Remove PA idle timer logic
In reply to Iulia TanasescuThis removes BAP support for long-lived PA sync (added for Scan Delegator support), since it is now handled inside the BASS plugin. This also removes the PA idle timer logic, since PA/BIG sync requests are now ordered inside the kernel.
--- profiles/audio/bap.c | 369 ++++++++++--------------------------------- 1 file changed, 81 insertions(+), 288 deletions(-)
profiles/audio/bap.c +81 -288
@@ -65,15 +65,9 @@#define MEDIA_ENDPOINT_INTERFACE "org.bluez.MediaEndpoint1"#define MEDIA_INTERFACE "org.bluez.Media1" -/* Periodic advertisments are performed by an idle timer, which, -* at every tick, checks a queue for pending PA requests. -* When there is no pending requests, an item is popped from the -* queue, marked as pending and then it gets processed. -*/ -#define PA_IDLE_TIMEOUT 2 -struct bap_setup {struct bap_ep *ep; +struct bap_data *data;struct bt_bap_stream *stream;struct bt_bap_qos qos; int (*qos_parser)(struct bap_setup *setup, const char *key, int var,
@@ -101,15 +95,9 @@ struct bap_ep {struct queue *setups; }; -struct bap_adapter { -struct btd_adapter *adapter; -unsigned int pa_timer_id; -struct queue *bcast_pa_requests; -}; -struct bap_data {struct btd_device *device; -struct bap_adapter *adapter; +struct btd_adapter *adapter;struct btd_service *service;struct bt_bap *bap;unsigned int ready_id;
@@ -121,30 +109,12 @@ struct bap_data {struct queue *bcast_snks;struct queue *streams;GIOChannel *listen_io; +unsigned int io_id;int selecting;void *user_data; }; -enum { -BAP_PA_SHORT_REQ =0 ,/* Request for short PA sync */ -BAP_PA_LONG_REQ ,/* Request for long PA sync */ -BAP_PA_BIG_SYNC_REQ ,/* Request for PA Sync and BIG Sync */ -}; - -struct bap_bcast_pa_req { -uint8_t type; -bool in_progress; -struct bap_data *bap_data; -union { -struct btd_service *service; -struct queue *setups; - } data; -unsigned int io_id;/* io_id for BIG Info watch */ -GIOChannel *io; -}; -static struct queue *sessions; -static struct queue *adapters;/* Structure holding the parameters for Periodic Advertisement create sync. * The full QOS is populated at the time the user selects and endpoint and
@@ -219,6 +189,9 @@ static void bap_data_free(struct bap_data *data)g_io_channel_unref (data->listen_io); } +if (data->io_id) +g_source_remove (data->io_id); +if (data->service) {btd_service_set_user_data (data->service,NULL );bt_bap_set_user_data (data->bap,NULL );
@@ -382,7 +355,7 @@ static gboolean get_device(const GDBusPropertyTable *property,const char *path;if (bt_bap_pac_get_type (ep->lpac) ==BT_BAP_BCAST_SOURCE ) - path =adapter_get_path (ep->data->adapter->adapter); + path =adapter_get_path (ep->data->adapter);else path =device_get_path (ep->data->device);
@@ -996,12 +969,19 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg,return NULL ; } +static bool stream_io_unset (const void *data,const void *user_data) +{ +struct bt_bap_stream *stream = (struct bt_bap_stream *)data; + +return !bt_bap_stream_get_io (stream); +} +static void iso_bcast_confirm_cb (GIOChannel *io,GError *err,void *user_data) { -struct bap_bcast_pa_req *req = user_data; -struct bap_setup *setup; +struct bap_setup *setup = user_data; +struct bt_bap_stream *stream = setup->stream;int fd; -struct bap_data *bap_data = req->bap_data; +struct bap_data *bap_data = setup->data;DBG ("BIG Sync completed" );
@@ -1009,28 +989,23 @@ static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data)* to the order of the BISes that were enqueued before * calling bt_io_bcast_accept. */ - setup =queue_pop_head (req->data.setups); - -if (queue_isempty (req->data.setups)) { -/* All fds have been notified. Mark service as connected. */ -btd_service_connecting_complete (bap_data->service,0 ); - -if (req->io) { -g_io_channel_unref (req->io); -g_io_channel_shutdown (req->io, TRUE,NULL ); - req->io =NULL ; - } - -queue_remove (bap_data->adapter->bcast_pa_requests, req); -queue_destroy (req->data.setups,NULL ); -free (req); - } +if (bt_bap_stream_get_io (stream)) + stream =queue_find (bt_bap_stream_io_get_links (stream), + stream_io_unset,NULL ); fd =g_io_channel_unix_get_fd (io); -if (bt_bap_stream_set_io (setup->stream, fd)) { +if (bt_bap_stream_set_io (stream, fd))g_io_channel_set_close_on_unref (io, FALSE); -return ; + +if (!queue_find (bt_bap_stream_io_get_links (stream), + stream_io_unset,NULL )) { +/* All fds have been notified. Mark service as connected. */ +btd_service_connecting_complete (bap_data->service,0 ); + +g_io_channel_unref (bap_data->listen_io); +g_io_channel_shutdown (bap_data->listen_io, TRUE,NULL ); + bap_data->listen_io =NULL ; } }
@@ -1097,6 +1072,8 @@ static void create_stream_for_bis(struct bap_data *bap_data,/* Create an internal copy for bcode */ setup->qos.bcast.bcode =util_iov_dup (qos->bcast.bcode,1 ); + setup->data = bap_data; +queue_push_tail (bap_data->bcast_snks, setup);/* Create and configure stream */
@@ -1139,8 +1116,7 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, gpointer user_data) {GError *err =NULL ; -struct bap_bcast_pa_req *req = user_data; -struct bap_data *data =btd_service_get_user_data (req->data.service); +struct bap_data *data = user_data;struct bt_iso_base base;struct bt_iso_qos qos;struct iovec iov;
@@ -1156,7 +1132,7 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond,error ("%s" , err->message);g_error_free (err);g_io_channel_shutdown (io, TRUE,NULL ); - req->io_id =0 ; + data->io_id =0 ;return FALSE; }
@@ -1165,18 +1141,10 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond,g_io_channel_unref (data->listen_io); data->listen_io =NULL ; -if (req->type ==BAP_PA_LONG_REQ ) { -/* If long-lived PA sync was requested, keep a reference -* to the PA sync io to keep the sync active. -*/ - data->listen_io = io; -g_io_channel_ref (io); - }else { -/* For short-lived PA, the sync is no longer needed at -* this point, so the io can be closed. -*/ -g_io_channel_shutdown (io, TRUE,NULL ); - } +/* For short-lived PA, the sync is no longer needed at +* this point, so the io can be closed. +*/ +g_io_channel_shutdown (io, TRUE,NULL );/* Analyze received BASE data and create remote media endpoints for each * BIS matching our capabilities
@@ -1191,23 +1159,21 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond,util_iov_free (bap_qos.bcast.bcode,1 ); -service_set_connecting (req->data.service); +service_set_connecting (data->service); -queue_remove (data->adapter->bcast_pa_requests, req); - req->io_id =0 ; -free (req); + data->io_id =0 ;return FALSE; }static void iso_pa_sync_confirm_cb (GIOChannel *io,void *user_data) { -struct bap_bcast_pa_req *req = user_data; +struct bap_data *data = user_data;/* PA Sync was established, wait for BIG Info report so that the * encryption flag is also available. */ DBG ("PA Sync done" ); - req->io_id =g_io_add_watch (io,G_IO_OUT , big_info_report_cb, + data->io_id =g_io_add_watch (io,G_IO_OUT , big_info_report_cb, user_data); }
@@ -1262,7 +1228,7 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data,struct bt_bap_pac *lpac, struct bt_bap_pac *rpac) { - struct btd_adapter *adapter = data->adapter->adapter; + struct btd_adapter *adapter = data->adapter;struct btd_device *device = data->device;struct bap_ep *ep;struct queue *queue;
@@ -2109,95 +2075,13 @@ static void setup_listen_io(struct bap_data *data, struct bt_bap_stream *stream, data->listen_io = io; } -static void check_pa_req_in_progress (void *data,void *user_data) -{ -struct bap_bcast_pa_req *req = data; - -if (req->in_progress == TRUE) - *((bool *)user_data) = TRUE; -} - -static int pa_sync (struct bap_bcast_pa_req *req); -static void pa_and_big_sync (struct bap_bcast_pa_req *req); - -static gboolean pa_idle_timer (gpointer user_data) -{ -struct bap_adapter *adapter = user_data; -struct bap_bcast_pa_req *req; -bool in_progress = FALSE; - -/* Handle timer if no request is in progress */ -queue_foreach (adapter->bcast_pa_requests, check_pa_req_in_progress, - &in_progress); -if (in_progress == FALSE) { - req =queue_peek_head (adapter->bcast_pa_requests); -if (req !=NULL ) -switch (req->type) { -case BAP_PA_SHORT_REQ : -DBG ("do short lived PA Sync" ); -pa_sync (req); -break ; -case BAP_PA_LONG_REQ : -DBG ("do long lived PA Sync" ); -pa_sync (req); -break ; -case BAP_PA_BIG_SYNC_REQ : -DBG ("do PA Sync and BIG Sync" ); -pa_and_big_sync (req); -break ; - } -else { -/* pa_req queue is empty, stop the timer by returning -* FALSE and set the pa_timer_id to 0. This will later -* be used to check if the timer is active. -*/ - adapter->pa_timer_id =0 ; -return FALSE; - } - } - -return TRUE; -} +static int pa_sync (struct bap_data *data); +static void pa_and_big_sync (struct bap_setup *setup);static void setup_accept_io_broadcast (struct bap_data *data,struct bap_setup *setup) { - struct bap_bcast_pa_req *req = new0(struct bap_bcast_pa_req, 1); -struct bap_adapter *adapter = data->adapter; -struct queue *links =bt_bap_stream_io_get_links (setup->stream); -const struct queue_entry *entry; - -/* Timer could be stopped if all other requests were treated. -* Check the state of the timer and turn it on so that this request -* can also be treated. -*/ -if (adapter->pa_timer_id ==0 ) - adapter->pa_timer_id =g_timeout_add_seconds (PA_IDLE_TIMEOUT , - pa_idle_timer, - adapter); - -/* Add this request to the PA queue. -* We don't need to check the queue here, as we cannot have -* BAP_PA_BIG_SYNC_REQ before a short PA (BAP_PA_SHORT_REQ) -*/ - req->type =BAP_PA_BIG_SYNC_REQ ; - req->in_progress = FALSE; - req->bap_data = data; - - req->data.setups =queue_new (); - -/* Enqueue all linked setups to the request */ -queue_push_tail (req->data.setups, setup); - -for (entry =queue_get_entries (links); entry; - entry = entry->next) { -struct bt_bap_stream *stream = entry->data; - -queue_push_tail (req->data.setups, -bap_find_setup_by_stream (data, stream)); - } - -queue_push_tail (adapter->bcast_pa_requests, req); +pa_and_big_sync (setup); } static void setup_create_ucast_io(struct bap_data *data,
@@ -2952,10 +2836,8 @@ static void bap_detached(struct bt_bap *bap, void *user_data)bap_data_remove (data); } -static int pa_sync (struct bap_bcast_pa_req *req) +static int pa_sync (struct bap_data *data) { -struct btd_service *service = req->data.service; -struct bap_data *data =btd_service_get_user_data (service);GError *err =NULL ;if (data->listen_io) {
@@ -2964,13 +2846,13 @@ static int pa_sync(struct bap_bcast_pa_req *req) }DBG ("Create PA sync with this source" ); - req->in_progress = TRUE; - data->listen_io = bt_io_listen(NULL, iso_pa_sync_confirm_cb, req, + + data->listen_io = bt_io_listen(NULL, iso_pa_sync_confirm_cb, data, NULL, &err, BT_IO_OPT_SOURCE_BDADDR, - btd_adapter_get_address(data->adapter->adapter), + btd_adapter_get_address(data->adapter), BT_IO_OPT_SOURCE_TYPE, - btd_adapter_get_address_type(data->adapter->adapter), + btd_adapter_get_address_type(data->adapter), BT_IO_OPT_DEST_BDADDR, device_get_address(data->device), BT_IO_OPT_DEST_TYPE,
@@ -2988,9 +2870,9 @@ static int pa_sync(struct bap_bcast_pa_req *req)static void append_setup (void *data,void *user_data) { -struct bap_setup *setup = data; +struct bt_bap_stream *stream = data;struct sockaddr_iso_bc *addr = user_data; -char *path =bt_bap_stream_get_user_data (setup->stream); +char *path =bt_bap_stream_get_user_data (stream);int bis =1 ;int s_err;const char *strbis =NULL ;
@@ -3015,39 +2897,36 @@ static void append_setup(void *data, void *user_data)static void setup_refresh_qos (void *data,void *user_data) { -struct bap_setup *setup = data; +struct bt_bap_stream *stream = data; +struct bap_data *bap_data = user_data; +struct bap_setup *setup =bap_find_setup_by_stream (bap_data, stream); - setup->qos = *bt_bap_stream_get_qos (setup->stream); + setup->qos = *bt_bap_stream_get_qos (stream); }static void iso_do_big_sync (GIOChannel *io,void *user_data) {GError *err =NULL ; -struct bap_bcast_pa_req *req = user_data; -struct queue *setups = req->data.setups; -struct bap_setup *setup =queue_peek_head (setups); -struct bap_data *data = req->bap_data; +struct bap_setup *setup = user_data; +struct bap_data *data = setup->data;struct sockaddr_iso_bc iso_bc_addr = {0 };struct bt_iso_qos qos; +struct queue *links =bt_bap_stream_io_get_links (setup->stream);DBG ("PA Sync done" ); -if (req->io) { -g_io_channel_unref (req->io); -g_io_channel_shutdown (req->io, TRUE,NULL ); - req->io = io; -g_io_channel_ref (req->io); - } - - iso_bc_addr.bc_bdaddr_type =btd_device_get_bdaddr_type (data->device); -memcpy (&iso_bc_addr.bc_bdaddr,device_get_address (data->device), -sizeof (bdaddr_t)); +g_io_channel_unref (data->listen_io); +g_io_channel_shutdown (data->listen_io, TRUE,NULL ); + data->listen_io = io; +g_io_channel_ref (data->listen_io);/* Append each linked BIS to the BIG sync request */ -queue_foreach (setups, append_setup, &iso_bc_addr); +append_setup (setup->stream, &iso_bc_addr); +queue_foreach (links, append_setup, &iso_bc_addr);/* Refresh qos stored in setups */ -queue_foreach (setups, setup_refresh_qos,NULL ); + setup->qos = *bt_bap_stream_get_qos (setup->stream); +queue_foreach (links, setup_refresh_qos, data);/* Set the user requested QOS */ bap_qos_to_iso_qos (&setup->qos, &qos);
@@ -3061,7 +2940,7 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data)if (!bt_io_bcast_accept (io, iso_bcast_confirm_cb, - req,NULL , &err, + setup,NULL , &err,BT_IO_OPT_ISO_BC_NUM_BIS , iso_bc_addr.bc_num_bis,BT_IO_OPT_ISO_BC_BIS , iso_bc_addr.bc_bis,BT_IO_OPT_INVALID )) {
@@ -3070,28 +2949,16 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data) } } -static void pa_and_big_sync (struct bap_bcast_pa_req *req) +static void pa_and_big_sync (struct bap_setup *setup) {GError *err =NULL ; -struct bap_data *bap_data = req->bap_data; - - req->in_progress = TRUE; - -if (bap_data->listen_io) { -/* If there is an active listen io for the BAP session -* with the Broadcast Source, it means that PA sync is -* already established. Go straight to establishing BIG -* sync. -*/ -iso_do_big_sync (bap_data->listen_io, req); -return ; - } +struct bap_data *bap_data = setup->data;DBG ("Create PA sync with this source" ); - req->io = bt_io_listen(NULL, iso_do_big_sync, req, + bap_data->listen_io = bt_io_listen(NULL, iso_do_big_sync, setup, NULL, &err, BT_IO_OPT_SOURCE_BDADDR, - btd_adapter_get_address(bap_data->adapter->adapter), + btd_adapter_get_address(bap_data->adapter), BT_IO_OPT_DEST_BDADDR, device_get_address(bap_data->device), BT_IO_OPT_DEST_TYPE,
@@ -3099,26 +2966,17 @@ static void pa_and_big_sync(struct bap_bcast_pa_req *req)BT_IO_OPT_MODE ,BT_IO_MODE_ISO ,BT_IO_OPT_QOS , &bap_sink_pa_qos, BT_IO_OPT_INVALID); -if (!req->io) { +if (!bap_data->listen_io) {error ("%s" , err->message);g_error_free (err); } } -static bool match_bap_adapter (const void *data,const void *match_data) -{ -struct bap_adapter *adapter = (struct bap_adapter *)data; - -return adapter->adapter == match_data; -} -static int bap_bcast_probe (struct btd_service *service) {struct btd_device *device =btd_service_get_device (service);struct btd_adapter *adapter =device_get_adapter (device);struct btd_gatt_database *database =btd_adapter_get_database (adapter); -struct bap_bcast_pa_req *req; -uint8_t type =BAP_PA_LONG_REQ ;struct bap_data *data;int ret =0 ;
@@ -3127,27 +2985,10 @@ static int bap_bcast_probe(struct btd_service *service)return -ENOTSUP ; } - data =queue_find (sessions, match_device, device); -if (data && data->service) { -error ("Profile probed twice for the same device!" ); -return -EINVAL ; - } - -if (!data) { - data =bap_data_new (device); - data->device = device; -bap_data_add (data); - -/* The Broadcaster was scanned autonomously, -* so it should be probed short-lived. -*/ - type =BAP_PA_SHORT_REQ ; - } - + data =bap_data_new (device); data->service = service; -btd_service_set_user_data (service, data); - - data->adapter =queue_find (adapters, match_bap_adapter, adapter); + data->adapter = adapter; + data->device = device; data->bap =bt_bap_new (btd_gatt_database_get_db (database),btd_gatt_database_get_db (database));if (!data->bap) {
@@ -3155,9 +2996,6 @@ static int bap_bcast_probe(struct btd_service *service)free (data);return -EINVAL ; } - -bt_bap_set_debug (data->bap, bap_debug,NULL ,NULL ); - data->bcast_snks =queue_new ();if (!bt_bap_attach (data->bap,NULL )) {
@@ -3165,6 +3003,8 @@ static int bap_bcast_probe(struct btd_service *service)return -EINVAL ; } +bap_data_add (data); + data->ready_id =bt_bap_ready_register (data->bap, bap_ready, service,NULL ); data->state_id = bt_bap_state_register(data->bap, bap_state_bcast_sink,
@@ -3178,36 +3018,15 @@ static int bap_bcast_probe(struct btd_service *service)/* Return if probed device was handled inside BASS. */ return ret; -/* Start the PA timer if it hasn't been started yet */ -if (data->adapter->pa_timer_id ==0 ) - data->adapter->pa_timer_id =g_timeout_add_seconds ( -PA_IDLE_TIMEOUT , - pa_idle_timer, - data->adapter); - -/* Enqueue this device advertisement so that we can create PA sync. */ -DBG ("enqueue service: %p" , service); - req = new0(struct bap_bcast_pa_req, 1); - req->type = type; - req->in_progress = FALSE; - req->data.service = service; -queue_push_tail (data->adapter->bcast_pa_requests, req); +pa_sync (data);return 0 ; } -static bool match_service (const void *data,const void *match_data) -{ -struct bap_bcast_pa_req *req = (struct bap_bcast_pa_req *)data; - -return req->data.service == match_data; -} -static void bap_bcast_remove (struct btd_service *service) {struct btd_device *device =btd_service_get_device (service);struct bap_data *data; -struct bap_bcast_pa_req *req;char addr[18 ];ba2str (device_get_address (device), addr);
@@ -3218,17 +3037,6 @@ static void bap_bcast_remove(struct btd_service *service)error ("BAP service not handled by profile" );return ; } -/* Remove the corresponding entry from the pa_req queue. Any pa_req that -* are in progress will be stopped by bap_data_remove which calls -* bap_data_free. -*/ - req =queue_remove_if (data->adapter->bcast_pa_requests, - match_service, service); -if (req && req->io_id) { -g_source_remove (req->io_id); - req->io_id =0 ; - } -free (req);/* Notify the BASS plugin about the removed session. */ bass_bcast_remove (device);
@@ -3370,13 +3178,7 @@ static int bap_adapter_probe(struct btd_profile *p, struct btd_adapter *adapter)bt_bap_set_user_data (data->bap, adapter);bap_data_set_user_data (data, adapter); - data->adapter = new0(struct bap_adapter, 1); - data->adapter->adapter = adapter; - -if (adapters ==NULL ) - adapters =queue_new (); - data->adapter->bcast_pa_requests =queue_new (); -queue_push_tail (adapters, data->adapter); + data->adapter = adapter;return 0 ; }
@@ -3391,15 +3193,6 @@ static void bap_adapter_remove(struct btd_profile *p,ba2str (btd_adapter_get_address (adapter), addr);DBG ("%s" , addr); -queue_destroy (data->adapter->bcast_pa_requests, free); -queue_remove (adapters, data->adapter); -free (data->adapter); - -if (queue_isempty (adapters)) { -queue_destroy (adapters,NULL ); - adapters =NULL ; - } -if (!data) {error ("BAP service not handled by profile" );return ;
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 9 lines · On Wed, 20 Nov 2024 12:25:54 +0200 you wrote:
This patch reworks the Scan Delegator implementation in BASS, to manage BAP streams internally and leave BAP to just handle streams created by autonomous Broadcast Sink.
Thus, this also removes long-lived PA sync support from BAP and also the pa idle timer, since kernel support has been added to order PA/BIG sync requests.
[...]
Here is the summary with links:
- [BlueZ,v2,1/7] shared/bap: Add helper to parse BASE
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=a0aee49df1d8 - [BlueZ,v2,2/7] bap: Add helpers to convert iso_qos to/from bap_qos https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=8054693b0c5b - [BlueZ,v2,3/7] bap: Rework BASE parsing https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=66a83fde5c49 - [BlueZ,v2,4/7] bap: Make default PA sync QoS public https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=3babeefa17b6 - [BlueZ,v2,5/7] bass: Rework Scan Delegator to handle BAP streams https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=ac56526b7e39 - [BlueZ,v2,6/7] bap: Remove API to probe device from BASS https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=e618932b968f - [BlueZ,v2,7/7] bap: Remove PA idle timer logic https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=e59a915db9d8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html