Skip to content

Commit 355a552

Browse files
pin-zephyrkartben
authored andcommitted
Bluetooth: Audio: fix BIS_Sync_State for BASS server
BASS server need to notify that both BIS and PA are no longer synced by setting all required fields to 0 after client stops BIS by sending a BIG control PDU with a BIG TERMINATED indication. meanwhile BIG_Encryption in the notification should also be reset to be BT_BAP_BIG_ENC_STATE_NO_ENC when BIS is not synced anymore. Signed-off-by: Ping Wang <pinw@demant.com>
1 parent 8c3e937 commit 355a552

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

subsys/bluetooth/audio/bap_broadcast_sink.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ static void update_recv_state_big_cleared(const struct bt_bap_broadcast_sink *si
153153
uint8_t reason)
154154
{
155155
const struct bt_bap_scan_delegator_recv_state *recv_state;
156+
bool sink_is_streaming = false;
156157
int err;
157158

158159
recv_state = bt_bap_scan_delegator_find_state(find_recv_state_by_sink_cb, (void *)sink);
@@ -171,10 +172,21 @@ static void update_recv_state_big_cleared(const struct bt_bap_broadcast_sink *si
171172
/* Sync failed due to bad broadcast code */
172173
mod_src_param.encrypt_state = BT_BAP_BIG_ENC_STATE_BAD_CODE;
173174
} else {
174-
mod_src_param.encrypt_state = recv_state->encrypt_state;
175+
mod_src_param.encrypt_state = BT_BAP_BIG_ENC_STATE_NO_ENC;
176+
}
177+
178+
/* Determine if the previous receive state reported that streaming was active
179+
* If it was previously active, then we need to set the BIS_sync state to 0
180+
* (not streaming), and if not then we consider this a BIG Sync failure and
181+
* set BT_BAP_BIS_SYNC_FAILED
182+
*/
183+
for (uint8_t i = 0U; i < recv_state->num_subgroups && !sink_is_streaming; i++) {
184+
sink_is_streaming = recv_state->subgroups[i].bis_sync != 0 &&
185+
recv_state->subgroups[i].bis_sync != BT_BAP_BIS_SYNC_FAILED;
175186
}
176187

177-
if (reason != BT_HCI_ERR_LOCALHOST_TERM_CONN) {
188+
if (!sink_is_streaming) {
189+
/* BASS spec 3.1.1.5: Set Sync Failed when the server fails to sync to the BIG */
178190
for (uint8_t i = 0U; i < recv_state->num_subgroups; i++) {
179191
mod_src_param.subgroups[i].bis_sync = BT_BAP_BIS_SYNC_FAILED;
180192
}

0 commit comments

Comments
 (0)