Skip to content

Commit e418aff

Browse files
committed
nimble/host: Replace ble_audio.h macros with __VA_OPT__
Fixes an error at 'newt test all' in Github Actions: repos/apache-mynewt-nimble/nimble/host/audio/include/audio/ble_audio.h:52: error: "TEST" redefined [-Werror] 52 | #define TEST(x, A, FUNC, ...) FUNC |
1 parent 9d7e855 commit e418aff

File tree

1 file changed

+46
-63
lines changed

1 file changed

+46
-63
lines changed

nimble/host/audio/include/audio/ble_audio.h

Lines changed: 46 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,6 @@
3333
* @{
3434
*/
3535

36-
/**
37-
* @cond
38-
* Helper macros for BLE_AUDIO_BUILD_CODEC_CONFIG
39-
* @private @{
40-
*/
41-
#define FIELD_LEN_2(_len, _type, _field) _len, _type, _field,
42-
#define FIELD_LEN_5(_len, _type, _field) _len, _type, _field, \
43-
_field >> 8, _field >> 16, \
44-
_field >> 24,
45-
46-
#define FIELD_TESTED_0(_len, _type, _field)
47-
#define FIELD_TESTED_1(_len, _type, _field) FIELD_LEN_ ## _len(_len, \
48-
_type, \
49-
_field)
50-
#define EMPTY() FIELD_TESTED_0
51-
#define PRESENT(X) FIELD_TESTED_1
52-
#define TEST(x, A, FUNC, ...) FUNC
53-
#define TEST_FIELD(...) TEST(, ## __VA_ARGS__, \
54-
PRESENT(__VA_ARGS__), \
55-
EMPTY(__VA_ARGS__))
56-
#define FIELD_TESTED(_test, _len, _type, _field) _test(_len, _type, _field)
57-
#define OPTIONAL_FIELD(_len, _type, ...) FIELD_TESTED(TEST_FIELD \
58-
(__VA_ARGS__), \
59-
_len, \
60-
_type, \
61-
__VA_ARGS__)
62-
63-
/**
64-
* @}
65-
* @endcond
66-
*/
67-
6836
/** Broadcast Audio Broadcast Code Size. */
6937
#define BLE_AUDIO_BROADCAST_CODE_SIZE 16
7038

@@ -439,6 +407,22 @@
439407

440408
/** @} */
441409

410+
/**
411+
* @cond
412+
* Helper macros for BLE_AUDIO_BUILD_CODEC_CONFIG and BLE_AUDIO_BUILD_CODEC_CAPS
413+
* @private @{
414+
*/
415+
#define _BLE_AUDIO_FIELD_LEN_2(_len, _type, _field) _len, _type, _field,
416+
#define _BLE_AUDIO_FIELD_LEN_5(_len, _type, _field) \
417+
_len, _type, _field, _field >> 8, _field >> 16, _field >> 24,
418+
419+
#define _BLE_AUDIO_OPTIONAL_FIELD(_len, _type, ...) \
420+
__VA_OPT__(_BLE_AUDIO_FIELD_LEN_##len(len, type, __VA_ARGS__))
421+
/**
422+
* @}
423+
* @endcond
424+
*/
425+
442426
/**
443427
* @brief Helper macro used to build LTV array of Codec_Specific_Configuration.
444428
*
@@ -453,20 +437,20 @@
453437
*
454438
* @return Pointer to a `ble_uuid16_t` structure.
455439
*/
456-
#define BLE_AUDIO_BUILD_CODEC_CONFIG(_sampling_freq, \
457-
_frame_duration, \
458-
_audio_channel_alloc, \
459-
_octets_per_codec_frame, \
460-
_codec_frame_blocks_per_sdu) \
461-
{ \
462-
2, BLE_AUDIO_CODEC_CONF_SAMPLING_FREQ_TYPE, _sampling_freq, \
463-
2, BLE_AUDIO_CODEC_CONF_FRAME_DURATION_TYPE, _frame_duration, \
464-
OPTIONAL_FIELD(5, BLE_AUDIO_CODEC_CONF_AUDIO_CHANNEL_ALLOCATION_TYPE, \
465-
_audio_channel_alloc) \
466-
3, BLE_AUDIO_CODEC_CONF_OCTETS_PER_CODEC_FRAME_TYPE, \
467-
(_octets_per_codec_frame), ((_octets_per_codec_frame) >> 8), \
468-
OPTIONAL_FIELD(2, BLE_AUDIO_CODEC_CONF_FRAME_BLOCKS_PER_SDU_TYPE, \
469-
_codec_frame_blocks_per_sdu) \
440+
#define BLE_AUDIO_BUILD_CODEC_CONFIG(_sampling_freq, \
441+
_frame_duration, \
442+
_audio_channel_alloc, \
443+
_octets_per_codec_frame, \
444+
_codec_frame_blocks_per_sdu) \
445+
{ \
446+
2, BLE_AUDIO_CODEC_CONF_SAMPLING_FREQ_TYPE, _sampling_freq, \
447+
2, BLE_AUDIO_CODEC_CONF_FRAME_DURATION_TYPE, _frame_duration, \
448+
_BLE_AUDIO_OPTIONAL_FIELD(5, BLE_AUDIO_CODEC_CONF_AUDIO_CHANNEL_ALLOCATION_TYPE, \
449+
_audio_channel_alloc) \
450+
3, BLE_AUDIO_CODEC_CONF_OCTETS_PER_CODEC_FRAME_TYPE, \
451+
(_octets_per_codec_frame), ((_octets_per_codec_frame) >> 8), \
452+
_BLE_AUDIO_OPTIONAL_FIELD(2, BLE_AUDIO_CODEC_CONF_FRAME_BLOCKS_PER_SDU_TYPE, \
453+
_codec_frame_blocks_per_sdu) \
470454
}
471455

472456
/**
@@ -489,23 +473,22 @@
489473
*
490474
* @return Pointer to a `ble_uuid16_t` structure.
491475
*/
492-
#define BLE_AUDIO_BUILD_CODEC_CAPS(_sampling_freq, \
493-
_frame_duration, \
494-
_audio_channel_counts, \
495-
_min_octets_per_codec_frame, \
496-
_max_octets_per_codec_frame, \
497-
_codec_frames_per_sdu) \
498-
{ \
499-
3, BLE_AUDIO_CODEC_CAPS_SAMPLING_FREQ_TYPE, \
500-
(_sampling_freq), ((_sampling_freq) >> 8), \
501-
2, BLE_AUDIO_CODEC_CAPS_FRAME_DURATION_TYPE, _frame_duration, \
502-
OPTIONAL_FIELD(2, BLE_AUDIO_CODEC_CAPS_SUP_AUDIO_CHANNEL_COUNTS_TYPE, \
503-
_audio_channel_counts) \
504-
5, BLE_AUDIO_CODEC_CAPS_OCTETS_PER_CODEC_FRAME_TYPE, \
505-
(_min_octets_per_codec_frame), ((_min_octets_per_codec_frame) >> 8), \
506-
(_max_octets_per_codec_frame), ((_max_octets_per_codec_frame) >> 8), \
507-
OPTIONAL_FIELD(2, BLE_AUDIO_CODEC_CAPS_FRAMES_PER_SDU_TYPE, \
508-
_codec_frames_per_sdu) \
476+
#define BLE_AUDIO_BUILD_CODEC_CAPS(_sampling_freq, \
477+
_frame_duration, \
478+
_audio_channel_counts, \
479+
_min_octets_per_codec_frame, \
480+
_max_octets_per_codec_frame, \
481+
_codec_frames_per_sdu) \
482+
{ \
483+
3, BLE_AUDIO_CODEC_CAPS_SAMPLING_FREQ_TYPE, (_sampling_freq), ((_sampling_freq) >> 8), \
484+
2, BLE_AUDIO_CODEC_CAPS_FRAME_DURATION_TYPE, _frame_duration, \
485+
_BLE_AUDIO_OPTIONAL_FIELD(2, BLE_AUDIO_CODEC_CAPS_SUP_AUDIO_CHANNEL_COUNTS_TYPE, \
486+
_audio_channel_counts) \
487+
5, BLE_AUDIO_CODEC_CAPS_OCTETS_PER_CODEC_FRAME_TYPE, \
488+
(_min_octets_per_codec_frame), ((_min_octets_per_codec_frame) >> 8), \
489+
(_max_octets_per_codec_frame), ((_max_octets_per_codec_frame) >> 8), \
490+
_BLE_AUDIO_OPTIONAL_FIELD(2, BLE_AUDIO_CODEC_CAPS_FRAMES_PER_SDU_TYPE, \
491+
_codec_frames_per_sdu) \
509492
}
510493

511494
/** Codec Information */

0 commit comments

Comments
 (0)