From f6ab1bedd1f8f2b59cda43678e4edd688d04852c Mon Sep 17 00:00:00 2001 From: Frode van der Meeren Date: Thu, 3 Oct 2024 12:33:51 +0200 Subject: [PATCH] bluetooth: tester: audio: Add verification for bis stopping Adds a semaphor to make sure the stream has properly been stopped by the controller before returning from btp_bap_broadcast_source_stop. Signed-off-by: Frode van der Meeren --- .../bluetooth/tester/src/audio/btp_bap_broadcast.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/bluetooth/tester/src/audio/btp_bap_broadcast.c b/tests/bluetooth/tester/src/audio/btp_bap_broadcast.c index b5243202c058d1..2ba82979c46e61 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; }