diff --git a/tests/bluetooth/tester/src/audio/btp_bap_broadcast.c b/tests/bluetooth/tester/src/audio/btp_bap_broadcast.c index b5243202c058d1..c7f4a4eaaf28a3 100644 --- a/tests/bluetooth/tester/src/audio/btp_bap_broadcast.c +++ b/tests/bluetooth/tester/src/audio/btp_bap_broadcast.c @@ -23,6 +23,8 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_BTTESTER_LOG_LEVEL); #include "btp_bap_audio_stream.h" #include "btp_bap_broadcast.h" +static K_SEM_DEFINE(sem_bis_stopped, 0U, 1); + static struct btp_bap_broadcast_remote_source remote_broadcast_sources[1]; static struct btp_bap_broadcast_local_source local_source; /* Only one PA sync supported for now. */ @@ -132,8 +134,9 @@ static void stream_stopped(struct bt_bap_stream *stream, uint8_t reason) LOG_DBG("Stopped stream %p with reason 0x%02X", stream, reason); btp_bap_audio_stream_stopped(&b_stream->audio_stream); - b_stream->bis_synced = false; + + k_sem_give(&sem_bis_stopped); } static void send_bis_stream_received_ev(const bt_addr_le_t *address, uint32_t broadcast_id, @@ -484,6 +487,8 @@ uint8_t btp_bap_broadcast_source_stop(const void *cmd, uint16_t cmd_len, LOG_DBG(""); + k_sem_reset(&sem_bis_stopped) + err = bt_bap_broadcast_source_stop(source->bap_broadcast); if (err != 0) { LOG_DBG("Unable to stop broadcast source: %d", err); @@ -491,6 +496,13 @@ uint8_t btp_bap_broadcast_source_stop(const void *cmd, uint16_t cmd_len, return BTP_STATUS_FAILED; } + err = k_sem_take(&sem_bis_stopped, K_MSEC(2000)); + if (err != 0) { + LOG_DBG("Timed out waiting to stop BIS stream"); + + return BTP_STATUS_FAILED; + } + return BTP_STATUS_SUCCESS; }