Skip to content

Commit

Permalink
bluetooth: tester: audio: Add verification for bis stopping
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Frodevan committed Oct 3, 2024
1 parent 9655c2f commit 9ac715f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/bluetooth/tester/src/audio/btp_bap_broadcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -484,13 +487,22 @@ 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) {

Check notice on line 493 in tests/bluetooth/tester/src/audio/btp_bap_broadcast.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

tests/bluetooth/tester/src/audio/btp_bap_broadcast.c:493 - err = bt_bap_broadcast_source_stop(source->bap_broadcast); + err = bt_bap_broadcast_source_stop(source->bap_broadcast);
LOG_DBG("Unable to stop broadcast source: %d", err);

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;
}

Expand Down

0 comments on commit 9ac715f

Please sign in to comment.