1 /*
2 * Copyright (C) 2016 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 <media/TypeConverter.h>
18
19 namespace android {
20
21 #define MAKE_STRING_FROM_ENUM(string) { #string, string }
22 #define TERMINATOR { .literal = nullptr }
23
24 template <>
25 const OutputDeviceConverter::Table OutputDeviceConverter::mTable[] = {
26 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_NONE),
27 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_EARPIECE),
28 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_SPEAKER),
29 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_SPEAKER_SAFE),
30 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_WIRED_HEADSET),
31 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_WIRED_HEADPHONE),
32 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_BLUETOOTH_SCO),
33 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET),
34 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT),
35 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_ALL_SCO),
36 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP),
37 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES),
38 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER),
39 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_ALL_A2DP),
40 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_AUX_DIGITAL),
41 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_HDMI),
42 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET),
43 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET),
44 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_USB_ACCESSORY),
45 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_USB_DEVICE),
46 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_ALL_USB),
47 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_REMOTE_SUBMIX),
48 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_TELEPHONY_TX),
49 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_LINE),
50 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_HDMI_ARC),
51 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_SPDIF),
52 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_FM),
53 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_AUX_LINE),
54 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_IP),
55 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_BUS),
56 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_PROXY),
57 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_USB_HEADSET),
58 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_HEARING_AID),
59 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_ECHO_CANCELLER),
60 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_DEFAULT),
61 // STUB must be after DEFAULT, so the latter is picked up by toString first.
62 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_STUB),
63 TERMINATOR
64 };
65
66 template <>
67 const InputDeviceConverter::Table InputDeviceConverter::mTable[] = {
68 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_NONE),
69 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_COMMUNICATION),
70 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_AMBIENT),
71 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BUILTIN_MIC),
72 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET),
73 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_ALL_SCO),
74 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_WIRED_HEADSET),
75 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_AUX_DIGITAL),
76 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_HDMI),
77 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_HDMI_ARC),
78 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_TELEPHONY_RX),
79 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_VOICE_CALL),
80 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BACK_MIC),
81 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_REMOTE_SUBMIX),
82 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET),
83 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET),
84 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_USB_ACCESSORY),
85 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_USB_DEVICE),
86 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_ALL_USB),
87 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_FM_TUNER),
88 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_TV_TUNER),
89 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_LINE),
90 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_SPDIF),
91 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BLUETOOTH_A2DP),
92 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_LOOPBACK),
93 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_IP),
94 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BUS),
95 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_PROXY),
96 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_USB_HEADSET),
97 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BLUETOOTH_BLE),
98 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_ECHO_REFERENCE),
99 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_DEFAULT),
100 // STUB must be after DEFAULT, so the latter is picked up by toString first.
101 MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_STUB),
102 TERMINATOR
103 };
104
105
106 template <>
107 const OutputFlagConverter::Table OutputFlagConverter::mTable[] = {
108 MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_NONE),
109 MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_DIRECT),
110 MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_PRIMARY),
111 MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_FAST),
112 MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_DEEP_BUFFER),
113 MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD),
114 MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_NON_BLOCKING),
115 MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_HW_AV_SYNC),
116 MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_TTS),
117 MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_RAW),
118 MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_SYNC),
119 MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO),
120 MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_DIRECT_PCM),
121 MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_MMAP_NOIRQ),
122 MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_VOIP_RX),
123 MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_INCALL_MUSIC),
124 TERMINATOR
125 };
126
127
128 template <>
129 const InputFlagConverter::Table InputFlagConverter::mTable[] = {
130 MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_NONE),
131 MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_FAST),
132 MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_HW_HOTWORD),
133 MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_RAW),
134 MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_SYNC),
135 MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_MMAP_NOIRQ),
136 MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_VOIP_TX),
137 MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_HW_AV_SYNC),
138 MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_DIRECT),
139 TERMINATOR
140 };
141
142
143 template <>
144 const FormatConverter::Table FormatConverter::mTable[] = {
145 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_16_BIT),
146 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_8_BIT),
147 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_32_BIT),
148 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_8_24_BIT),
149 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_FLOAT),
150 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_24_BIT_PACKED),
151 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_MP3),
152 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AMR_NB),
153 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AMR_WB),
154 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC),
155 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_MAIN),
156 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_LC),
157 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_SSR),
158 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_LTP),
159 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_HE_V1),
160 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_SCALABLE),
161 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ERLC),
162 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_LD),
163 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_HE_V2),
164 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ELD),
165 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_XHE),
166 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ADTS_MAIN),
167 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ADTS_LC),
168 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ADTS_SSR),
169 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ADTS_LTP),
170 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ADTS_HE_V1),
171 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ADTS_SCALABLE),
172 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ADTS_ERLC),
173 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ADTS_LD),
174 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ADTS_HE_V2),
175 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ADTS_ELD),
176 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ADTS_XHE),
177 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_VORBIS),
178 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_HE_AAC_V1),
179 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_HE_AAC_V2),
180 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_OPUS),
181 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AC3),
182 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_E_AC3),
183 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_DTS),
184 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_DTS_HD),
185 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_IEC61937),
186 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_DOLBY_TRUEHD),
187 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_EVRC),
188 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_EVRCB),
189 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_EVRCWB),
190 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_EVRCNW),
191 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ADIF),
192 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_WMA),
193 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_WMA_PRO),
194 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AMR_WB_PLUS),
195 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_MP2),
196 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_QCELP),
197 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_DSD),
198 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_FLAC),
199 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_ALAC),
200 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_APE),
201 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ADTS),
202 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_SBC),
203 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_APTX),
204 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_APTX_HD),
205 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AC4),
206 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_LDAC),
207 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_MAT),
208 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_E_AC3_JOC),
209 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_MAT_1_0),
210 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_MAT_2_0),
211 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_MAT_2_1),
212 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_LATM),
213 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_LATM_LC),
214 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_LATM_HE_V1),
215 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_LATM_HE_V2),
216 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_CELT),
217 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_APTX_ADAPTIVE),
218 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_LHDC),
219 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_LHDC_LL),
220 MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_APTX_TWSP),
221 TERMINATOR
222 };
223
224
225 template <>
226 const OutputChannelConverter::Table OutputChannelConverter::mTable[] = {
227 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_MONO),
228 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_STEREO),
229 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_2POINT1),
230 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_2POINT0POINT2),
231 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_2POINT1POINT2),
232 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_TRI),
233 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_TRI_BACK),
234 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_3POINT1),
235 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_3POINT0POINT2),
236 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_3POINT1POINT2),
237 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_QUAD),
238 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_QUAD_BACK),
239 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_QUAD_SIDE),
240 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_SURROUND),
241 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_PENTA),
242 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_5POINT1),
243 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_5POINT1_BACK),
244 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_5POINT1_SIDE),
245 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_5POINT1POINT2),
246 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_5POINT1POINT4),
247 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_6POINT1),
248 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_7POINT1),
249 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_7POINT1POINT2),
250 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_7POINT1POINT4),
251 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_HAPTIC_A),
252 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_MONO_HAPTIC_A),
253 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_STEREO_HAPTIC_A),
254 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_HAPTIC_AB),
255 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_MONO_HAPTIC_AB),
256 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_STEREO_HAPTIC_AB),
257 TERMINATOR
258 };
259
260
261 template <>
262 const InputChannelConverter::Table InputChannelConverter::mTable[] = {
263 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_MONO),
264 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_STEREO),
265 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_FRONT_BACK),
266 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_6),
267 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_2POINT0POINT2),
268 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_2POINT1POINT2),
269 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_3POINT0POINT2),
270 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_3POINT1POINT2),
271 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_5POINT1),
272 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_VOICE_UPLINK_MONO),
273 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_VOICE_DNLINK_MONO),
274 MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_VOICE_CALL_MONO),
275 TERMINATOR
276 };
277
278 template <>
279 const ChannelIndexConverter::Table ChannelIndexConverter::mTable[] = {
280 {"AUDIO_CHANNEL_INDEX_MASK_1", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_1)},
281 {"AUDIO_CHANNEL_INDEX_MASK_2", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_2)},
282 {"AUDIO_CHANNEL_INDEX_MASK_3", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_3)},
283 {"AUDIO_CHANNEL_INDEX_MASK_4", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_4)},
284 {"AUDIO_CHANNEL_INDEX_MASK_5", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_5)},
285 {"AUDIO_CHANNEL_INDEX_MASK_6", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_6)},
286 {"AUDIO_CHANNEL_INDEX_MASK_7", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_7)},
287 {"AUDIO_CHANNEL_INDEX_MASK_8", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_8)},
288 TERMINATOR
289 };
290
291
292 template <>
293 const GainModeConverter::Table GainModeConverter::mTable[] = {
294 MAKE_STRING_FROM_ENUM(AUDIO_GAIN_MODE_JOINT),
295 MAKE_STRING_FROM_ENUM(AUDIO_GAIN_MODE_CHANNELS),
296 MAKE_STRING_FROM_ENUM(AUDIO_GAIN_MODE_RAMP),
297 TERMINATOR
298 };
299
300
301 template <>
302 const StreamTypeConverter::Table StreamTypeConverter::mTable[] = {
303 MAKE_STRING_FROM_ENUM(AUDIO_STREAM_DEFAULT),
304 MAKE_STRING_FROM_ENUM(AUDIO_STREAM_VOICE_CALL),
305 MAKE_STRING_FROM_ENUM(AUDIO_STREAM_SYSTEM),
306 MAKE_STRING_FROM_ENUM(AUDIO_STREAM_RING),
307 MAKE_STRING_FROM_ENUM(AUDIO_STREAM_MUSIC),
308 MAKE_STRING_FROM_ENUM(AUDIO_STREAM_ALARM),
309 MAKE_STRING_FROM_ENUM(AUDIO_STREAM_NOTIFICATION),
310 MAKE_STRING_FROM_ENUM(AUDIO_STREAM_BLUETOOTH_SCO ),
311 MAKE_STRING_FROM_ENUM(AUDIO_STREAM_ENFORCED_AUDIBLE),
312 MAKE_STRING_FROM_ENUM(AUDIO_STREAM_DTMF),
313 MAKE_STRING_FROM_ENUM(AUDIO_STREAM_TTS),
314 MAKE_STRING_FROM_ENUM(AUDIO_STREAM_ACCESSIBILITY),
315 MAKE_STRING_FROM_ENUM(AUDIO_STREAM_ASSISTANT),
316 MAKE_STRING_FROM_ENUM(AUDIO_STREAM_REROUTING),
317 MAKE_STRING_FROM_ENUM(AUDIO_STREAM_PATCH),
318 TERMINATOR
319 };
320
321 template<>
322 const AudioModeConverter::Table AudioModeConverter::mTable[] = {
323 MAKE_STRING_FROM_ENUM(AUDIO_MODE_INVALID),
324 MAKE_STRING_FROM_ENUM(AUDIO_MODE_CURRENT),
325 MAKE_STRING_FROM_ENUM(AUDIO_MODE_NORMAL),
326 MAKE_STRING_FROM_ENUM(AUDIO_MODE_RINGTONE),
327 MAKE_STRING_FROM_ENUM(AUDIO_MODE_IN_CALL),
328 MAKE_STRING_FROM_ENUM(AUDIO_MODE_IN_COMMUNICATION),
329 TERMINATOR
330 };
331
332 template<>
333 const AudioContentTypeConverter::Table AudioContentTypeConverter::mTable[] = {
334 MAKE_STRING_FROM_ENUM(AUDIO_CONTENT_TYPE_UNKNOWN),
335 MAKE_STRING_FROM_ENUM(AUDIO_CONTENT_TYPE_SPEECH),
336 MAKE_STRING_FROM_ENUM(AUDIO_CONTENT_TYPE_MUSIC),
337 MAKE_STRING_FROM_ENUM(AUDIO_CONTENT_TYPE_MOVIE),
338 MAKE_STRING_FROM_ENUM(AUDIO_CONTENT_TYPE_SONIFICATION),
339 TERMINATOR
340 };
341
342 template <>
343 const UsageTypeConverter::Table UsageTypeConverter::mTable[] = {
344 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_UNKNOWN),
345 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_MEDIA),
346 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_VOICE_COMMUNICATION),
347 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING),
348 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_ALARM),
349 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_NOTIFICATION),
350 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE),
351 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_NOTIFICATION_COMMUNICATION_REQUEST),
352 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_NOTIFICATION_COMMUNICATION_INSTANT),
353 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_NOTIFICATION_COMMUNICATION_DELAYED),
354 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_NOTIFICATION_EVENT),
355 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY),
356 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE),
357 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_ASSISTANCE_SONIFICATION),
358 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_GAME),
359 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_VIRTUAL_SOURCE),
360 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_ASSISTANT),
361 TERMINATOR
362 };
363
364 template <>
365 const SourceTypeConverter::Table SourceTypeConverter::mTable[] = {
366 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_DEFAULT),
367 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_MIC),
368 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_VOICE_UPLINK),
369 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_VOICE_DOWNLINK),
370 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_VOICE_CALL),
371 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_CAMCORDER),
372 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_VOICE_RECOGNITION),
373 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_VOICE_COMMUNICATION),
374 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_REMOTE_SUBMIX),
375 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_UNPROCESSED),
376 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_VOICE_PERFORMANCE),
377 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_ECHO_REFERENCE),
378 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_FM_TUNER),
379 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_HOTWORD),
380 TERMINATOR
381 };
382
383 template <>
384 const AudioFlagConverter::Table AudioFlagConverter::mTable[] = {
385 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_NONE),
386 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_AUDIBILITY_ENFORCED),
387 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_SECURE),
388 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_SCO),
389 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_BEACON),
390 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_HW_AV_SYNC),
391 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_HW_HOTWORD),
392 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_BYPASS_INTERRUPTION_POLICY),
393 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_BYPASS_MUTE),
394 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_LOW_LATENCY),
395 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_DEEP_BUFFER),
396 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_NO_MEDIA_PROJECTION),
397 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_MUTE_HAPTIC),
398 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_NO_SYSTEM_CAPTURE),
399 TERMINATOR
400 };
401
402 template class TypeConverter<OutputDeviceTraits>;
403 template class TypeConverter<InputDeviceTraits>;
404 template class TypeConverter<OutputFlagTraits>;
405 template class TypeConverter<InputFlagTraits>;
406 template class TypeConverter<FormatTraits>;
407 template class TypeConverter<OutputChannelTraits>;
408 template class TypeConverter<InputChannelTraits>;
409 template class TypeConverter<ChannelIndexTraits>;
410 template class TypeConverter<GainModeTraits>;
411 template class TypeConverter<StreamTraits>;
412 template class TypeConverter<AudioModeTraits>;
413 template class TypeConverter<UsageTraits>;
414 template class TypeConverter<SourceTraits>;
415 template class TypeConverter<AudioFlagTraits>;
416
deviceFromString(const std::string & literalDevice,audio_devices_t & device)417 bool deviceFromString(const std::string& literalDevice, audio_devices_t& device) {
418 return InputDeviceConverter::fromString(literalDevice, device) ||
419 OutputDeviceConverter::fromString(literalDevice, device);
420 }
421
samplingRatesFromString(const std::string & samplingRates,const char * del)422 SampleRateTraits::Collection samplingRatesFromString(
423 const std::string &samplingRates, const char *del)
424 {
425 SampleRateTraits::Collection samplingRateCollection;
426 collectionFromString<SampleRateTraits>(samplingRates, samplingRateCollection, del);
427 return samplingRateCollection;
428 }
429
formatsFromString(const std::string & formats,const char * del)430 FormatTraits::Collection formatsFromString(
431 const std::string &formats, const char *del)
432 {
433 FormatTraits::Collection formatCollection;
434 FormatConverter::collectionFromString(formats, formatCollection, del);
435 return formatCollection;
436 }
437
formatFromString(const std::string & literalFormat,audio_format_t defaultFormat)438 audio_format_t formatFromString(const std::string &literalFormat, audio_format_t defaultFormat)
439 {
440 audio_format_t format;
441 if (literalFormat.empty()) {
442 return defaultFormat;
443 }
444 FormatConverter::fromString(literalFormat, format);
445 return format;
446 }
447
channelMaskFromString(const std::string & literalChannels)448 audio_channel_mask_t channelMaskFromString(const std::string &literalChannels)
449 {
450 audio_channel_mask_t channels;
451 if (!OutputChannelConverter::fromString(literalChannels, channels) &&
452 !InputChannelConverter::fromString(literalChannels, channels)) {
453 return AUDIO_CHANNEL_INVALID;
454 }
455 return channels;
456 }
457
channelMasksFromString(const std::string & channels,const char * del)458 ChannelTraits::Collection channelMasksFromString(
459 const std::string &channels, const char *del)
460 {
461 ChannelTraits::Collection channelMaskCollection;
462 OutputChannelConverter::collectionFromString(channels, channelMaskCollection, del);
463 InputChannelConverter::collectionFromString(channels, channelMaskCollection, del);
464 ChannelIndexConverter::collectionFromString(channels, channelMaskCollection, del);
465 return channelMaskCollection;
466 }
467
inputChannelMasksFromString(const std::string & inChannels,const char * del)468 InputChannelTraits::Collection inputChannelMasksFromString(
469 const std::string &inChannels, const char *del)
470 {
471 InputChannelTraits::Collection inputChannelMaskCollection;
472 InputChannelConverter::collectionFromString(inChannels, inputChannelMaskCollection, del);
473 ChannelIndexConverter::collectionFromString(inChannels, inputChannelMaskCollection, del);
474 return inputChannelMaskCollection;
475 }
476
outputChannelMasksFromString(const std::string & outChannels,const char * del)477 OutputChannelTraits::Collection outputChannelMasksFromString(
478 const std::string &outChannels, const char *del)
479 {
480 OutputChannelTraits::Collection outputChannelMaskCollection;
481 OutputChannelConverter::collectionFromString(outChannels, outputChannelMaskCollection, del);
482 ChannelIndexConverter::collectionFromString(outChannels, outputChannelMaskCollection, del);
483 return outputChannelMaskCollection;
484 }
485
486 }; // namespace android
487