Skip to content

Commit 29b78ab

Browse files
Frodevancarlescufi
authored andcommitted
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 <[email protected]>
1 parent d41fefe commit 29b78ab

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

tests/bluetooth/tester/src/audio/btp_bap_broadcast.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_BTTESTER_LOG_LEVEL);
2323
#include "btp_bap_audio_stream.h"
2424
#include "btp_bap_broadcast.h"
2525

26+
static K_SEM_DEFINE(sem_stream_stopped, 0U, CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT);
27+
2628
static struct btp_bap_broadcast_remote_source remote_broadcast_sources[1];
2729
static struct btp_bap_broadcast_local_source local_source;
2830
/* Only one PA sync supported for now. */
@@ -132,8 +134,9 @@ static void stream_stopped(struct bt_bap_stream *stream, uint8_t reason)
132134
LOG_DBG("Stopped stream %p with reason 0x%02X", stream, reason);
133135

134136
btp_bap_audio_stream_stopped(&b_stream->audio_stream);
135-
136137
b_stream->bis_synced = false;
138+
139+
k_sem_give(&sem_stream_stopped);
137140
}
138141

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

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

485490
LOG_DBG("");
486491

492+
k_sem_reset(&sem_stream_stopped);
493+
487494
err = bt_bap_broadcast_source_stop(source->bap_broadcast);
488495
if (err != 0) {
489496
LOG_DBG("Unable to stop broadcast source: %d", err);
490497

491498
return BTP_STATUS_FAILED;
492499
}
493500

501+
for (int i = 0; i < source->stream_count; i++) {
502+
err = k_sem_take(&sem_stream_stopped, K_MSEC(1000));
503+
if (err != 0) {
504+
LOG_DBG("Timed out waiting for stream nr %d to stop", i);
505+
506+
return BTP_STATUS_FAILED;
507+
}
508+
}
509+
494510
return BTP_STATUS_SUCCESS;
495511
}
496512

tests/bluetooth/tester/src/audio/btp_bap_broadcast.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct btp_bap_broadcast_local_source {
4545
struct bt_bap_qos_cfg qos;
4646
struct btp_bap_broadcast_stream streams[CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT];
4747
struct bt_audio_codec_cfg subgroup_codec_cfg[CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT];
48+
uint8_t stream_count;
4849
/* Only for BTP BAP commands */
4950
struct bt_bap_broadcast_source *bap_broadcast;
5051
/* Only for BTP CAP commands */

0 commit comments

Comments
 (0)