From f58bea6b7bddba8b06c9ca9fcc4ebb04b361aaad Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Mon, 16 Oct 2023 13:29:12 +0200 Subject: [PATCH] Bluetooth: BAP: Scan Delegator bis_sync_req cb called on rem If a receive state is removed, then the bis_syn_req callback will be called with 0x00000000, to indicate to the application that the sink should be desynced. Signed-off-by: Emil Gydesen --- include/zephyr/bluetooth/audio/bap.h | 4 +++- subsys/bluetooth/audio/bap_scan_delegator.c | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/zephyr/bluetooth/audio/bap.h b/include/zephyr/bluetooth/audio/bap.h index 1436f38494e..77c63ba598b 100644 --- a/include/zephyr/bluetooth/audio/bap.h +++ b/include/zephyr/bluetooth/audio/bap.h @@ -406,7 +406,9 @@ struct bt_bap_scan_delegator_cb { * requested for the sync. * @param[in] bis_sync_req Array of bitfields of which BIS indexes * that is requested to sync for each subgroup - * by the Broadcast Assistant. + * by the Broadcast Assistant. A value of 0 + * indicates a request to terminate the BIG + * sync. * * @return 0 in case of accept, or other value to reject. */ diff --git a/subsys/bluetooth/audio/bap_scan_delegator.c b/subsys/bluetooth/audio/bap_scan_delegator.c index 19d33997453..f23c438099d 100644 --- a/subsys/bluetooth/audio/bap_scan_delegator.c +++ b/subsys/bluetooth/audio/bap_scan_delegator.c @@ -830,6 +830,7 @@ static int scan_delegator_rem_src(struct bt_conn *conn, { struct bass_recv_state_internal *internal_state; struct bt_bap_scan_delegator_recv_state *state; + bool bis_sync_was_requested; uint8_t src_id; /* subtract 1 as the opcode has already been pulled */ @@ -862,6 +863,14 @@ static int scan_delegator_rem_src(struct bt_conn *conn, } } + bis_sync_was_requested = false; + for (uint8_t i = 0U; i < state->num_subgroups; i++) { + if (internal_state->requested_bis_sync[i] != 0U) { + bis_sync_was_requested = true; + break; + } + } + LOG_DBG("Index %u: Removed source with ID 0x%02x", internal_state->index, src_id); @@ -873,6 +882,9 @@ static int scan_delegator_rem_src(struct bt_conn *conn, (void)memset(internal_state->requested_bis_sync, 0, sizeof(internal_state->requested_bis_sync)); + if (bis_sync_was_requested) { + bis_sync_request_updated(conn, internal_state); + } receive_state_updated(conn, internal_state); return 0;