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
18 changes: 17 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_stream_stopped, 0U, CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT);

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

static void send_bis_stream_received_ev(const bt_addr_le_t *address, uint32_t broadcast_id,
Expand Down Expand Up @@ -327,6 +330,8 @@ uint8_t btp_bap_broadcast_source_setup(const void *cmd, uint16_t cmd_len,
source->qos.pd = sys_get_le24(cp->presentation_delay);
source->qos.sdu = sys_le16_to_cpu(cp->max_sdu);

source->stream_count = cp->subgroups * cp->streams_per_subgroup;

err = setup_broadcast_source(cp->streams_per_subgroup, cp->subgroups, source, &codec_cfg);
if (err != 0) {
LOG_DBG("Unable to setup broadcast source: %d", err);
Expand Down Expand Up @@ -484,13 +489,24 @@ uint8_t btp_bap_broadcast_source_stop(const void *cmd, uint16_t cmd_len,

LOG_DBG("");

k_sem_reset(&sem_stream_stopped);

err = bt_bap_broadcast_source_stop(source->bap_broadcast);
if (err != 0) {
LOG_DBG("Unable to stop broadcast source: %d", err);

return BTP_STATUS_FAILED;
}

for (int i = 0; i < source->stream_count; i++) {
err = k_sem_take(&sem_stream_stopped, K_MSEC(1000));
if (err != 0) {
LOG_DBG("Timed out waiting for stream nr %d to stop", i);

return BTP_STATUS_FAILED;
}
}

return BTP_STATUS_SUCCESS;
}

Expand Down
1 change: 1 addition & 0 deletions tests/bluetooth/tester/src/audio/btp_bap_broadcast.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct btp_bap_broadcast_local_source {
struct bt_audio_codec_qos qos;
struct btp_bap_broadcast_stream streams[CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT];
struct bt_audio_codec_cfg subgroup_codec_cfg[CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT];
uint8_t stream_count;
/* Only for BTP BAP commands */
struct bt_bap_broadcast_source *bap_broadcast;
/* Only for BTP CAP commands */
Expand Down
Loading