Skip to content

Commit a7265d9

Browse files
committed
[nrf fromtree] tests: bluetooth: tester: Make brcst_source_stop synchronous
- Add semaphore to make sure source is stopped before proceeding - This ensures source can be released after this command is finished Signed-off-by: Alexander Svensen <[email protected]> (cherry picked from commit 6d19fc2)
1 parent 6a86b8f commit a7265d9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_BTTESTER_LOG_LEVEL);
2222

2323
static struct btp_bap_unicast_group *u_group;
2424

25+
static K_SEM_DEFINE(source_stopped_sem, 0U, CONFIG_BT_BAP_BROADCAST_SRC_COUNT);
26+
2527
extern struct bt_csip_set_coordinator_set_member *btp_csip_set_members[CONFIG_BT_MAX_CONN];
2628

2729
static struct bt_bap_stream *stream_unicast_to_bap(struct btp_bap_unicast_stream *stream)
@@ -139,11 +141,19 @@ static void unicast_stop_complete_cb(int err, struct bt_conn *conn)
139141
BTP_CAP_UNICAST_START_STATUS_SUCCESS);
140142
}
141143

144+
static void broadcast_stopped_cb(struct bt_cap_broadcast_source *source, uint8_t reason)
145+
{
146+
LOG_DBG("");
147+
148+
k_sem_give(&source_stopped_sem);
149+
}
150+
142151
static struct bt_cap_initiator_cb cap_cb = {
143152
.unicast_discovery_complete = cap_discovery_complete_cb,
144153
.unicast_start_complete = unicast_start_complete_cb,
145154
.unicast_update_complete = unicast_update_complete_cb,
146155
.unicast_stop_complete = unicast_stop_complete_cb,
156+
.broadcast_stopped = broadcast_stopped_cb,
147157
};
148158

149159
static uint8_t btp_cap_supported_commands(const void *cmd, uint16_t cmd_len,
@@ -804,6 +814,14 @@ static uint8_t btp_cap_broadcast_source_stop(const void *cmd, uint16_t cmd_len,
804814
return BTP_STATUS_FAILED;
805815
}
806816

817+
/* Make sure source is stopped before proceeding */
818+
err = k_sem_take(&source_stopped_sem, K_SECONDS(1));
819+
if (err) {
820+
LOG_ERR("Semaphore timed out: %d", err);
821+
822+
return BTP_STATUS_FAILED;
823+
}
824+
807825
return BTP_STATUS_SUCCESS;
808826
}
809827

0 commit comments

Comments
 (0)