@@ -24,12 +24,12 @@ NET_BUF_POOL_FIXED_DEFINE(tx_pool, TOTAL_BUF_NEEDED, BT_ISO_SDU_BUF_SIZE(CONFIG_
24
24
extern enum bst_result_t bst_result ;
25
25
26
26
static volatile size_t sent_count ;
27
- static struct bap_test_stream g_streams [CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT ];
27
+ static struct audio_test_stream test_streams [CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT ];
28
28
static struct bt_bap_ep * g_sinks [CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT ];
29
29
static struct bt_bap_ep * g_sources [CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT ];
30
30
31
- static struct bt_bap_unicast_group_stream_pair_param pair_params [ARRAY_SIZE (g_streams )];
32
- static struct bt_bap_unicast_group_stream_param stream_params [ARRAY_SIZE (g_streams )];
31
+ static struct bt_bap_unicast_group_stream_pair_param pair_params [ARRAY_SIZE (test_streams )];
32
+ static struct bt_bap_unicast_group_stream_param stream_params [ARRAY_SIZE (test_streams )];
33
33
34
34
/* Mandatory support preset by both client and server */
35
35
static struct bt_bap_lc3_preset preset_16_2_1 = BT_BAP_LC3_UNICAST_PRESET_16_2_1 (
@@ -63,7 +63,7 @@ static void stream_configured(struct bt_bap_stream *stream,
63
63
64
64
static void stream_qos_set (struct bt_bap_stream * stream )
65
65
{
66
- struct bap_test_stream * test_stream = CONTAINER_OF ( stream , struct bap_test_stream , stream );
66
+ struct audio_test_stream * test_stream = audio_test_stream_from_bap_stream ( stream );
67
67
68
68
printk ("QoS set stream %p\n" , stream );
69
69
@@ -95,7 +95,7 @@ static void stream_metadata_updated(struct bt_bap_stream *stream)
95
95
96
96
static void stream_disabled (struct bt_bap_stream * stream )
97
97
{
98
- struct bap_test_stream * test_stream = CONTAINER_OF ( stream , struct bap_test_stream , stream );
98
+ struct audio_test_stream * test_stream = audio_test_stream_from_bap_stream ( stream );
99
99
100
100
test_stream -> tx_active = false;
101
101
@@ -119,7 +119,7 @@ static void stream_released(struct bt_bap_stream *stream)
119
119
static void stream_recv_cb (struct bt_bap_stream * stream , const struct bt_iso_recv_info * info ,
120
120
struct net_buf * buf )
121
121
{
122
- struct bap_test_stream * test_stream = CONTAINER_OF ( stream , struct bap_test_stream , stream );
122
+ struct audio_test_stream * test_stream = audio_test_stream_from_bap_stream ( stream );
123
123
124
124
printk ("Incoming audio on stream %p len %u and ts %u\n" , stream , buf -> len , info -> ts );
125
125
@@ -152,7 +152,7 @@ static void stream_recv_cb(struct bt_bap_stream *stream, const struct bt_iso_rec
152
152
153
153
static void stream_sent_cb (struct bt_bap_stream * stream )
154
154
{
155
- struct bap_test_stream * test_stream = CONTAINER_OF ( stream , struct bap_test_stream , stream );
155
+ struct audio_test_stream * test_stream = audio_test_stream_from_bap_stream ( stream );
156
156
struct net_buf * buf ;
157
157
int ret ;
158
158
@@ -489,8 +489,11 @@ static void init(void)
489
489
return ;
490
490
}
491
491
492
- for (size_t i = 0 ; i < ARRAY_SIZE (g_streams ); i ++ ) {
493
- g_streams [i ].stream .ops = & stream_ops ;
492
+ for (size_t i = 0 ; i < ARRAY_SIZE (test_streams ); i ++ ) {
493
+ struct bt_bap_stream * bap_stream =
494
+ bap_stream_from_audio_test_stream (& test_streams [i ]);
495
+
496
+ bap_stream -> ops = & stream_ops ;
494
497
}
495
498
496
499
bt_le_scan_cb_register (& bap_scan_cb );
@@ -674,7 +677,7 @@ static int enable_stream(struct bt_bap_stream *stream)
674
677
static void enable_streams (size_t stream_cnt )
675
678
{
676
679
for (size_t i = 0U ; i < stream_cnt ; i ++ ) {
677
- struct bt_bap_stream * stream = & g_streams [i ]. stream ;
680
+ struct bt_bap_stream * stream = bap_stream_from_audio_test_stream ( & test_streams [i ]) ;
678
681
int err ;
679
682
680
683
err = enable_stream (stream );
@@ -713,7 +716,7 @@ static int metadata_update_stream(struct bt_bap_stream *stream)
713
716
static void metadata_update_streams (size_t stream_cnt )
714
717
{
715
718
for (size_t i = 0U ; i < stream_cnt ; i ++ ) {
716
- struct bt_bap_stream * stream = & g_streams [i ]. stream ;
719
+ struct bt_bap_stream * stream = bap_stream_from_audio_test_stream ( & test_streams [i ]) ;
717
720
int err ;
718
721
719
722
err = metadata_update_stream (stream );
@@ -788,8 +791,8 @@ static void transceive_streams(void)
788
791
sink_stream = pair_params [0 ].tx_param == NULL ? NULL : pair_params [0 ].tx_param -> stream ;
789
792
790
793
if (sink_stream != NULL ) {
791
- struct bap_test_stream * test_stream =
792
- CONTAINER_OF (sink_stream , struct bap_test_stream , stream );
794
+ struct audio_test_stream * test_stream =
795
+ audio_test_stream_from_bap_stream (sink_stream );
793
796
794
797
test_stream -> tx_active = true;
795
798
for (unsigned int i = 0U ; i < ENQUEUE_COUNT ; i ++ ) {
@@ -803,8 +806,8 @@ static void transceive_streams(void)
803
806
}
804
807
805
808
if (source_stream != NULL ) {
806
- const struct bap_test_stream * test_stream =
807
- CONTAINER_OF (source_stream , struct bap_test_stream , stream );
809
+ const struct audio_test_stream * test_stream =
810
+ audio_test_stream_from_bap_stream (source_stream );
808
811
809
812
/* Keep receiving until we reach the minimum expected */
810
813
while (test_stream -> rx_cnt < MIN_SEND_COUNT ) {
@@ -822,7 +825,8 @@ static void disable_streams(size_t stream_cnt)
822
825
UNSET_FLAG (flag_stream_disabled );
823
826
824
827
do {
825
- err = bt_bap_stream_disable (& g_streams [i ].stream );
828
+ err = bt_bap_stream_disable (
829
+ bap_stream_from_audio_test_stream (& test_streams [i ]));
826
830
if (err == - EBUSY ) {
827
831
k_sleep (BAP_STREAM_RETRY_WAIT );
828
832
} else if (err != 0 ) {
@@ -845,7 +849,8 @@ static void release_streams(size_t stream_cnt)
845
849
UNSET_FLAG (flag_stream_released );
846
850
847
851
do {
848
- err = bt_bap_stream_release (& g_streams [i ].stream );
852
+ err = bt_bap_stream_release (
853
+ bap_stream_from_audio_test_stream (& test_streams [i ]));
849
854
if (err == - EBUSY ) {
850
855
k_sleep (BAP_STREAM_RETRY_WAIT );
851
856
} else if (err != 0 ) {
@@ -869,12 +874,13 @@ static size_t create_unicast_group(struct bt_bap_unicast_group **unicast_group)
869
874
memset (stream_params , 0 , sizeof (stream_params ));
870
875
memset (pair_params , 0 , sizeof (pair_params ));
871
876
872
- for (size_t i = 0U ; i < MIN (ARRAY_SIZE (g_sinks ), ARRAY_SIZE (g_streams )); i ++ ) {
877
+ for (size_t i = 0U ; i < MIN (ARRAY_SIZE (g_sinks ), ARRAY_SIZE (test_streams )); i ++ ) {
873
878
if (g_sinks [i ] == NULL ) {
874
879
break ;
875
880
}
876
881
877
- stream_params [stream_cnt ].stream = & g_streams [stream_cnt ].stream ;
882
+ stream_params [stream_cnt ].stream =
883
+ bap_stream_from_audio_test_stream (& test_streams [stream_cnt ]);
878
884
stream_params [stream_cnt ].qos = & preset_16_2_1 .qos ;
879
885
pair_params [i ].tx_param = & stream_params [stream_cnt ];
880
886
@@ -883,12 +889,13 @@ static size_t create_unicast_group(struct bt_bap_unicast_group **unicast_group)
883
889
break ;
884
890
}
885
891
886
- for (size_t i = 0U ; i < MIN (ARRAY_SIZE (g_sources ), ARRAY_SIZE (g_streams )); i ++ ) {
892
+ for (size_t i = 0U ; i < MIN (ARRAY_SIZE (g_sources ), ARRAY_SIZE (test_streams )); i ++ ) {
887
893
if (g_sources [i ] == NULL ) {
888
894
break ;
889
895
}
890
896
891
- stream_params [stream_cnt ].stream = & g_streams [stream_cnt ].stream ;
897
+ stream_params [stream_cnt ].stream =
898
+ bap_stream_from_audio_test_stream (& test_streams [stream_cnt ]);
892
899
stream_params [stream_cnt ].qos = & preset_16_2_1 .qos ;
893
900
pair_params [i ].rx_param = & stream_params [stream_cnt ];
894
901
0 commit comments