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