xref: /aosp_15_r20/system/media/tests/static_checks.h (revision b9df5ad1c9ac98a7fefaac271a55f7ae3db05414)
1*b9df5ad1SAndroid Build Coastguard Worker /*
2*b9df5ad1SAndroid Build Coastguard Worker  * Copyright (C) 2020 The Android Open Source Project
3*b9df5ad1SAndroid Build Coastguard Worker  *
4*b9df5ad1SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*b9df5ad1SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*b9df5ad1SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*b9df5ad1SAndroid Build Coastguard Worker  *
8*b9df5ad1SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*b9df5ad1SAndroid Build Coastguard Worker  *
10*b9df5ad1SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*b9df5ad1SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*b9df5ad1SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*b9df5ad1SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*b9df5ad1SAndroid Build Coastguard Worker  * limitations under the License.
15*b9df5ad1SAndroid Build Coastguard Worker  */
16*b9df5ad1SAndroid Build Coastguard Worker 
17*b9df5ad1SAndroid Build Coastguard Worker #include <assert.h>
18*b9df5ad1SAndroid Build Coastguard Worker #include <stdint.h>
19*b9df5ad1SAndroid Build Coastguard Worker 
20*b9df5ad1SAndroid Build Coastguard Worker #include <system/audio.h>
21*b9df5ad1SAndroid Build Coastguard Worker 
22*b9df5ad1SAndroid Build Coastguard Worker // Ensure that bit mask enum types have 32-bit size.
23*b9df5ad1SAndroid Build Coastguard Worker // There is a lot of code that assumes this.
24*b9df5ad1SAndroid Build Coastguard Worker 
25*b9df5ad1SAndroid Build Coastguard Worker // Note that audio_devices_t is not a pure mask type since R,
26*b9df5ad1SAndroid Build Coastguard Worker // however there is legacy code which can mix its usage with uint32_t.
27*b9df5ad1SAndroid Build Coastguard Worker 
28*b9df5ad1SAndroid Build Coastguard Worker #define AUDIO_ENUM_MASKS_LIST(V)                \
29*b9df5ad1SAndroid Build Coastguard Worker     V(audio_channel_mask_t)                     \
30*b9df5ad1SAndroid Build Coastguard Worker     V(audio_channel_representation_t)           \
31*b9df5ad1SAndroid Build Coastguard Worker     V(audio_devices_t)                          \
32*b9df5ad1SAndroid Build Coastguard Worker     V(audio_flags_mask_t)                       \
33*b9df5ad1SAndroid Build Coastguard Worker     V(audio_gain_mode_t)                        \
34*b9df5ad1SAndroid Build Coastguard Worker     V(audio_input_flags_t)                      \
35*b9df5ad1SAndroid Build Coastguard Worker     V(audio_output_flags_t)
36*b9df5ad1SAndroid Build Coastguard Worker 
37*b9df5ad1SAndroid Build Coastguard Worker #define AUDIO_ASSERT_ENUM_MASK_SIZE(t)                                  \
38*b9df5ad1SAndroid Build Coastguard Worker     static_assert(sizeof(t) == sizeof(uint32_t), "The size of \'" #t "\' type must be 32 bits");
39*b9df5ad1SAndroid Build Coastguard Worker AUDIO_ENUM_MASKS_LIST(AUDIO_ASSERT_ENUM_MASK_SIZE);
40*b9df5ad1SAndroid Build Coastguard Worker #undef AUDIO_ASSERT_ENUM_MASK_SIZE
41*b9df5ad1SAndroid Build Coastguard Worker #undef AUDIO_ENUM_MASKS_LIST
42