Skip to content

Commit 5746852

Browse files
Thalleyjhedberg
authored andcommitted
tests: Bluetooth: CAP: Test bt_cap_unicast_group_get_info
Add an additional step when doing CAP unicast tests where we validate that the presentation delay set for each stream match the presentation delay from bt_bap_unicast_group_get_info via the BAP unicast group pointer retrieved via bt_cap_unicast_group_get_info. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 29f5628 commit 5746852

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

tests/bsim/bluetooth/audio/src/cap_initiator_unicast_test.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,50 @@ static void unicast_group_create(struct bt_cap_unicast_group **out_unicast_group
644644
}
645645
}
646646

647+
static bool unicast_group_foreach_stream_cb(struct bt_cap_stream *cap_stream, void *user_data)
648+
{
649+
const uint32_t expected_pd = cap_stream->bap_stream.qos->pd;
650+
struct bt_cap_unicast_group *unicast_group = user_data;
651+
struct bt_bap_unicast_group_info bap_info;
652+
struct bt_cap_unicast_group_info cap_info;
653+
struct bt_bap_ep_info ep_info;
654+
int err;
655+
656+
err = bt_bap_ep_get_info(cap_stream->bap_stream.ep, &ep_info);
657+
if (err != 0) {
658+
FAIL("Failed to get EP info: %d\n", err);
659+
return true;
660+
}
661+
662+
err = bt_cap_unicast_group_get_info(unicast_group, &cap_info);
663+
if (err != 0) {
664+
FAIL("Failed to get CAP unicast group info: %d\n", err);
665+
return true;
666+
}
667+
668+
err = bt_bap_unicast_group_get_info(cap_info.unicast_group, &bap_info);
669+
if (err != 0) {
670+
FAIL("Failed to get BAP unicast group info: %d\n", err);
671+
return true;
672+
}
673+
674+
if (ep_info.dir == BT_AUDIO_DIR_SINK) {
675+
if (bap_info.sink_pd != expected_pd) {
676+
FAIL("Unexpected sink PD %u (expected %u)\n", bap_info.sink_pd,
677+
expected_pd);
678+
return true;
679+
}
680+
} else {
681+
if (bap_info.source_pd != expected_pd) {
682+
FAIL("Unexpected source PD %u (expected %u)\n", bap_info.source_pd,
683+
expected_pd);
684+
return true;
685+
}
686+
}
687+
688+
return false;
689+
}
690+
647691
static void unicast_audio_start(struct bt_cap_unicast_group *unicast_group, bool wait)
648692
{
649693
struct bt_cap_unicast_audio_start_stream_param stream_param[2];
@@ -676,6 +720,13 @@ static void unicast_audio_start(struct bt_cap_unicast_group *unicast_group, bool
676720
WAIT_FOR_FLAG(flag_started);
677721
/* let other devices know we have started what we wanted */
678722
backchannel_sync_send_all();
723+
724+
err = bt_cap_unicast_group_foreach_stream(
725+
unicast_group, unicast_group_foreach_stream_cb, unicast_group);
726+
if (err != 0) {
727+
FAIL("Failed iterate on unicast group: %d\n", err);
728+
return;
729+
}
679730
}
680731
}
681732

0 commit comments

Comments
 (0)