Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions subsys/bluetooth/audio/bap_broadcast_sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ static void update_recv_state_big_cleared(const struct bt_bap_broadcast_sink *si
uint8_t reason)
{
const struct bt_bap_scan_delegator_recv_state *recv_state;
bool sink_is_streaming = false;
int err;

recv_state = bt_bap_scan_delegator_find_state(find_recv_state_by_src_id_cb, (void *)sink);
Expand All @@ -174,20 +173,26 @@ static void update_recv_state_big_cleared(const struct bt_bap_broadcast_sink *si
mod_src_param.encrypt_state = BT_BAP_BIG_ENC_STATE_NO_ENC;
}

/* Determine if the previous receive state reported that streaming was active
* If it was previously active, then we need to set the BIS_sync state to 0
* (not streaming), and if not then we consider this a BIG Sync failure and
* set BT_BAP_BIS_SYNC_FAILED
/* If we are currently not synced (bis_sync == 0U) then we set the BIS sync to
* BT_BAP_BIS_SYNC_FAILED to indicate a sync failure, unless the reason is
* BT_HCI_ERR_TERM_DUE_TO_MIC_FAIL (indicating a bad broadcast code). We treat this as a
* special case due to current open errata https://bluetooth.atlassian.net/browse/ES-28435
* and https://bluetooth.atlassian.net/browse/ES-28482 where the expected behavior is not
* properly defined but the qualification tests expect the BIS sync value to be set to 0 in
* case of a bad broadcast code.
*
* If we are already synced and this is called, then that indicates a sync lost, in which
* case we set the BIS sync to 0.
*/
for (uint8_t i = 0U; i < recv_state->num_subgroups && !sink_is_streaming; i++) {
sink_is_streaming = recv_state->subgroups[i].bis_sync != 0 &&
recv_state->subgroups[i].bis_sync != BT_BAP_BIS_SYNC_FAILED;
}

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

Expand Down
6 changes: 4 additions & 2 deletions subsys/bluetooth/audio/bap_scan_delegator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1126,8 +1126,10 @@

state = &internal_state->state;

if (internal_state->pa_sync_requested) {
LOG_DBG("Cannot remove source ID 0x%02x while PA is synced or syncing",
if (internal_state->pa_sync_requested ||
state->pa_sync_state == BT_BAP_PA_STATE_INFO_REQ ||
state->pa_sync_state == BT_BAP_PA_STATE_SYNCED) {

Check notice on line 1131 in subsys/bluetooth/audio/bap_scan_delegator.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/bluetooth/audio/bap_scan_delegator.c:1131 - if (internal_state->pa_sync_requested || - state->pa_sync_state == BT_BAP_PA_STATE_INFO_REQ || + if (internal_state->pa_sync_requested || state->pa_sync_state == BT_BAP_PA_STATE_INFO_REQ || See https://docs.zephyrproject.org/latest/contribute/guidelines.html#clang-format for more details.
LOG_DBG("Cannot remove source ID 0x%02x while PA is syncing or synced",

Check warning on line 1132 in subsys/bluetooth/audio/bap_scan_delegator.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

use of GNU statement expression extension from macro expansion

See more on https://sonarcloud.io/project/issues?id=nrfconnect_sdk-zephyr&issues=AZ5FdOOTEff-qLKNUgbG&open=AZ5FdOOTEff-qLKNUgbG&pullRequest=4094
state->src_id);
err = k_mutex_unlock(&internal_state->mutex);
__ASSERT(err == 0, "Failed to unlock mutex: %d", err);
Expand Down
4 changes: 2 additions & 2 deletions tests/bsim/bluetooth/audio/src/bap_broadcast_assistant_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ static void bap_broadcast_assistant_recv_state_cb(
for (uint8_t i = 0; i < state->num_subgroups; i++) {
const struct bt_bap_bass_subgroup *subgroup = &state->subgroups[i];

if (subgroup->bis_sync != BT_BAP_BIS_SYNC_FAILED) {
FAIL("Invalid BIS sync value 0x%08X for failed sync\n",
if (subgroup->bis_sync != 0U) {
FAIL("Invalid BIS sync value 0x%08X for bad broadcast code\n",
subgroup->bis_sync);
return;
}
Expand Down
Loading