@@ -33,8 +33,10 @@ NET_BUF_POOL_FIXED_DEFINE(tx_pool, CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT,
3333static struct bt_audio_stream streams [CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT +
3434 CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT ];
3535static size_t configured_sink_stream_count ;
36- static size_t configured_stream_count ;
36+ static size_t configured_source_stream_count ;
3737
38+ #define configured_stream_count (configured_sink_stream_count + \
39+ configured_source_stream_count)
3840
3941/* Select a codec configuration to apply that is mandatory to support by both client and server.
4042 * Allows this sample application to work without logic to parse the codec capabilities of the
@@ -329,25 +331,6 @@ static void audio_timer_timeout(struct k_work *work)
329331
330332#endif
331333
332-
333- static enum bt_audio_dir stream_dir (const struct bt_audio_stream * stream )
334- {
335- for (size_t i = 0U ; i < ARRAY_SIZE (sinks ); i ++ ) {
336- if (sinks [i ].ep != NULL && stream -> ep == sinks [i ].ep ) {
337- return BT_AUDIO_DIR_SINK ;
338- }
339- }
340-
341- for (size_t i = 0U ; i < ARRAY_SIZE (sources ); i ++ ) {
342- if (sources [i ] != NULL && stream -> ep == sources [i ]) {
343- return BT_AUDIO_DIR_SOURCE ;
344- }
345- }
346-
347- __ASSERT (false, "Invalid stream" );
348- return 0 ;
349- }
350-
351334static void print_hex (const uint8_t * ptr , size_t len )
352335{
353336 while (len -- != 0 ) {
@@ -880,7 +863,6 @@ static int configure_streams(void)
880863 }
881864
882865 printk ("Configured sink stream[%zu]\n" , i );
883- configured_stream_count ++ ;
884866 configured_sink_stream_count ++ ;
885867 }
886868
@@ -900,26 +882,42 @@ static int configure_streams(void)
900882 }
901883
902884 printk ("Configured source stream[%zu]\n" , i );
903- configured_stream_count ++ ;
885+ configured_source_stream_count ++ ;
904886 }
905887
906888 return 0 ;
907889}
908890
909891static int create_group (void )
910892{
911- struct bt_audio_unicast_group_stream_param stream_params [ARRAY_SIZE (streams )];
893+ const size_t params_count = MAX (configured_sink_stream_count ,
894+ configured_source_stream_count );
895+ struct bt_audio_unicast_group_stream_pair_param pair_params [params_count ];
896+ struct bt_audio_unicast_group_stream_param stream_params [configured_stream_count ];
912897 struct bt_audio_unicast_group_param param ;
913898 int err ;
914899
915900 for (size_t i = 0U ; i < configured_stream_count ; i ++ ) {
916901 stream_params [i ].stream = & streams [i ];
917902 stream_params [i ].qos = & codec_configuration .qos ;
918- stream_params [i ].dir = stream_dir (stream_params [i ].stream );
919903 }
920904
921- param .params = stream_params ;
922- param .params_count = configured_stream_count ;
905+ for (size_t i = 0U ; i < params_count ; i ++ ) {
906+ if (i < configured_sink_stream_count ) {
907+ pair_params [i ].tx_param = & stream_params [i ];
908+ } else {
909+ pair_params [i ].tx_param = NULL ;
910+ }
911+
912+ if (i < configured_source_stream_count ) {
913+ pair_params [i ].rx_param = & stream_params [i + configured_sink_stream_count ];
914+ } else {
915+ pair_params [i ].rx_param = NULL ;
916+ }
917+ }
918+
919+ param .params = pair_params ;
920+ param .params_count = params_count ;
923921 param .packing = BT_ISO_PACKING_SEQUENTIAL ;
924922
925923 err = bt_audio_unicast_group_create (& param , & unicast_group );
@@ -969,7 +967,7 @@ static int enable_streams(void)
969967 init_lc3 ();
970968 }
971969
972- for (size_t i = 0 ; i < configured_stream_count ; i ++ ) {
970+ for (size_t i = 0U ; i < configured_stream_count ; i ++ ) {
973971 int err ;
974972
975973 err = bt_audio_stream_enable (& streams [i ],
@@ -992,7 +990,7 @@ static int enable_streams(void)
992990
993991static int start_streams (void )
994992{
995- for (size_t i = 0 ; i < configured_stream_count ; i ++ ) {
993+ for (size_t i = 0U ; i < configured_stream_count ; i ++ ) {
996994 int err ;
997995
998996 err = bt_audio_stream_start (& streams [i ]);
@@ -1025,7 +1023,7 @@ static void reset_data(void)
10251023 k_sem_reset (& sem_stream_started );
10261024
10271025 configured_sink_stream_count = 0 ;
1028- configured_stream_count = 0 ;
1026+ configured_source_stream_count = 0 ;
10291027}
10301028
10311029void main (void )
0 commit comments