2929
3030#include <zephyr/logging/log.h>
3131
32+ BUILD_ASSERT (CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT > 0 ||
33+ CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT > 0 ,
34+ "CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT or "
35+ "CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT shall be non-zero" );
36+
3237LOG_MODULE_REGISTER (bt_unicast_client , CONFIG_BT_AUDIO_UNICAST_CLIENT_LOG_LEVEL );
3338
3439#define PAC_DIR_UNUSED (dir ) ((dir) != BT_AUDIO_DIR_SINK && (dir) != BT_AUDIO_DIR_SOURCE)
@@ -58,10 +63,14 @@ static const struct bt_uuid *ase_src_uuid = BT_UUID_ASCS_ASE_SRC;
5863static const struct bt_uuid * cp_uuid = BT_UUID_ASCS_ASE_CP ;
5964
6065
66+ #if CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT > 0
6167static struct bt_unicast_client_ep snks [CONFIG_BT_MAX_CONN ]
6268 [CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT ];
69+ #endif /* CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT > 0 */
70+ #if CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT > 0
6371static struct bt_unicast_client_ep srcs [CONFIG_BT_MAX_CONN ]
6472 [CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT ];
73+ #endif /* CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT > 0 */
6574
6675static struct bt_gatt_subscribe_params cp_subscribe [CONFIG_BT_MAX_CONN ];
6776static struct bt_gatt_subscribe_params snk_loc_subscribe [CONFIG_BT_MAX_CONN ];
@@ -237,17 +246,21 @@ static struct bt_iso_chan_ops unicast_client_iso_ops = {
237246
238247bool bt_audio_ep_is_unicast_client (const struct bt_audio_ep * ep )
239248{
249+ #if CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT > 0
240250 for (size_t i = 0U ; i < ARRAY_SIZE (snks ); i ++ ) {
241251 if (PART_OF_ARRAY (snks [i ], ep )) {
242252 return true;
243253 }
244254 }
255+ #endif /* CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT > 0 */
245256
257+ #if CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT > 0
246258 for (size_t i = 0U ; i < ARRAY_SIZE (srcs ); i ++ ) {
247259 if (PART_OF_ARRAY (srcs [i ], ep )) {
248260 return true;
249261 }
250262 }
263+ #endif /* CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT > 0 */
251264
252265 return false;
253266}
@@ -270,28 +283,31 @@ static void unicast_client_ep_init(struct bt_audio_ep *ep, uint16_t handle,
270283static struct bt_audio_ep * unicast_client_ep_find (struct bt_conn * conn ,
271284 uint16_t handle )
272285{
273- size_t i ;
274286 uint8_t index ;
275287
276288 index = bt_conn_index (conn );
277289
278- for (i = 0 ; i < ARRAY_SIZE (snks [index ]); i ++ ) {
290+ #if CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT > 0
291+ for (size_t i = 0U ; i < ARRAY_SIZE (snks [index ]); i ++ ) {
279292 struct bt_unicast_client_ep * client_ep = & snks [index ][i ];
280293
281294 if ((handle && client_ep -> handle == handle ) ||
282295 (!handle && client_ep -> handle )) {
283296 return & client_ep -> ep ;
284297 }
285298 }
299+ #endif /* CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT > 0 */
286300
287- for (i = 0 ; i < ARRAY_SIZE (srcs [index ]); i ++ ) {
301+ #if CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT > 0
302+ for (size_t i = 0U ; i < ARRAY_SIZE (srcs [index ]); i ++ ) {
288303 struct bt_unicast_client_ep * client_ep = & srcs [index ][i ];
289304
290305 if ((handle && client_ep -> handle == handle ) ||
291306 (!handle && client_ep -> handle )) {
292307 return & client_ep -> ep ;
293308 }
294309 }
310+ #endif /* CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT > 0 */
295311
296312 return NULL ;
297313}
@@ -323,14 +339,18 @@ static struct bt_audio_ep *unicast_client_ep_new(struct bt_conn *conn,
323339 index = bt_conn_index (conn );
324340
325341 switch (dir ) {
342+ #if CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT > 0
326343 case BT_AUDIO_DIR_SINK :
327344 cache = snks [index ];
328345 size = ARRAY_SIZE (snks [index ]);
329346 break ;
347+ #endif /* CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT > 0 */
348+ #if CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT > 0
330349 case BT_AUDIO_DIR_SOURCE :
331350 cache = srcs [index ];
332351 size = ARRAY_SIZE (srcs [index ]);
333352 break ;
353+ #endif /* CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT > 0 */
334354 default :
335355 return NULL ;
336356 }
@@ -1153,7 +1173,6 @@ static int unicast_client_ep_subscribe(struct bt_conn *conn,
11531173
11541174static void unicast_client_ep_set_cp (struct bt_conn * conn , uint16_t handle )
11551175{
1156- size_t i ;
11571176 uint8_t index ;
11581177
11591178 LOG_DBG ("conn %p 0x%04x" , conn , handle );
@@ -1173,21 +1192,25 @@ static void unicast_client_ep_set_cp(struct bt_conn *conn, uint16_t handle)
11731192 bt_gatt_subscribe (conn , & cp_subscribe [index ]);
11741193 }
11751194
1176- for (i = 0 ; i < ARRAY_SIZE (snks [index ]); i ++ ) {
1195+ #if CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT > 0
1196+ for (size_t i = 0U ; i < ARRAY_SIZE (snks [index ]); i ++ ) {
11771197 struct bt_unicast_client_ep * client_ep = & snks [index ][i ];
11781198
11791199 if (client_ep -> handle ) {
11801200 client_ep -> cp_handle = handle ;
11811201 }
11821202 }
1203+ #endif /* CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT > 0 */
11831204
1184- for (i = 0 ; i < ARRAY_SIZE (srcs [index ]); i ++ ) {
1205+ #if CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT > 0
1206+ for (size_t i = 0U ; i < ARRAY_SIZE (srcs [index ]); i ++ ) {
11851207 struct bt_unicast_client_ep * client_ep = & srcs [index ][i ];
11861208
11871209 if (client_ep -> handle ) {
11881210 client_ep -> cp_handle = handle ;
11891211 }
11901212 }
1213+ #endif /* CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT > 0 */
11911214}
11921215
11931216NET_BUF_SIMPLE_DEFINE_STATIC (ep_buf , CONFIG_BT_L2CAP_TX_MTU );
@@ -1495,24 +1518,27 @@ static void unicast_client_reset(struct bt_audio_ep *ep)
14951518
14961519static void unicast_client_ep_reset (struct bt_conn * conn )
14971520{
1498- size_t i ;
14991521 uint8_t index ;
15001522
15011523 LOG_DBG ("conn %p" , conn );
15021524
15031525 index = bt_conn_index (conn );
15041526
1505- for (i = 0 ; i < ARRAY_SIZE (snks [index ]); i ++ ) {
1527+ #if CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT > 0
1528+ for (size_t i = 0U ; i < ARRAY_SIZE (snks [index ]); i ++ ) {
15061529 struct bt_audio_ep * ep = & snks [index ][i ].ep ;
15071530
15081531 unicast_client_reset (ep );
15091532 }
1533+ #endif /* CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT > 0 */
15101534
1511- for (i = 0 ; i < ARRAY_SIZE (srcs [index ]); i ++ ) {
1535+ #if CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT > 0
1536+ for (size_t i = 0U ; i < ARRAY_SIZE (srcs [index ]); i ++ ) {
15121537 struct bt_audio_ep * ep = & srcs [index ][i ].ep ;
15131538
15141539 unicast_client_reset (ep );
15151540 }
1541+ #endif /* CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT > 0 */
15161542}
15171543
15181544int bt_unicast_client_config (struct bt_audio_stream * stream ,
0 commit comments