|
33 | 33 | * @{ |
34 | 34 | */ |
35 | 35 |
|
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 | | - |
68 | 36 | /** Broadcast Audio Broadcast Code Size. */ |
69 | 37 | #define BLE_AUDIO_BROADCAST_CODE_SIZE 16 |
70 | 38 |
|
|
439 | 407 |
|
440 | 408 | /** @} */ |
441 | 409 |
|
| 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 | + |
442 | 426 | /** |
443 | 427 | * @brief Helper macro used to build LTV array of Codec_Specific_Configuration. |
444 | 428 | * |
|
453 | 437 | * |
454 | 438 | * @return Pointer to a `ble_uuid16_t` structure. |
455 | 439 | */ |
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, _frame_duration, \ |
| 441 | + _audio_channel_alloc, _octets_per_codec_frame, \ |
| 442 | + _codec_frame_blocks_per_sdu) \ |
| 443 | + { \ |
| 444 | + 2, BLE_AUDIO_CODEC_CONF_SAMPLING_FREQ_TYPE, _sampling_freq, 2, \ |
| 445 | + BLE_AUDIO_CODEC_CONF_FRAME_DURATION_TYPE, _frame_duration, \ |
| 446 | + _BLE_AUDIO_OPTIONAL_FIELD(5, BLE_AUDIO_CODEC_CONF_AUDIO_CHANNEL_ALLOCATION_TYPE, \ |
| 447 | + _audio_channel_alloc) 3, \ |
| 448 | + BLE_AUDIO_CODEC_CONF_OCTETS_PER_CODEC_FRAME_TYPE, \ |
| 449 | + (_octets_per_codec_frame), ((_octets_per_codec_frame) >> 8), \ |
| 450 | + _BLE_AUDIO_OPTIONAL_FIELD(2, BLE_AUDIO_CODEC_CONF_FRAME_BLOCKS_PER_SDU_TYPE, \ |
| 451 | + _codec_frame_blocks_per_sdu) \ |
470 | 452 | } |
471 | 453 |
|
472 | 454 | /** |
|
489 | 471 | * |
490 | 472 | * @return Pointer to a `ble_uuid16_t` structure. |
491 | 473 | */ |
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) \ |
| 474 | +#define BLE_AUDIO_BUILD_CODEC_CAPS( \ |
| 475 | + _sampling_freq, _frame_duration, _audio_channel_counts, \ |
| 476 | + _min_octets_per_codec_frame, _max_octets_per_codec_frame, _codec_frames_per_sdu) \ |
| 477 | + { \ |
| 478 | + 3, BLE_AUDIO_CODEC_CAPS_SAMPLING_FREQ_TYPE, (_sampling_freq), \ |
| 479 | + ((_sampling_freq) >> 8), 2, \ |
| 480 | + BLE_AUDIO_CODEC_CAPS_FRAME_DURATION_TYPE, _frame_duration, \ |
| 481 | + _BLE_AUDIO_OPTIONAL_FIELD(2, BLE_AUDIO_CODEC_CAPS_SUP_AUDIO_CHANNEL_COUNTS_TYPE, \ |
| 482 | + _audio_channel_counts) 5, \ |
| 483 | + BLE_AUDIO_CODEC_CAPS_OCTETS_PER_CODEC_FRAME_TYPE, \ |
| 484 | + (_min_octets_per_codec_frame), ((_min_octets_per_codec_frame) >> 8), \ |
| 485 | + (_max_octets_per_codec_frame), ((_max_octets_per_codec_frame) >> 8), \ |
| 486 | + _BLE_AUDIO_OPTIONAL_FIELD(2, BLE_AUDIO_CODEC_CAPS_FRAMES_PER_SDU_TYPE, \ |
| 487 | + _codec_frames_per_sdu) \ |
509 | 488 | } |
510 | 489 |
|
511 | 490 | /** Codec Information */ |
|
0 commit comments