@@ -24,12 +24,12 @@ NET_BUF_POOL_FIXED_DEFINE(tx_pool, TOTAL_BUF_NEEDED, BT_ISO_SDU_BUF_SIZE(CONFIG_
2424extern enum bst_result_t bst_result ;
2525
2626static 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 ];
2828static struct bt_bap_ep * g_sinks [CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT ];
2929static struct bt_bap_ep * g_sources [CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT ];
3030
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 )];
3333
3434/* Mandatory support preset by both client and server */
3535static 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,
6363
6464static void stream_qos_set (struct bt_bap_stream * stream )
6565{
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 );
6767
6868 printk ("QoS set stream %p\n" , stream );
6969
@@ -95,7 +95,7 @@ static void stream_metadata_updated(struct bt_bap_stream *stream)
9595
9696static void stream_disabled (struct bt_bap_stream * stream )
9797{
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 );
9999
100100 test_stream -> tx_active = false;
101101
@@ -119,7 +119,7 @@ static void stream_released(struct bt_bap_stream *stream)
119119static void stream_recv_cb (struct bt_bap_stream * stream , const struct bt_iso_recv_info * info ,
120120 struct net_buf * buf )
121121{
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 );
123123
124124 printk ("Incoming audio on stream %p len %u and ts %u\n" , stream , buf -> len , info -> ts );
125125
@@ -152,7 +152,7 @@ static void stream_recv_cb(struct bt_bap_stream *stream, const struct bt_iso_rec
152152
153153static void stream_sent_cb (struct bt_bap_stream * stream )
154154{
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 );
156156 struct net_buf * buf ;
157157 int ret ;
158158
@@ -489,8 +489,11 @@ static void init(void)
489489 return ;
490490 }
491491
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 ;
494497 }
495498
496499 bt_le_scan_cb_register (& bap_scan_cb );
@@ -674,7 +677,7 @@ static int enable_stream(struct bt_bap_stream *stream)
674677static void enable_streams (size_t stream_cnt )
675678{
676679 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 ]) ;
678681 int err ;
679682
680683 err = enable_stream (stream );
@@ -713,7 +716,7 @@ static int metadata_update_stream(struct bt_bap_stream *stream)
713716static void metadata_update_streams (size_t stream_cnt )
714717{
715718 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 ]) ;
717720 int err ;
718721
719722 err = metadata_update_stream (stream );
@@ -788,8 +791,8 @@ static void transceive_streams(void)
788791 sink_stream = pair_params [0 ].tx_param == NULL ? NULL : pair_params [0 ].tx_param -> stream ;
789792
790793 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 );
793796
794797 test_stream -> tx_active = true;
795798 for (unsigned int i = 0U ; i < ENQUEUE_COUNT ; i ++ ) {
@@ -803,8 +806,8 @@ static void transceive_streams(void)
803806 }
804807
805808 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 );
808811
809812 /* Keep receiving until we reach the minimum expected */
810813 while (test_stream -> rx_cnt < MIN_SEND_COUNT ) {
@@ -822,7 +825,8 @@ static void disable_streams(size_t stream_cnt)
822825 UNSET_FLAG (flag_stream_disabled );
823826
824827 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 ]));
826830 if (err == - EBUSY ) {
827831 k_sleep (BAP_STREAM_RETRY_WAIT );
828832 } else if (err != 0 ) {
@@ -845,7 +849,8 @@ static void release_streams(size_t stream_cnt)
845849 UNSET_FLAG (flag_stream_released );
846850
847851 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 ]));
849854 if (err == - EBUSY ) {
850855 k_sleep (BAP_STREAM_RETRY_WAIT );
851856 } else if (err != 0 ) {
@@ -869,12 +874,13 @@ static size_t create_unicast_group(struct bt_bap_unicast_group **unicast_group)
869874 memset (stream_params , 0 , sizeof (stream_params ));
870875 memset (pair_params , 0 , sizeof (pair_params ));
871876
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 ++ ) {
873878 if (g_sinks [i ] == NULL ) {
874879 break ;
875880 }
876881
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 ]);
878884 stream_params [stream_cnt ].qos = & preset_16_2_1 .qos ;
879885 pair_params [i ].tx_param = & stream_params [stream_cnt ];
880886
@@ -883,12 +889,13 @@ static size_t create_unicast_group(struct bt_bap_unicast_group **unicast_group)
883889 break ;
884890 }
885891
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 ++ ) {
887893 if (g_sources [i ] == NULL ) {
888894 break ;
889895 }
890896
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 ]);
892899 stream_params [stream_cnt ].qos = & preset_16_2_1 .qos ;
893900 pair_params [i ].rx_param = & stream_params [stream_cnt ];
894901
0 commit comments