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 // This header contains definitions of enums that are passed through
18 // the system <-> vendor (also known as framework <-> HAL) boundary.
19 // On the HIDL HAL side they are defined in the Audio Policy config
20 // schema: h/i/audio/x.x/config/audio_policy_configuration.xsd
21 // AIDL HAL has a similar XSD schema designed to facilitate parsing of
22 // legacy APM config files, it is located at:
23 // h/i/audio/aidl/default/config/audioPolicy/audio_policy_configuration.xsd
24 //
25 // These enums are passed between the framework and the HAL as
26 // strings. Because of that, functions for to/from string conversion
27 // are also defined here. The enums are defined in a way that
28 // allows having only one list of values which is then used to
29 // generate both enum definitions and to/from string converters.
30 // As this header needs to be compatible with C, preprocessor
31 // macros are used for templating.
32 //
33 // Some enums have framework-only extensions. They are disabled
34 // for vendor code by means of AUDIO_NO_SYSTEM_DECLARATIONS define.
35 // Framework-only enum values can not be received from HAL, thus
36 // string -> enum conversion is not generated for them. However,
37 // since enum -> string conversion is also useful for debugging
38 // purposes, the corresponding cases are handled in conversion
39 // functions.
40 //
41 // There is no automatic update of enum symbols list from the
42 // audio HAL schema, or vice versa. Any new enum value used at
43 // the system <-> vendor boundary must be added to both locations.
44 //
45 // No special functions are provided for dealing with enums that
46 // constitute flags, e.g. to convert a mask into a list of strings.
47 // String conversion functions only support individual flag values.
48 // The only exception is 'audio_channel_mask_from_string' function
49 // which only deals with masks, not with individual channels.
50
51 #ifndef ANDROID_AUDIO_HAL_ENUMS_H
52 #define ANDROID_AUDIO_HAL_ENUMS_H
53
54 #include <stdbool.h>
55 #include <stdint.h>
56 #include <string.h>
57 #include <sys/cdefs.h>
58
59 __BEGIN_DECLS
60
61 #define AUDIO_ENUM_QUOTE(x) #x
62 #define AUDIO_ENUM_STRINGIFY(x) AUDIO_ENUM_QUOTE(x)
63 // Simple enums are the ones relying on default values.
64 // Enums that specify values need to use '_V' versions of macros.
65 #define AUDIO_DEFINE_ENUM_SYMBOL(symbol) symbol,
66 #define AUDIO_DEFINE_ENUM_SYMBOL_V(symbol, value) symbol = value,
67 #define AUDIO_DEFINE_BIT_MASK(symbol) symbol |
68 #define AUDIO_DEFINE_BIT_MASK_V(symbol, _) AUDIO_DEFINE_BIT_MASK(symbol)
69 #define AUDIO_DEFINE_STRINGIFY_CASE(symbol) case symbol: return AUDIO_ENUM_STRINGIFY(symbol);
70 #define AUDIO_DEFINE_STRINGIFY_CASE_V(symbol, _) AUDIO_DEFINE_STRINGIFY_CASE(symbol)
71 #define AUDIO_DEFINE_PARSE_CASE(symbol) \
72 if (strcmp(s, AUDIO_ENUM_STRINGIFY(symbol)) == 0) { *t = symbol; return true; } else
73 #define AUDIO_DEFINE_PARSE_CASE_V(symbol, _) AUDIO_DEFINE_PARSE_CASE(symbol)
74
75
76 // These are individual output channel flags, only one bit must be set.
77 #define AUDIO_CHANNEL_OUT_DISCRETE_CHANNEL_LIST_DEF(V) \
78 V(AUDIO_CHANNEL_OUT_FRONT_LEFT, 0x1u) \
79 V(AUDIO_CHANNEL_OUT_FRONT_RIGHT, 0x2u) \
80 V(AUDIO_CHANNEL_OUT_FRONT_CENTER, 0x4u) \
81 V(AUDIO_CHANNEL_OUT_LOW_FREQUENCY, 0x8u) \
82 V(AUDIO_CHANNEL_OUT_BACK_LEFT, 0x10u) \
83 V(AUDIO_CHANNEL_OUT_BACK_RIGHT, 0x20u) \
84 V(AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER, 0x40u) \
85 V(AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER, 0x80u) \
86 V(AUDIO_CHANNEL_OUT_BACK_CENTER, 0x100u) \
87 V(AUDIO_CHANNEL_OUT_SIDE_LEFT, 0x200u) \
88 V(AUDIO_CHANNEL_OUT_SIDE_RIGHT, 0x400u) \
89 V(AUDIO_CHANNEL_OUT_TOP_CENTER, 0x800u) \
90 V(AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT, 0x1000u) \
91 V(AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER, 0x2000u) \
92 V(AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT, 0x4000u) \
93 V(AUDIO_CHANNEL_OUT_TOP_BACK_LEFT, 0x8000u) \
94 V(AUDIO_CHANNEL_OUT_TOP_BACK_CENTER, 0x10000u) \
95 V(AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT, 0x20000u) \
96 V(AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT, 0x40000u) \
97 V(AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT, 0x80000u) \
98 V(AUDIO_CHANNEL_OUT_BOTTOM_FRONT_LEFT, 0x100000u) \
99 V(AUDIO_CHANNEL_OUT_BOTTOM_FRONT_CENTER, 0x200000u) \
100 V(AUDIO_CHANNEL_OUT_BOTTOM_FRONT_RIGHT, 0x400000u) \
101 V(AUDIO_CHANNEL_OUT_LOW_FREQUENCY_2, 0x800000u) \
102 V(AUDIO_CHANNEL_OUT_FRONT_WIDE_LEFT, 0x1000000u) \
103 V(AUDIO_CHANNEL_OUT_FRONT_WIDE_RIGHT, 0x2000000u) \
104 V(AUDIO_CHANNEL_OUT_HAPTIC_A, 0x20000000u) \
105 V(AUDIO_CHANNEL_OUT_HAPTIC_B, 0x10000000u)
106 // These are individual input channel flags, only one bit must be set.
107 #define AUDIO_CHANNEL_IN_DISCRETE_CHANNEL_LIST_DEF(V) \
108 V(AUDIO_CHANNEL_IN_LEFT, 0x4u) \
109 V(AUDIO_CHANNEL_IN_RIGHT, 0x8u) \
110 V(AUDIO_CHANNEL_IN_FRONT, 0x10u) \
111 V(AUDIO_CHANNEL_IN_BACK, 0x20u) \
112 V(AUDIO_CHANNEL_IN_LEFT_PROCESSED, 0x40u) \
113 V(AUDIO_CHANNEL_IN_RIGHT_PROCESSED, 0x80u) \
114 V(AUDIO_CHANNEL_IN_FRONT_PROCESSED, 0x100u) \
115 V(AUDIO_CHANNEL_IN_BACK_PROCESSED, 0x200u) \
116 V(AUDIO_CHANNEL_IN_PRESSURE, 0x400u) \
117 V(AUDIO_CHANNEL_IN_X_AXIS, 0x800u) \
118 V(AUDIO_CHANNEL_IN_Y_AXIS, 0x1000u) \
119 V(AUDIO_CHANNEL_IN_Z_AXIS, 0x2000u) \
120 V(AUDIO_CHANNEL_IN_VOICE_UPLINK, 0x4000u) \
121 V(AUDIO_CHANNEL_IN_VOICE_DNLINK, 0x8000u) \
122 V(AUDIO_CHANNEL_IN_BACK_LEFT, 0x10000u) \
123 V(AUDIO_CHANNEL_IN_BACK_RIGHT, 0x20000u) \
124 V(AUDIO_CHANNEL_IN_CENTER, 0x40000u) \
125 V(AUDIO_CHANNEL_IN_LOW_FREQUENCY, 0x100000u) \
126 V(AUDIO_CHANNEL_IN_TOP_LEFT, 0x200000u) \
127 V(AUDIO_CHANNEL_IN_TOP_RIGHT, 0x400000u)
128 #define AUDIO_CHANNEL_IN_OUT_MASK_LIST_DEF(V) \
129 V(AUDIO_CHANNEL_NONE, 0x0u)
130 // Input and output masks are defined via individual channels.
131 #define AUDIO_CHANNEL_OUT_MASK_LIST_UNIQUE_DEF(V) \
132 V(AUDIO_CHANNEL_OUT_MONO, AUDIO_CHANNEL_OUT_FRONT_LEFT) \
133 V(AUDIO_CHANNEL_OUT_STEREO, AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT) \
134 V(AUDIO_CHANNEL_OUT_2POINT1, AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | AUDIO_CHANNEL_OUT_LOW_FREQUENCY) \
135 V(AUDIO_CHANNEL_OUT_TRI, AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | AUDIO_CHANNEL_OUT_FRONT_CENTER) \
136 V(AUDIO_CHANNEL_OUT_TRI_BACK, AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | AUDIO_CHANNEL_OUT_BACK_CENTER) \
137 V(AUDIO_CHANNEL_OUT_3POINT1, AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | AUDIO_CHANNEL_OUT_FRONT_CENTER | AUDIO_CHANNEL_OUT_LOW_FREQUENCY) \
138 V(AUDIO_CHANNEL_OUT_2POINT0POINT2, AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT | AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT) \
139 V(AUDIO_CHANNEL_OUT_2POINT1POINT2, AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT | AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT | AUDIO_CHANNEL_OUT_LOW_FREQUENCY) \
140 V(AUDIO_CHANNEL_OUT_3POINT0POINT2, AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | AUDIO_CHANNEL_OUT_FRONT_CENTER | AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT | AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT) \
141 V(AUDIO_CHANNEL_OUT_3POINT1POINT2, AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | AUDIO_CHANNEL_OUT_FRONT_CENTER | AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT | AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT | AUDIO_CHANNEL_OUT_LOW_FREQUENCY) \
142 V(AUDIO_CHANNEL_OUT_QUAD, AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | AUDIO_CHANNEL_OUT_BACK_LEFT | AUDIO_CHANNEL_OUT_BACK_RIGHT) \
143 V(AUDIO_CHANNEL_OUT_QUAD_SIDE, AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | AUDIO_CHANNEL_OUT_SIDE_LEFT | AUDIO_CHANNEL_OUT_SIDE_RIGHT) \
144 V(AUDIO_CHANNEL_OUT_SURROUND, AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | AUDIO_CHANNEL_OUT_FRONT_CENTER | AUDIO_CHANNEL_OUT_BACK_CENTER) \
145 V(AUDIO_CHANNEL_OUT_PENTA, AUDIO_CHANNEL_OUT_QUAD | AUDIO_CHANNEL_OUT_FRONT_CENTER) \
146 V(AUDIO_CHANNEL_OUT_5POINT1, AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | AUDIO_CHANNEL_OUT_FRONT_CENTER | AUDIO_CHANNEL_OUT_LOW_FREQUENCY | AUDIO_CHANNEL_OUT_BACK_LEFT | AUDIO_CHANNEL_OUT_BACK_RIGHT) \
147 V(AUDIO_CHANNEL_OUT_5POINT1_SIDE, AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | AUDIO_CHANNEL_OUT_FRONT_CENTER | AUDIO_CHANNEL_OUT_LOW_FREQUENCY | AUDIO_CHANNEL_OUT_SIDE_LEFT | AUDIO_CHANNEL_OUT_SIDE_RIGHT) \
148 V(AUDIO_CHANNEL_OUT_5POINT1POINT2, AUDIO_CHANNEL_OUT_5POINT1 | AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT | AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT) \
149 V(AUDIO_CHANNEL_OUT_5POINT1POINT4, AUDIO_CHANNEL_OUT_5POINT1 | AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT | AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT | AUDIO_CHANNEL_OUT_TOP_BACK_LEFT | AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT) \
150 V(AUDIO_CHANNEL_OUT_6POINT1, AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | AUDIO_CHANNEL_OUT_FRONT_CENTER | AUDIO_CHANNEL_OUT_LOW_FREQUENCY | AUDIO_CHANNEL_OUT_BACK_LEFT | AUDIO_CHANNEL_OUT_BACK_RIGHT | AUDIO_CHANNEL_OUT_BACK_CENTER) \
151 V(AUDIO_CHANNEL_OUT_7POINT1, AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | AUDIO_CHANNEL_OUT_FRONT_CENTER | AUDIO_CHANNEL_OUT_LOW_FREQUENCY | AUDIO_CHANNEL_OUT_BACK_LEFT | AUDIO_CHANNEL_OUT_BACK_RIGHT | AUDIO_CHANNEL_OUT_SIDE_LEFT | AUDIO_CHANNEL_OUT_SIDE_RIGHT) \
152 V(AUDIO_CHANNEL_OUT_7POINT1POINT2, AUDIO_CHANNEL_OUT_7POINT1 | AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT | AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT) \
153 V(AUDIO_CHANNEL_OUT_7POINT1POINT4, AUDIO_CHANNEL_OUT_7POINT1 | AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT | AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT | AUDIO_CHANNEL_OUT_TOP_BACK_LEFT | AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT) \
154 V(AUDIO_CHANNEL_OUT_9POINT1POINT4, AUDIO_CHANNEL_OUT_7POINT1POINT4 | \
155 AUDIO_CHANNEL_OUT_FRONT_WIDE_LEFT | AUDIO_CHANNEL_OUT_FRONT_WIDE_RIGHT) \
156 V(AUDIO_CHANNEL_OUT_9POINT1POINT6, AUDIO_CHANNEL_OUT_9POINT1POINT4 | \
157 AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT | AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT) \
158 V(AUDIO_CHANNEL_OUT_13POINT_360RA, \
159 AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | \
160 AUDIO_CHANNEL_OUT_FRONT_CENTER | \
161 AUDIO_CHANNEL_OUT_SIDE_LEFT | AUDIO_CHANNEL_OUT_SIDE_RIGHT | \
162 AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT | AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT | \
163 AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER | \
164 AUDIO_CHANNEL_OUT_TOP_BACK_LEFT | AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT | \
165 AUDIO_CHANNEL_OUT_BOTTOM_FRONT_LEFT | AUDIO_CHANNEL_OUT_BOTTOM_FRONT_RIGHT | \
166 AUDIO_CHANNEL_OUT_BOTTOM_FRONT_CENTER) \
167 V(AUDIO_CHANNEL_OUT_22POINT2, AUDIO_CHANNEL_OUT_7POINT1POINT4 | \
168 AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER | AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER | \
169 AUDIO_CHANNEL_OUT_BACK_CENTER | AUDIO_CHANNEL_OUT_TOP_CENTER | \
170 AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER | AUDIO_CHANNEL_OUT_TOP_BACK_CENTER | \
171 AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT | AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT | \
172 AUDIO_CHANNEL_OUT_BOTTOM_FRONT_LEFT | AUDIO_CHANNEL_OUT_BOTTOM_FRONT_RIGHT | \
173 AUDIO_CHANNEL_OUT_BOTTOM_FRONT_CENTER | \
174 AUDIO_CHANNEL_OUT_LOW_FREQUENCY_2) \
175 V(AUDIO_CHANNEL_OUT_MONO_HAPTIC_A, AUDIO_CHANNEL_OUT_MONO | AUDIO_CHANNEL_OUT_HAPTIC_A) \
176 V(AUDIO_CHANNEL_OUT_STEREO_HAPTIC_A, AUDIO_CHANNEL_OUT_STEREO | AUDIO_CHANNEL_OUT_HAPTIC_A) \
177 V(AUDIO_CHANNEL_OUT_HAPTIC_AB, AUDIO_CHANNEL_OUT_HAPTIC_A | AUDIO_CHANNEL_OUT_HAPTIC_B) \
178 V(AUDIO_CHANNEL_OUT_MONO_HAPTIC_AB, AUDIO_CHANNEL_OUT_MONO | AUDIO_CHANNEL_OUT_HAPTIC_AB) \
179 V(AUDIO_CHANNEL_OUT_STEREO_HAPTIC_AB, AUDIO_CHANNEL_OUT_STEREO | AUDIO_CHANNEL_OUT_HAPTIC_AB)
180 // Some of the channel masks have aliases. They can not appear in the 'to string'
181 // converter as case values must be unique.
182 #define AUDIO_CHANNEL_OUT_MASK_LIST_DEF(V) \
183 AUDIO_CHANNEL_OUT_MASK_LIST_UNIQUE_DEF(V) \
184 V(AUDIO_CHANNEL_OUT_5POINT1_BACK, AUDIO_CHANNEL_OUT_5POINT1) \
185 V(AUDIO_CHANNEL_OUT_QUAD_BACK, AUDIO_CHANNEL_OUT_QUAD)
186 #define AUDIO_CHANNEL_IN_MASK_LIST_DEF(V) \
187 V(AUDIO_CHANNEL_IN_MONO, AUDIO_CHANNEL_IN_FRONT) \
188 V(AUDIO_CHANNEL_IN_STEREO, AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_RIGHT) \
189 V(AUDIO_CHANNEL_IN_2POINT1, AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_RIGHT | AUDIO_CHANNEL_IN_LOW_FREQUENCY) \
190 V(AUDIO_CHANNEL_IN_FRONT_BACK, AUDIO_CHANNEL_IN_FRONT | AUDIO_CHANNEL_IN_BACK) \
191 V(AUDIO_CHANNEL_IN_TRI, AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_RIGHT | AUDIO_CHANNEL_IN_CENTER) \
192 V(AUDIO_CHANNEL_IN_3POINT1, AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_RIGHT | AUDIO_CHANNEL_IN_LOW_FREQUENCY | AUDIO_CHANNEL_IN_CENTER) \
193 V(AUDIO_CHANNEL_IN_6, AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_RIGHT | AUDIO_CHANNEL_IN_FRONT | AUDIO_CHANNEL_IN_BACK | AUDIO_CHANNEL_IN_LEFT_PROCESSED | AUDIO_CHANNEL_IN_RIGHT_PROCESSED) \
194 V(AUDIO_CHANNEL_IN_2POINT0POINT2, AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_RIGHT | AUDIO_CHANNEL_IN_TOP_LEFT | AUDIO_CHANNEL_IN_TOP_RIGHT) \
195 V(AUDIO_CHANNEL_IN_2POINT1POINT2, AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_RIGHT | AUDIO_CHANNEL_IN_TOP_LEFT | AUDIO_CHANNEL_IN_TOP_RIGHT | AUDIO_CHANNEL_IN_LOW_FREQUENCY) \
196 V(AUDIO_CHANNEL_IN_3POINT0POINT2, AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_CENTER | AUDIO_CHANNEL_IN_RIGHT | AUDIO_CHANNEL_IN_TOP_LEFT | AUDIO_CHANNEL_IN_TOP_RIGHT) \
197 V(AUDIO_CHANNEL_IN_3POINT1POINT2, AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_CENTER | AUDIO_CHANNEL_IN_RIGHT | AUDIO_CHANNEL_IN_TOP_LEFT | AUDIO_CHANNEL_IN_TOP_RIGHT | AUDIO_CHANNEL_IN_LOW_FREQUENCY) \
198 V(AUDIO_CHANNEL_IN_QUAD, AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_RIGHT | AUDIO_CHANNEL_IN_BACK_LEFT | AUDIO_CHANNEL_IN_BACK_RIGHT) \
199 V(AUDIO_CHANNEL_IN_PENTA, AUDIO_CHANNEL_IN_QUAD | AUDIO_CHANNEL_IN_CENTER) \
200 V(AUDIO_CHANNEL_IN_5POINT1, AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_CENTER | AUDIO_CHANNEL_IN_RIGHT | AUDIO_CHANNEL_IN_BACK_LEFT | AUDIO_CHANNEL_IN_BACK_RIGHT | AUDIO_CHANNEL_IN_LOW_FREQUENCY) \
201 V(AUDIO_CHANNEL_IN_VOICE_UPLINK_MONO, AUDIO_CHANNEL_IN_VOICE_UPLINK | AUDIO_CHANNEL_IN_MONO) \
202 V(AUDIO_CHANNEL_IN_VOICE_DNLINK_MONO, AUDIO_CHANNEL_IN_VOICE_DNLINK | AUDIO_CHANNEL_IN_MONO) \
203 V(AUDIO_CHANNEL_IN_VOICE_CALL_MONO, AUDIO_CHANNEL_IN_VOICE_UPLINK_MONO | AUDIO_CHANNEL_IN_VOICE_DNLINK_MONO)
204
205 enum {
206 AUDIO_CHANNEL_COUNT_MAX = 30u,
207 // Can't use AUDIO_CHANNEL_REPRESENTATION_INDEX because audio.h depends on this header.
208 AUDIO_CHANNEL_INDEX_HDR = 0x80000000u, // AUDIO_CHANNEL_REPRESENTATION_INDEX << COUNT_MAX
209 };
210
211 // Channel index representation definitions.
212 #define AUDIO_CHANNEL_INDEX_MASK_LIST_DEF(V) \
213 V(AUDIO_CHANNEL_INDEX_MASK_1, AUDIO_CHANNEL_INDEX_HDR | (1 << 1) - 1) \
214 V(AUDIO_CHANNEL_INDEX_MASK_2, AUDIO_CHANNEL_INDEX_HDR | (1 << 2) - 1) \
215 V(AUDIO_CHANNEL_INDEX_MASK_3, AUDIO_CHANNEL_INDEX_HDR | (1 << 3) - 1) \
216 V(AUDIO_CHANNEL_INDEX_MASK_4, AUDIO_CHANNEL_INDEX_HDR | (1 << 4) - 1) \
217 V(AUDIO_CHANNEL_INDEX_MASK_5, AUDIO_CHANNEL_INDEX_HDR | (1 << 5) - 1) \
218 V(AUDIO_CHANNEL_INDEX_MASK_6, AUDIO_CHANNEL_INDEX_HDR | (1 << 6) - 1) \
219 V(AUDIO_CHANNEL_INDEX_MASK_7, AUDIO_CHANNEL_INDEX_HDR | (1 << 7) - 1) \
220 V(AUDIO_CHANNEL_INDEX_MASK_8, AUDIO_CHANNEL_INDEX_HDR | (1 << 8) - 1) \
221 V(AUDIO_CHANNEL_INDEX_MASK_9, AUDIO_CHANNEL_INDEX_HDR | (1 << 9) - 1) \
222 V(AUDIO_CHANNEL_INDEX_MASK_10, AUDIO_CHANNEL_INDEX_HDR | (1 << 10) - 1) \
223 V(AUDIO_CHANNEL_INDEX_MASK_11, AUDIO_CHANNEL_INDEX_HDR | (1 << 11) - 1) \
224 V(AUDIO_CHANNEL_INDEX_MASK_12, AUDIO_CHANNEL_INDEX_HDR | (1 << 12) - 1) \
225 V(AUDIO_CHANNEL_INDEX_MASK_13, AUDIO_CHANNEL_INDEX_HDR | (1 << 13) - 1) \
226 V(AUDIO_CHANNEL_INDEX_MASK_14, AUDIO_CHANNEL_INDEX_HDR | (1 << 14) - 1) \
227 V(AUDIO_CHANNEL_INDEX_MASK_15, AUDIO_CHANNEL_INDEX_HDR | (1 << 15) - 1) \
228 V(AUDIO_CHANNEL_INDEX_MASK_16, AUDIO_CHANNEL_INDEX_HDR | (1 << 16) - 1) \
229 V(AUDIO_CHANNEL_INDEX_MASK_17, AUDIO_CHANNEL_INDEX_HDR | (1 << 17) - 1) \
230 V(AUDIO_CHANNEL_INDEX_MASK_18, AUDIO_CHANNEL_INDEX_HDR | (1 << 18) - 1) \
231 V(AUDIO_CHANNEL_INDEX_MASK_19, AUDIO_CHANNEL_INDEX_HDR | (1 << 19) - 1) \
232 V(AUDIO_CHANNEL_INDEX_MASK_20, AUDIO_CHANNEL_INDEX_HDR | (1 << 20) - 1) \
233 V(AUDIO_CHANNEL_INDEX_MASK_21, AUDIO_CHANNEL_INDEX_HDR | (1 << 21) - 1) \
234 V(AUDIO_CHANNEL_INDEX_MASK_22, AUDIO_CHANNEL_INDEX_HDR | (1 << 22) - 1) \
235 V(AUDIO_CHANNEL_INDEX_MASK_23, AUDIO_CHANNEL_INDEX_HDR | (1 << 23) - 1) \
236 V(AUDIO_CHANNEL_INDEX_MASK_24, AUDIO_CHANNEL_INDEX_HDR | (1 << 24) - 1)
237
238 // The "channel mask" enum is comprised of discrete channels,
239 // their combinations (masks), and special values.
240 typedef enum : uint32_t {
241 AUDIO_CHANNEL_OUT_DISCRETE_CHANNEL_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL_V)
242 AUDIO_CHANNEL_IN_DISCRETE_CHANNEL_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL_V)
243 AUDIO_CHANNEL_IN_OUT_MASK_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL_V)
244 AUDIO_CHANNEL_OUT_MASK_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL_V)
245 AUDIO_CHANNEL_IN_MASK_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL_V)
246 AUDIO_CHANNEL_INDEX_MASK_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL_V)
247 AUDIO_CHANNEL_OUT_ALL =
248 AUDIO_CHANNEL_OUT_DISCRETE_CHANNEL_LIST_DEF(AUDIO_DEFINE_BIT_MASK_V) 0,
249 AUDIO_CHANNEL_HAPTIC_ALL = AUDIO_CHANNEL_OUT_HAPTIC_B |
250 AUDIO_CHANNEL_OUT_HAPTIC_A,
251 AUDIO_CHANNEL_IN_ALL =
252 AUDIO_CHANNEL_IN_DISCRETE_CHANNEL_LIST_DEF(AUDIO_DEFINE_BIT_MASK_V) 0,
253 // This value must be part of the enum, but it is not a valid mask,
254 // and thus it does not participate in to/from string conversions.
255 AUDIO_CHANNEL_INVALID = 0xC0000000u,
256 } audio_channel_mask_t;
257
258 // Due to the fact that flag values for input and output channels
259 // intersect, to string conversions must be defined separately.
audio_channel_out_mask_to_string(audio_channel_mask_t t)260 inline const char* audio_channel_out_mask_to_string(audio_channel_mask_t t) {
261 switch (t) {
262 AUDIO_CHANNEL_IN_OUT_MASK_LIST_DEF(AUDIO_DEFINE_STRINGIFY_CASE_V)
263 AUDIO_CHANNEL_OUT_MASK_LIST_UNIQUE_DEF(AUDIO_DEFINE_STRINGIFY_CASE_V)
264 default:
265 return "";
266 }
267 }
268
audio_channel_in_mask_to_string(audio_channel_mask_t t)269 inline const char* audio_channel_in_mask_to_string(audio_channel_mask_t t) {
270 switch (t) {
271 AUDIO_CHANNEL_IN_OUT_MASK_LIST_DEF(AUDIO_DEFINE_STRINGIFY_CASE_V)
272 AUDIO_CHANNEL_IN_MASK_LIST_DEF(AUDIO_DEFINE_STRINGIFY_CASE_V)
273 default:
274 return "";
275 }
276 }
277
audio_channel_index_mask_to_string(audio_channel_mask_t t)278 inline const char* audio_channel_index_mask_to_string(audio_channel_mask_t t) {
279 switch (t) {
280 AUDIO_CHANNEL_IN_OUT_MASK_LIST_DEF(AUDIO_DEFINE_STRINGIFY_CASE_V)
281 AUDIO_CHANNEL_INDEX_MASK_LIST_DEF(AUDIO_DEFINE_STRINGIFY_CASE_V)
282 default:
283 return "";
284 }
285 }
286
287 // Note: parsing is only done for masks, individual channels are not used by HAL.
audio_channel_mask_from_string(const char * s,audio_channel_mask_t * t)288 inline bool audio_channel_mask_from_string(const char* s, audio_channel_mask_t* t) {
289 AUDIO_CHANNEL_IN_OUT_MASK_LIST_DEF(AUDIO_DEFINE_PARSE_CASE_V)
290 AUDIO_CHANNEL_OUT_MASK_LIST_DEF(AUDIO_DEFINE_PARSE_CASE_V)
291 AUDIO_CHANNEL_IN_MASK_LIST_DEF(AUDIO_DEFINE_PARSE_CASE_V)
292 AUDIO_CHANNEL_INDEX_MASK_LIST_DEF(AUDIO_DEFINE_PARSE_CASE_V)
293 return false;
294 }
295
296 #undef AUDIO_CHANNEL_INDEX_MASK_LIST_DEF
297 #undef AUDIO_CHANNEL_IN_MASK_LIST_DEF
298 #undef AUDIO_CHANNEL_OUT_MASK_LIST_DEF
299 #undef AUDIO_CHANNEL_OUT_MASK_LIST_UNIQUE_DEF
300 #undef AUDIO_CHANNEL_IN_OUT_MASK_LIST_DEF
301 #undef AUDIO_CHANNEL_IN_DISCRETE_CHANNEL_LIST_DEF
302 #undef AUDIO_CHANNEL_OUT_DISCRETE_CHANNEL_LIST_DEF
303
304
305 #define AUDIO_CONTENT_TYPE_LIST_DEF(V) \
306 V(AUDIO_CONTENT_TYPE_UNKNOWN, 0) \
307 V(AUDIO_CONTENT_TYPE_SPEECH, 1) \
308 V(AUDIO_CONTENT_TYPE_MUSIC, 2) \
309 V(AUDIO_CONTENT_TYPE_MOVIE, 3) \
310 V(AUDIO_CONTENT_TYPE_SONIFICATION, 4) \
311 V(AUDIO_CONTENT_TYPE_ULTRASOUND, 1997)
312
313 typedef enum : int32_t {
314 AUDIO_CONTENT_TYPE_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL_V)
315 } audio_content_type_t;
316
audio_content_type_to_string(audio_content_type_t t)317 inline const char* audio_content_type_to_string(audio_content_type_t t) {
318 switch (t) {
319 AUDIO_CONTENT_TYPE_LIST_DEF(AUDIO_DEFINE_STRINGIFY_CASE_V)
320 }
321 return "";
322 }
323
audio_content_type_from_string(const char * s,audio_content_type_t * t)324 inline bool audio_content_type_from_string(const char* s, audio_content_type_t* t) {
325 AUDIO_CONTENT_TYPE_LIST_DEF(AUDIO_DEFINE_PARSE_CASE_V)
326 return false;
327 }
328
329 #undef AUDIO_CONTENT_TYPE_LIST_DEF
330
331
332 // Flags that never appear on their own.
333 enum {
334 AUDIO_DEVICE_BIT_IN = 0x80000000u,
335 AUDIO_DEVICE_BIT_DEFAULT = 0x40000000u,
336 };
337
338 #define AUDIO_DEVICE_LIST_UNIQUE_DEF(V) \
339 V(AUDIO_DEVICE_NONE, 0x0u) \
340 V(AUDIO_DEVICE_OUT_EARPIECE, 0x1u) \
341 V(AUDIO_DEVICE_OUT_SPEAKER, 0x2u) \
342 V(AUDIO_DEVICE_OUT_WIRED_HEADSET, 0x4u) \
343 V(AUDIO_DEVICE_OUT_WIRED_HEADPHONE, 0x8u) \
344 V(AUDIO_DEVICE_OUT_BLUETOOTH_SCO, 0x10u) \
345 V(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET, 0x20u) \
346 V(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT, 0x40u) \
347 V(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, 0x80u) \
348 V(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES, 0x100u) \
349 V(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER, 0x200u) \
350 V(AUDIO_DEVICE_OUT_HDMI, 0x400u) \
351 V(AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET, 0x800u) \
352 V(AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET, 0x1000u) \
353 V(AUDIO_DEVICE_OUT_USB_ACCESSORY, 0x2000u) \
354 V(AUDIO_DEVICE_OUT_USB_DEVICE, 0x4000u) \
355 V(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, 0x8000u) \
356 V(AUDIO_DEVICE_OUT_TELEPHONY_TX, 0x10000u) \
357 V(AUDIO_DEVICE_OUT_LINE, 0x20000u) \
358 V(AUDIO_DEVICE_OUT_HDMI_ARC, 0x40000u) \
359 V(AUDIO_DEVICE_OUT_HDMI_EARC, 0x40001u) \
360 V(AUDIO_DEVICE_OUT_SPDIF, 0x80000u) \
361 V(AUDIO_DEVICE_OUT_FM, 0x100000u) \
362 V(AUDIO_DEVICE_OUT_AUX_LINE, 0x200000u) \
363 V(AUDIO_DEVICE_OUT_SPEAKER_SAFE, 0x400000u) \
364 V(AUDIO_DEVICE_OUT_IP, 0x800000u) \
365 V(AUDIO_DEVICE_OUT_BUS, 0x1000000u) \
366 V(AUDIO_DEVICE_OUT_PROXY, 0x2000000u) \
367 V(AUDIO_DEVICE_OUT_USB_HEADSET, 0x4000000u) \
368 V(AUDIO_DEVICE_OUT_HEARING_AID, 0x8000000u) \
369 V(AUDIO_DEVICE_OUT_ECHO_CANCELLER, 0x10000000u) \
370 V(AUDIO_DEVICE_OUT_BLE_HEADSET, 0x20000000u) \
371 V(AUDIO_DEVICE_OUT_BLE_SPEAKER, 0x20000001u) \
372 V(AUDIO_DEVICE_OUT_BLE_BROADCAST, 0x20000002u) \
373 V(AUDIO_DEVICE_OUT_DEFAULT, AUDIO_DEVICE_BIT_DEFAULT) \
374 V(AUDIO_DEVICE_IN_COMMUNICATION, AUDIO_DEVICE_BIT_IN | 0x1u) \
375 V(AUDIO_DEVICE_IN_AMBIENT, AUDIO_DEVICE_BIT_IN | 0x2u) \
376 V(AUDIO_DEVICE_IN_BUILTIN_MIC, AUDIO_DEVICE_BIT_IN | 0x4u) \
377 V(AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET, AUDIO_DEVICE_BIT_IN | 0x8u) \
378 V(AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_BIT_IN | 0x10u) \
379 V(AUDIO_DEVICE_IN_HDMI, AUDIO_DEVICE_BIT_IN | 0x20u) \
380 V(AUDIO_DEVICE_IN_TELEPHONY_RX, AUDIO_DEVICE_BIT_IN | 0x40u) \
381 V(AUDIO_DEVICE_IN_BACK_MIC, AUDIO_DEVICE_BIT_IN | 0x80u) \
382 V(AUDIO_DEVICE_IN_REMOTE_SUBMIX, AUDIO_DEVICE_BIT_IN | 0x100u) \
383 V(AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET, AUDIO_DEVICE_BIT_IN | 0x200u) \
384 V(AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET, AUDIO_DEVICE_BIT_IN | 0x400u) \
385 V(AUDIO_DEVICE_IN_USB_ACCESSORY, AUDIO_DEVICE_BIT_IN | 0x800u) \
386 V(AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_BIT_IN | 0x1000u) \
387 V(AUDIO_DEVICE_IN_FM_TUNER, AUDIO_DEVICE_BIT_IN | 0x2000u) \
388 V(AUDIO_DEVICE_IN_TV_TUNER, AUDIO_DEVICE_BIT_IN | 0x4000u) \
389 V(AUDIO_DEVICE_IN_LINE, AUDIO_DEVICE_BIT_IN | 0x8000u) \
390 V(AUDIO_DEVICE_IN_SPDIF, AUDIO_DEVICE_BIT_IN | 0x10000u) \
391 V(AUDIO_DEVICE_IN_BLUETOOTH_A2DP, AUDIO_DEVICE_BIT_IN | 0x20000u) \
392 V(AUDIO_DEVICE_IN_LOOPBACK, AUDIO_DEVICE_BIT_IN | 0x40000u) \
393 V(AUDIO_DEVICE_IN_IP, AUDIO_DEVICE_BIT_IN | 0x80000u) \
394 V(AUDIO_DEVICE_IN_BUS, AUDIO_DEVICE_BIT_IN | 0x100000u) \
395 V(AUDIO_DEVICE_IN_PROXY, AUDIO_DEVICE_BIT_IN | 0x1000000u) \
396 V(AUDIO_DEVICE_IN_USB_HEADSET, AUDIO_DEVICE_BIT_IN | 0x2000000u) \
397 V(AUDIO_DEVICE_IN_BLUETOOTH_BLE, AUDIO_DEVICE_BIT_IN | 0x4000000u) \
398 V(AUDIO_DEVICE_IN_HDMI_ARC, AUDIO_DEVICE_BIT_IN | 0x8000000u) \
399 V(AUDIO_DEVICE_IN_HDMI_EARC, AUDIO_DEVICE_BIT_IN | 0x8000001u) \
400 V(AUDIO_DEVICE_IN_ECHO_REFERENCE, AUDIO_DEVICE_BIT_IN | 0x10000000u) \
401 V(AUDIO_DEVICE_IN_BLE_HEADSET, AUDIO_DEVICE_BIT_IN | 0x20000000u) \
402 V(AUDIO_DEVICE_IN_DEFAULT, AUDIO_DEVICE_BIT_IN | AUDIO_DEVICE_BIT_DEFAULT)
403 // Some of the device enums have aliases. They can not appear in the 'to string'
404 // converter as case values must be unique.
405 #define AUDIO_DEVICE_LIST_DEF(V) \
406 AUDIO_DEVICE_LIST_UNIQUE_DEF(V) \
407 V(AUDIO_DEVICE_OUT_AUX_DIGITAL, AUDIO_DEVICE_OUT_HDMI) \
408 V(AUDIO_DEVICE_OUT_STUB, AUDIO_DEVICE_OUT_DEFAULT) \
409 V(AUDIO_DEVICE_IN_VOICE_CALL, AUDIO_DEVICE_IN_TELEPHONY_RX) \
410 V(AUDIO_DEVICE_IN_AUX_DIGITAL, AUDIO_DEVICE_IN_HDMI) \
411 V(AUDIO_DEVICE_IN_STUB, AUDIO_DEVICE_IN_DEFAULT)
412
413 typedef enum : uint32_t {
414 AUDIO_DEVICE_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL_V)
415 } audio_devices_t;
416
audio_device_to_string(audio_devices_t t)417 inline const char* audio_device_to_string(audio_devices_t t) {
418 switch (t) {
419 AUDIO_DEVICE_LIST_UNIQUE_DEF(AUDIO_DEFINE_STRINGIFY_CASE_V)
420 }
421 return "";
422 }
423
audio_device_from_string(const char * s,audio_devices_t * t)424 inline bool audio_device_from_string(const char* s, audio_devices_t* t) {
425 AUDIO_DEVICE_LIST_DEF(AUDIO_DEFINE_PARSE_CASE_V)
426 return false;
427 }
428
429 #undef AUDIO_DEVICE_LIST_DEF
430 #undef AUDIO_DEVICE_LIST_UNIQUE_DEF
431
432
433 #define AUDIO_OUTPUT_FLAG_LIST_DEF(V) \
434 V(AUDIO_OUTPUT_FLAG_NONE, 0x0) \
435 V(AUDIO_OUTPUT_FLAG_DIRECT, 0x1) \
436 V(AUDIO_OUTPUT_FLAG_PRIMARY, 0x2) \
437 V(AUDIO_OUTPUT_FLAG_FAST, 0x4) \
438 V(AUDIO_OUTPUT_FLAG_DEEP_BUFFER, 0x8) \
439 V(AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD, 0x10) \
440 V(AUDIO_OUTPUT_FLAG_NON_BLOCKING, 0x20) \
441 V(AUDIO_OUTPUT_FLAG_HW_AV_SYNC, 0x40) \
442 V(AUDIO_OUTPUT_FLAG_TTS, 0x80) \
443 V(AUDIO_OUTPUT_FLAG_RAW, 0x100) \
444 V(AUDIO_OUTPUT_FLAG_SYNC, 0x200) \
445 V(AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO, 0x400) \
446 V(AUDIO_OUTPUT_FLAG_DIRECT_PCM, 0x2000) \
447 V(AUDIO_OUTPUT_FLAG_MMAP_NOIRQ, 0x4000) \
448 V(AUDIO_OUTPUT_FLAG_VOIP_RX, 0x8000) \
449 V(AUDIO_OUTPUT_FLAG_INCALL_MUSIC, 0x10000) \
450 V(AUDIO_OUTPUT_FLAG_GAPLESS_OFFLOAD, 0x20000) \
451 V(AUDIO_OUTPUT_FLAG_SPATIALIZER, 0x40000) \
452 V(AUDIO_OUTPUT_FLAG_ULTRASOUND, 0x80000) \
453 V(AUDIO_OUTPUT_FLAG_BIT_PERFECT, 0x100000)
454
455 typedef enum : uint32_t {
456 AUDIO_OUTPUT_FLAG_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL_V)
457 } audio_output_flags_t;
458
audio_output_flag_to_string(audio_output_flags_t t)459 inline const char* audio_output_flag_to_string(audio_output_flags_t t) {
460 switch (t) {
461 AUDIO_OUTPUT_FLAG_LIST_DEF(AUDIO_DEFINE_STRINGIFY_CASE_V)
462 }
463 return "";
464 }
465
audio_output_flag_from_string(const char * s,audio_output_flags_t * t)466 inline bool audio_output_flag_from_string(const char* s, audio_output_flags_t* t) {
467 AUDIO_OUTPUT_FLAG_LIST_DEF(AUDIO_DEFINE_PARSE_CASE_V)
468 return false;
469 }
470
471 #undef AUDIO_OUTPUT_FLAG_LIST_DEF
472
473
474 #define AUDIO_INPUT_FLAG_LIST_DEF(V) \
475 V(AUDIO_INPUT_FLAG_NONE, 0x0) \
476 V(AUDIO_INPUT_FLAG_FAST, 0x1) \
477 V(AUDIO_INPUT_FLAG_HW_HOTWORD, 0x2) \
478 V(AUDIO_INPUT_FLAG_RAW, 0x4) \
479 V(AUDIO_INPUT_FLAG_SYNC, 0x8) \
480 V(AUDIO_INPUT_FLAG_MMAP_NOIRQ, 0x10) \
481 V(AUDIO_INPUT_FLAG_VOIP_TX, 0x20) \
482 V(AUDIO_INPUT_FLAG_HW_AV_SYNC, 0x40) \
483 V(AUDIO_INPUT_FLAG_DIRECT, 0x80) \
484 V(AUDIO_INPUT_FLAG_ULTRASOUND, 0x100) \
485 V(AUDIO_INPUT_FLAG_HOTWORD_TAP, 0x200) \
486 V(AUDIO_INPUT_FLAG_HW_LOOKBACK, 0x400) \
487
488 typedef enum : uint32_t {
489 AUDIO_INPUT_FLAG_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL_V)
490 } audio_input_flags_t;
491
audio_input_flag_to_string(audio_input_flags_t t)492 inline const char* audio_input_flag_to_string(audio_input_flags_t t) {
493 switch (t) {
494 AUDIO_INPUT_FLAG_LIST_DEF(AUDIO_DEFINE_STRINGIFY_CASE_V)
495 }
496 return "";
497 }
498
audio_input_flag_from_string(const char * s,audio_input_flags_t * t)499 inline bool audio_input_flag_from_string(const char* s, audio_input_flags_t* t) {
500 AUDIO_INPUT_FLAG_LIST_DEF(AUDIO_DEFINE_PARSE_CASE_V)
501 return false;
502 }
503
504 #undef AUDIO_INPUT_FLAG_LIST_DEF
505
506
507 // Anonymous enum that provides building blocks for audio format enums.
508 // Because some of them are used on their own (e.g. masks), they retain 'AUDIO_FORMAT_' prefix.
509 enum {
510 AUDIO_FORMAT_MAIN_MASK = 0xFF000000u,
511 AUDIO_FORMAT_SUB_MASK = 0x00FFFFFFu,
512
513 AUDIO_FORMAT_PCM_MAIN = 0u,
514 AUDIO_FORMAT_PCM_SUB_16_BIT = 0x1u,
515 AUDIO_FORMAT_PCM_SUB_8_BIT = 0x2u,
516 AUDIO_FORMAT_PCM_SUB_32_BIT = 0x3u,
517 AUDIO_FORMAT_PCM_SUB_8_24_BIT = 0x4u,
518 AUDIO_FORMAT_PCM_SUB_FLOAT = 0x5u,
519 AUDIO_FORMAT_PCM_SUB_24_BIT_PACKED = 0x6u,
520
521 AUDIO_FORMAT_AAC_SUB_MAIN = 0x1u,
522 AUDIO_FORMAT_AAC_SUB_LC = 0x2u,
523 AUDIO_FORMAT_AAC_SUB_SSR = 0x4u,
524 AUDIO_FORMAT_AAC_SUB_LTP = 0x8u,
525 AUDIO_FORMAT_AAC_SUB_HE_V1 = 0x10u,
526 AUDIO_FORMAT_AAC_SUB_SCALABLE = 0x20u,
527 AUDIO_FORMAT_AAC_SUB_ERLC = 0x40u,
528 AUDIO_FORMAT_AAC_SUB_LD = 0x80u,
529 AUDIO_FORMAT_AAC_SUB_HE_V2 = 0x100u,
530 AUDIO_FORMAT_AAC_SUB_ELD = 0x200u,
531 AUDIO_FORMAT_AAC_SUB_XHE = 0x300u,
532
533 AUDIO_FORMAT_E_AC3_SUB_JOC = 0x1u,
534
535 AUDIO_FORMAT_MAT_SUB_1_0 = 0x1u,
536 AUDIO_FORMAT_MAT_SUB_2_0 = 0x2u,
537 AUDIO_FORMAT_MAT_SUB_2_1 = 0x3u,
538
539 AUDIO_FORMAT_MPEGH_SUB_BL_L3 = 0x13u,
540 AUDIO_FORMAT_MPEGH_SUB_BL_L4 = 0x14u,
541 AUDIO_FORMAT_MPEGH_SUB_LC_L3 = 0x23u,
542 AUDIO_FORMAT_MPEGH_SUB_LC_L4 = 0x24u,
543 };
544
545 #define AUDIO_FORMAT_LIST_UNIQUE_DEF(V) \
546 V(AUDIO_FORMAT_DEFAULT, AUDIO_FORMAT_PCM_MAIN) \
547 V(AUDIO_FORMAT_PCM_16_BIT, AUDIO_FORMAT_PCM_MAIN | AUDIO_FORMAT_PCM_SUB_16_BIT) \
548 V(AUDIO_FORMAT_PCM_8_BIT, AUDIO_FORMAT_PCM_MAIN | AUDIO_FORMAT_PCM_SUB_8_BIT) \
549 V(AUDIO_FORMAT_PCM_32_BIT, AUDIO_FORMAT_PCM_MAIN | AUDIO_FORMAT_PCM_SUB_32_BIT) \
550 V(AUDIO_FORMAT_PCM_8_24_BIT, AUDIO_FORMAT_PCM_MAIN | AUDIO_FORMAT_PCM_SUB_8_24_BIT) \
551 V(AUDIO_FORMAT_PCM_FLOAT, AUDIO_FORMAT_PCM_MAIN | AUDIO_FORMAT_PCM_SUB_FLOAT) \
552 V(AUDIO_FORMAT_PCM_24_BIT_PACKED, AUDIO_FORMAT_PCM_MAIN | AUDIO_FORMAT_PCM_SUB_24_BIT_PACKED) \
553 V(AUDIO_FORMAT_MP3, 0x01000000u) \
554 V(AUDIO_FORMAT_AMR_NB, 0x02000000u) \
555 V(AUDIO_FORMAT_AMR_WB, 0x03000000u) \
556 V(AUDIO_FORMAT_AAC, 0x04000000u) \
557 V(AUDIO_FORMAT_AAC_MAIN, AUDIO_FORMAT_AAC | AUDIO_FORMAT_AAC_SUB_MAIN) \
558 V(AUDIO_FORMAT_AAC_LC, AUDIO_FORMAT_AAC | AUDIO_FORMAT_AAC_SUB_LC) \
559 V(AUDIO_FORMAT_AAC_SSR, AUDIO_FORMAT_AAC | AUDIO_FORMAT_AAC_SUB_SSR) \
560 V(AUDIO_FORMAT_AAC_LTP, AUDIO_FORMAT_AAC | AUDIO_FORMAT_AAC_SUB_LTP) \
561 V(AUDIO_FORMAT_AAC_HE_V1, AUDIO_FORMAT_AAC | AUDIO_FORMAT_AAC_SUB_HE_V1) \
562 V(AUDIO_FORMAT_AAC_SCALABLE, AUDIO_FORMAT_AAC | AUDIO_FORMAT_AAC_SUB_SCALABLE) \
563 V(AUDIO_FORMAT_AAC_ERLC, AUDIO_FORMAT_AAC | AUDIO_FORMAT_AAC_SUB_ERLC) \
564 V(AUDIO_FORMAT_AAC_LD, AUDIO_FORMAT_AAC | AUDIO_FORMAT_AAC_SUB_LD) \
565 V(AUDIO_FORMAT_AAC_HE_V2, AUDIO_FORMAT_AAC | AUDIO_FORMAT_AAC_SUB_HE_V2) \
566 V(AUDIO_FORMAT_AAC_ELD, AUDIO_FORMAT_AAC | AUDIO_FORMAT_AAC_SUB_ELD) \
567 V(AUDIO_FORMAT_AAC_XHE, AUDIO_FORMAT_AAC | AUDIO_FORMAT_AAC_SUB_XHE) \
568 V(AUDIO_FORMAT_HE_AAC_V1, 0x05000000u) \
569 V(AUDIO_FORMAT_HE_AAC_V2, 0x06000000u) \
570 V(AUDIO_FORMAT_VORBIS, 0x07000000u) \
571 V(AUDIO_FORMAT_OPUS, 0x08000000u) \
572 V(AUDIO_FORMAT_AC3, 0x09000000u) \
573 V(AUDIO_FORMAT_E_AC3, 0x0A000000u) \
574 V(AUDIO_FORMAT_E_AC3_JOC, AUDIO_FORMAT_E_AC3 | AUDIO_FORMAT_E_AC3_SUB_JOC) \
575 V(AUDIO_FORMAT_DTS, 0x0B000000u) \
576 V(AUDIO_FORMAT_DTS_HD, 0x0C000000u) \
577 V(AUDIO_FORMAT_IEC61937, 0x0D000000u) \
578 V(AUDIO_FORMAT_DOLBY_TRUEHD, 0x0E000000u) \
579 V(AUDIO_FORMAT_EVRC, 0x10000000u) \
580 V(AUDIO_FORMAT_EVRCB, 0x11000000u) \
581 V(AUDIO_FORMAT_EVRCWB, 0x12000000u) \
582 V(AUDIO_FORMAT_EVRCNW, 0x13000000u) \
583 V(AUDIO_FORMAT_AAC_ADIF, 0x14000000u) \
584 V(AUDIO_FORMAT_WMA, 0x15000000u) \
585 V(AUDIO_FORMAT_WMA_PRO, 0x16000000u) \
586 V(AUDIO_FORMAT_AMR_WB_PLUS, 0x17000000u) \
587 V(AUDIO_FORMAT_MP2, 0x18000000u) \
588 V(AUDIO_FORMAT_QCELP, 0x19000000u) \
589 V(AUDIO_FORMAT_DSD, 0x1A000000u) \
590 V(AUDIO_FORMAT_FLAC, 0x1B000000u) \
591 V(AUDIO_FORMAT_ALAC, 0x1C000000u) \
592 V(AUDIO_FORMAT_APE, 0x1D000000u) \
593 V(AUDIO_FORMAT_AAC_ADTS, 0x1E000000u) \
594 V(AUDIO_FORMAT_AAC_ADTS_MAIN, AUDIO_FORMAT_AAC_ADTS | AUDIO_FORMAT_AAC_SUB_MAIN) \
595 V(AUDIO_FORMAT_AAC_ADTS_LC, AUDIO_FORMAT_AAC_ADTS | AUDIO_FORMAT_AAC_SUB_LC) \
596 V(AUDIO_FORMAT_AAC_ADTS_SSR, AUDIO_FORMAT_AAC_ADTS | AUDIO_FORMAT_AAC_SUB_SSR) \
597 V(AUDIO_FORMAT_AAC_ADTS_LTP, AUDIO_FORMAT_AAC_ADTS | AUDIO_FORMAT_AAC_SUB_LTP) \
598 V(AUDIO_FORMAT_AAC_ADTS_HE_V1, AUDIO_FORMAT_AAC_ADTS | AUDIO_FORMAT_AAC_SUB_HE_V1) \
599 V(AUDIO_FORMAT_AAC_ADTS_SCALABLE, AUDIO_FORMAT_AAC_ADTS | AUDIO_FORMAT_AAC_SUB_SCALABLE) \
600 V(AUDIO_FORMAT_AAC_ADTS_ERLC, AUDIO_FORMAT_AAC_ADTS | AUDIO_FORMAT_AAC_SUB_ERLC) \
601 V(AUDIO_FORMAT_AAC_ADTS_LD, AUDIO_FORMAT_AAC_ADTS | AUDIO_FORMAT_AAC_SUB_LD) \
602 V(AUDIO_FORMAT_AAC_ADTS_HE_V2, AUDIO_FORMAT_AAC_ADTS | AUDIO_FORMAT_AAC_SUB_HE_V2) \
603 V(AUDIO_FORMAT_AAC_ADTS_ELD, AUDIO_FORMAT_AAC_ADTS | AUDIO_FORMAT_AAC_SUB_ELD) \
604 V(AUDIO_FORMAT_AAC_ADTS_XHE, AUDIO_FORMAT_AAC_ADTS | AUDIO_FORMAT_AAC_SUB_XHE) \
605 V(AUDIO_FORMAT_SBC, 0x1F000000u) \
606 V(AUDIO_FORMAT_APTX, 0x20000000u) \
607 V(AUDIO_FORMAT_APTX_HD, 0x21000000u) \
608 V(AUDIO_FORMAT_AC4, 0x22000000u) \
609 V(AUDIO_FORMAT_LDAC, 0x23000000u) \
610 V(AUDIO_FORMAT_MAT, 0x24000000u) \
611 V(AUDIO_FORMAT_MAT_1_0, AUDIO_FORMAT_MAT | AUDIO_FORMAT_MAT_SUB_1_0) \
612 V(AUDIO_FORMAT_MAT_2_0, AUDIO_FORMAT_MAT | AUDIO_FORMAT_MAT_SUB_2_0) \
613 V(AUDIO_FORMAT_MAT_2_1, AUDIO_FORMAT_MAT | AUDIO_FORMAT_MAT_SUB_2_1) \
614 V(AUDIO_FORMAT_AAC_LATM, 0x25000000u) \
615 V(AUDIO_FORMAT_AAC_LATM_LC, AUDIO_FORMAT_AAC_LATM | AUDIO_FORMAT_AAC_SUB_LC) \
616 V(AUDIO_FORMAT_AAC_LATM_HE_V1, AUDIO_FORMAT_AAC_LATM | AUDIO_FORMAT_AAC_SUB_HE_V1) \
617 V(AUDIO_FORMAT_AAC_LATM_HE_V2, AUDIO_FORMAT_AAC_LATM | AUDIO_FORMAT_AAC_SUB_HE_V2) \
618 V(AUDIO_FORMAT_CELT, 0x26000000u) \
619 V(AUDIO_FORMAT_APTX_ADAPTIVE, 0x27000000u) \
620 V(AUDIO_FORMAT_LHDC, 0x28000000u) \
621 V(AUDIO_FORMAT_LHDC_LL, 0x29000000u) \
622 V(AUDIO_FORMAT_APTX_TWSP, 0x2A000000u) \
623 V(AUDIO_FORMAT_LC3, 0x2B000000u) \
624 V(AUDIO_FORMAT_MPEGH, 0x2C000000u) \
625 V(AUDIO_FORMAT_MPEGH_BL_L3, AUDIO_FORMAT_MPEGH | AUDIO_FORMAT_MPEGH_SUB_BL_L3) \
626 V(AUDIO_FORMAT_MPEGH_BL_L4, AUDIO_FORMAT_MPEGH | AUDIO_FORMAT_MPEGH_SUB_BL_L4) \
627 V(AUDIO_FORMAT_MPEGH_LC_L3, AUDIO_FORMAT_MPEGH | AUDIO_FORMAT_MPEGH_SUB_LC_L3) \
628 V(AUDIO_FORMAT_MPEGH_LC_L4, AUDIO_FORMAT_MPEGH | AUDIO_FORMAT_MPEGH_SUB_LC_L4) \
629 V(AUDIO_FORMAT_IEC60958, 0x2D000000u) \
630 V(AUDIO_FORMAT_DTS_UHD, 0x2E000000u) \
631 V(AUDIO_FORMAT_DRA, 0x2F000000u) \
632 V(AUDIO_FORMAT_APTX_ADAPTIVE_QLEA, 0x30000000u) \
633 V(AUDIO_FORMAT_APTX_ADAPTIVE_R4, 0x31000000u) \
634 V(AUDIO_FORMAT_DTS_HD_MA, 0x32000000u) \
635 V(AUDIO_FORMAT_DTS_UHD_P2, 0x33000000u)
636
637 #define AUDIO_FORMAT_LIST_DEF(V) \
638 AUDIO_FORMAT_LIST_UNIQUE_DEF(V) \
639 V(VX_AUDIO_FORMAT_LC3, AUDIO_FORMAT_LC3)
640
641 typedef enum : uint32_t {
642 AUDIO_FORMAT_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL_V)
643 // These values must be part of the enum, but they are not valid formats,
644 // and thus don't participate in to/from string conversions.
645 AUDIO_FORMAT_INVALID = 0xFFFFFFFFu,
646 AUDIO_FORMAT_PCM = AUDIO_FORMAT_PCM_MAIN,
647 } audio_format_t;
648
audio_format_to_string(audio_format_t t)649 inline const char* audio_format_to_string(audio_format_t t) {
650 switch (t) {
651 AUDIO_FORMAT_LIST_UNIQUE_DEF(AUDIO_DEFINE_STRINGIFY_CASE_V)
652 default:
653 return "";
654 }
655 }
656
audio_format_from_string(const char * s,audio_format_t * t)657 inline bool audio_format_from_string(const char* s, audio_format_t* t) {
658 AUDIO_FORMAT_LIST_DEF(AUDIO_DEFINE_PARSE_CASE_V)
659 return false;
660 }
661
662 #undef AUDIO_FORMAT_LIST_DEF
663 #undef AUDIO_FORMAT_LIST_UNIQUE_DEF
664
665 #define AUDIO_GAIN_MODE_LIST_DEF(V) \
666 V(AUDIO_GAIN_MODE_JOINT, 1) \
667 V(AUDIO_GAIN_MODE_CHANNELS, 2) \
668 V(AUDIO_GAIN_MODE_RAMP, 4)
669
670 typedef enum : uint32_t {
671 AUDIO_GAIN_MODE_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL_V)
672 } audio_gain_mode_t;
673
audio_gain_mode_to_string(audio_gain_mode_t t)674 inline const char* audio_gain_mode_to_string(audio_gain_mode_t t) {
675 switch (t) {
676 AUDIO_GAIN_MODE_LIST_DEF(AUDIO_DEFINE_STRINGIFY_CASE_V)
677 }
678 return "";
679 }
680
audio_gain_mode_from_string(const char * s,audio_gain_mode_t * t)681 inline bool audio_gain_mode_from_string(const char* s, audio_gain_mode_t* t) {
682 AUDIO_GAIN_MODE_LIST_DEF(AUDIO_DEFINE_PARSE_CASE_V)
683 return false;
684 }
685
686 #undef AUDIO_GAIN_MODE_LIST_DEF
687
688
689 #define AUDIO_SOURCE_LIST_NO_SYS_DEF(V) \
690 V(AUDIO_SOURCE_DEFAULT, 0) \
691 V(AUDIO_SOURCE_MIC, 1) \
692 V(AUDIO_SOURCE_VOICE_UPLINK, 2) \
693 V(AUDIO_SOURCE_VOICE_DOWNLINK, 3) \
694 V(AUDIO_SOURCE_VOICE_CALL, 4) \
695 V(AUDIO_SOURCE_CAMCORDER, 5) \
696 V(AUDIO_SOURCE_VOICE_RECOGNITION, 6) \
697 V(AUDIO_SOURCE_VOICE_COMMUNICATION, 7) \
698 V(AUDIO_SOURCE_REMOTE_SUBMIX, 8) \
699 V(AUDIO_SOURCE_UNPROCESSED, 9) \
700 V(AUDIO_SOURCE_VOICE_PERFORMANCE, 10) \
701 V(AUDIO_SOURCE_ECHO_REFERENCE, 1997) \
702 V(AUDIO_SOURCE_FM_TUNER, 1998) \
703 V(AUDIO_SOURCE_HOTWORD, 1999) \
704 V(AUDIO_SOURCE_ULTRASOUND, 2000)
705 #ifdef AUDIO_NO_SYSTEM_DECLARATIONS
706 #define AUDIO_SOURCE_LIST_DEF AUDIO_SOURCE_LIST_NO_SYS_DEF
707 #else
708 #define AUDIO_SOURCE_LIST_DEF(V) \
709 AUDIO_SOURCE_LIST_NO_SYS_DEF(V) \
710 V(AUDIO_SOURCE_INVALID, -1)
711 #endif // AUDIO_NO_SYSTEM_DECLARATIONS
712
713 typedef enum : int32_t {
714 AUDIO_SOURCE_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL_V)
715 } audio_source_t;
716
audio_source_to_string(audio_source_t t)717 inline const char* audio_source_to_string(audio_source_t t) {
718 switch (t) {
719 AUDIO_SOURCE_LIST_DEF(AUDIO_DEFINE_STRINGIFY_CASE_V)
720 }
721 return "";
722 }
723
audio_source_from_string(const char * s,audio_source_t * t)724 inline bool audio_source_from_string(const char* s, audio_source_t* t) {
725 AUDIO_SOURCE_LIST_NO_SYS_DEF(AUDIO_DEFINE_PARSE_CASE_V)
726 return false;
727 }
728
729 #undef AUDIO_SOURCE_LIST_DEF
730 #undef AUDIO_SOURCE_LIST_NO_SYS_DEF
731
732 #define AUDIO_STREAM_LIST_NO_SYS_DEF(V) \
733 V(AUDIO_STREAM_VOICE_CALL, 0) \
734 V(AUDIO_STREAM_SYSTEM, 1) \
735 V(AUDIO_STREAM_RING, 2) \
736 V(AUDIO_STREAM_MUSIC, 3) \
737 V(AUDIO_STREAM_ALARM, 4) \
738 V(AUDIO_STREAM_NOTIFICATION, 5) \
739 V(AUDIO_STREAM_BLUETOOTH_SCO, 6) \
740 V(AUDIO_STREAM_ENFORCED_AUDIBLE, 7) \
741 V(AUDIO_STREAM_DTMF, 8) \
742 V(AUDIO_STREAM_TTS, 9) \
743 V(AUDIO_STREAM_ACCESSIBILITY, 10) \
744 V(AUDIO_STREAM_ASSISTANT, 11) \
745 V(AUDIO_STREAM_REROUTING, 12) \
746 V(AUDIO_STREAM_PATCH, 13) \
747 V(AUDIO_STREAM_CALL_ASSISTANT, 14)
748 #ifdef AUDIO_NO_SYSTEM_DECLARATIONS
749 #define AUDIO_STREAM_LIST_DEF AUDIO_STREAM_LIST_NO_SYS_DEF
750 #else
751 #define AUDIO_STREAM_LIST_DEF(V) \
752 AUDIO_STREAM_LIST_NO_SYS_DEF(V) \
753 V(AUDIO_STREAM_DEFAULT, -1)
754 #endif // AUDIO_NO_SYSTEM_DECLARATIONS
755
756 typedef enum : int32_t {
757 AUDIO_STREAM_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL_V)
758 } audio_stream_type_t;
759
audio_stream_type_to_string(audio_stream_type_t t)760 inline const char* audio_stream_type_to_string(audio_stream_type_t t) {
761 switch (t) {
762 AUDIO_STREAM_LIST_DEF(AUDIO_DEFINE_STRINGIFY_CASE_V)
763 }
764 return "";
765 }
766
audio_stream_type_from_string(const char * s,audio_stream_type_t * t)767 inline bool audio_stream_type_from_string(const char* s, audio_stream_type_t* t) {
768 AUDIO_STREAM_LIST_NO_SYS_DEF(AUDIO_DEFINE_PARSE_CASE_V)
769 return false;
770 }
771
772 #undef AUDIO_STREAM_LIST_DEF
773 #undef AUDIO_STREAM_LIST_NO_SYS_DEF
774
775
776 #define AUDIO_USAGE_LIST_NO_SYS_DEF(V) \
777 V(AUDIO_USAGE_UNKNOWN, 0) \
778 V(AUDIO_USAGE_MEDIA, 1) \
779 V(AUDIO_USAGE_VOICE_COMMUNICATION, 2) \
780 V(AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING, 3) \
781 V(AUDIO_USAGE_ALARM, 4) \
782 V(AUDIO_USAGE_NOTIFICATION, 5) \
783 V(AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE, 6) \
784 V(AUDIO_USAGE_NOTIFICATION_EVENT, 10) \
785 V(AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY, 11) \
786 V(AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE, 12) \
787 V(AUDIO_USAGE_ASSISTANCE_SONIFICATION, 13) \
788 V(AUDIO_USAGE_GAME, 14) \
789 V(AUDIO_USAGE_VIRTUAL_SOURCE, 15) \
790 V(AUDIO_USAGE_ASSISTANT, 16) \
791 V(AUDIO_USAGE_CALL_ASSISTANT, 17) \
792 V(AUDIO_USAGE_EMERGENCY, 1000) \
793 V(AUDIO_USAGE_SAFETY, 1001) \
794 V(AUDIO_USAGE_VEHICLE_STATUS, 1002) \
795 V(AUDIO_USAGE_ANNOUNCEMENT, 1003)
796 #ifdef AUDIO_NO_SYSTEM_DECLARATIONS
797 #define AUDIO_USAGE_LIST_DEF AUDIO_USAGE_LIST_NO_SYS_DEF
798 #else
799 #define AUDIO_USAGE_LIST_DEF(V) \
800 AUDIO_USAGE_LIST_NO_SYS_DEF(V) \
801 V(AUDIO_USAGE_NOTIFICATION_COMMUNICATION_REQUEST, 7) \
802 V(AUDIO_USAGE_NOTIFICATION_COMMUNICATION_INSTANT, 8) \
803 V(AUDIO_USAGE_NOTIFICATION_COMMUNICATION_DELAYED, 9)
804 #endif // AUDIO_NO_SYSTEM_DECLARATIONS
805
806 typedef enum : int32_t {
807 AUDIO_USAGE_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL_V)
808 } audio_usage_t;
809
audio_usage_to_string(audio_usage_t t)810 inline const char* audio_usage_to_string(audio_usage_t t) {
811 switch (t) {
812 AUDIO_USAGE_LIST_DEF(AUDIO_DEFINE_STRINGIFY_CASE_V)
813 }
814 return "";
815 }
816
audio_usage_from_string(const char * s,audio_usage_t * t)817 inline bool audio_usage_from_string(const char* s, audio_usage_t* t) {
818 AUDIO_USAGE_LIST_DEF(AUDIO_DEFINE_PARSE_CASE_V)
819 return false;
820 }
821
822 #undef AUDIO_USAGE_LIST_NO_SYS_DEF
823 #undef AUDIO_USAGE_LIST_DEF
824
825 #define AUDIO_ENCAPSULATION_TYPE_LIST_DEF(V) \
826 V(AUDIO_ENCAPSULATION_TYPE_NONE, 0) \
827 V(AUDIO_ENCAPSULATION_TYPE_IEC61937, 1) \
828 V(AUDIO_ENCAPSULATION_TYPE_PCM, 2)
829
830 typedef enum : int32_t {
831 AUDIO_ENCAPSULATION_TYPE_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL_V)
832 } audio_encapsulation_type_t;
833
audio_encapsulation_type_to_string(audio_encapsulation_type_t t)834 inline const char* audio_encapsulation_type_to_string(audio_encapsulation_type_t t) {
835 switch (t) {
836 AUDIO_ENCAPSULATION_TYPE_LIST_DEF(AUDIO_DEFINE_STRINGIFY_CASE_V)
837 }
838 return "";
839 }
840
audio_encapsulation_type_from_string(const char * s,audio_encapsulation_type_t * t)841 inline bool audio_encapsulation_type_from_string(const char* s, audio_encapsulation_type_t* t) {
842 AUDIO_ENCAPSULATION_TYPE_LIST_DEF(AUDIO_DEFINE_PARSE_CASE_V)
843 return false;
844 }
845
846 #undef AUDIO_ENCAPSULATION_TYPE_LIST_DEF
847
848 #undef AUDIO_DEFINE_PARSE_CASE_V
849 #undef AUDIO_DEFINE_PARSE_CASE
850 #undef AUDIO_DEFINE_STRINGIFY_CASE_V
851 #undef AUDIO_DEFINE_STRINGIFY_CASE
852 #undef AUDIO_DEFINE_BIT_MASK_V
853 #undef AUDIO_DEFINE_BIT_MASK
854 #undef AUDIO_DEFINE_ENUM_SYMBOL_V
855 #undef AUDIO_DEFINE_ENUM_SYMBOL
856 #undef AUDIO_ENUM_STRINGIFY
857 #undef AUDIO_ENUM_QUOTE
858
859 __END_DECLS
860
861 #endif // ANDROID_AUDIO_HAL_ENUMS_H
862