This removes the BASS add/remove stream APIs and uses shared/bap to register BIS probe/remove callbacks instead, to avoid making direct calls between plugins. --- profiles/audio/bap.c | 6 +++--- profiles/audio/bass.c | 22 +++++++++++++++++----- profiles/audio/bass.h | 5 ----- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index b36e45ea4..37168e58c 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -1178,7 +1178,7 @@ static void bis_handler(uint8_t bis, uint8_t sgrp, struct iovec *caps, struct bt_bap_pac *lpac; char *path; - bass_add_stream(data->device, meta, caps, qos, sgrp, bis); + bt_bap_bis_probe(data->bap, bis, sgrp, caps, meta, qos); /* Check if this BIS matches any local PAC */ bt_bap_verify_bis(data->bap, bis, @@ -3128,9 +3128,9 @@ static void bap_bcast_remove(struct btd_service *service) return; } - bap_data_remove(data); + bt_bap_bis_remove(data->bap); - bass_remove_stream(device); + bap_data_remove(data); } static int bap_probe(struct btd_service *service) diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c index 96e767744..f5fe60652 100644 --- a/profiles/audio/bass.c +++ b/profiles/audio/bass.c @@ -86,6 +86,7 @@ struct bass_data { struct bt_bass *bass; unsigned int src_id; unsigned int cp_id; + unsigned int bis_id; }; struct bass_assistant { @@ -141,6 +142,11 @@ static struct bass_data *bass_data_new(struct btd_device *device); static void bass_data_add(struct bass_data *data); static void bass_data_remove(struct bass_data *data); +static void bis_probe(uint8_t bis, uint8_t sgrp, struct iovec *caps, + struct iovec *meta, struct bt_bap_qos *qos, void *user_data); +static void bis_remove(struct bt_bap *bap, void *user_data); + + static void bass_debug(const char *str, void *user_data) { DBG_IDX(0xffff, "%s", str); @@ -590,6 +596,8 @@ static void bap_attached(struct bt_bap *bap, void *user_data) /* Create BASS session with the Broadcast Source */ data = bass_data_new(device); + data->bis_id = bt_bap_bis_cb_register(bap, bis_probe, + bis_remove, device, NULL); bass_data_add(data); @@ -678,8 +686,10 @@ static void bap_detached(struct bt_bap *bap, void *user_data) /* Remove BASS session with the Broadcast Source device */ data = queue_find(sessions, match_device, device); - if (data) + if (data) { + bt_bap_bis_cb_unregister(bap, data->bis_id); bass_data_remove(data); + } dg = queue_remove_if(delegators, delegator_match_device, device); if (!dg) @@ -1077,10 +1087,10 @@ static struct bass_assistant *assistant_new(struct btd_adapter *adapter, return assistant; } -void bass_add_stream(struct btd_device *device, struct iovec *meta, - struct iovec *caps, struct bt_bap_qos *qos, - uint8_t sgrp, uint8_t bis) +static void bis_probe(uint8_t bis, uint8_t sgrp, struct iovec *caps, + struct iovec *meta, struct bt_bap_qos *qos, void *user_data) { + struct btd_device *device = user_data; const struct queue_entry *entry; struct bt_bap *bap; struct bt_bap_pac *pac; @@ -1142,8 +1152,10 @@ static void unregister_assistant(void *data) assistant->path, MEDIA_ASSISTANT_INTERFACE); } -void bass_remove_stream(struct btd_device *device) +static void bis_remove(struct bt_bap *bap, void *user_data) { + struct btd_device *device = user_data; + queue_remove_all(assistants, assistant_match_device, device, unregister_assistant); } diff --git a/profiles/audio/bass.h b/profiles/audio/bass.h index 99b755259..42a2c047f 100644 --- a/profiles/audio/bass.h +++ b/profiles/audio/bass.h @@ -7,11 +7,6 @@ * */ -void bass_add_stream(struct btd_device *device, struct iovec *meta, - struct iovec *caps, struct bt_bap_qos *qos, - uint8_t sgrp, uint8_t bis); -void bass_remove_stream(struct btd_device *device); - typedef void (*bt_bass_bcode_func_t)(void *user_data, int err); void bass_req_bcode(struct bt_bap_stream *stream, -- 2.43.0