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_REROUTING),
316 MAKE_STRING_FROM_ENUM(AUDIO_STREAM_PATCH),
317 TERMINATOR
318 };
319
320 template<>
321 const AudioModeConverter::Table AudioModeConverter::mTable[] = {
322 MAKE_STRING_FROM_ENUM(AUDIO_MODE_INVALID),
323 MAKE_STRING_FROM_ENUM(AUDIO_MODE_CURRENT),
324 MAKE_STRING_FROM_ENUM(AUDIO_MODE_NORMAL),
325 MAKE_STRING_FROM_ENUM(AUDIO_MODE_RINGTONE),
326 MAKE_STRING_FROM_ENUM(AUDIO_MODE_IN_CALL),
327 MAKE_STRING_FROM_ENUM(AUDIO_MODE_IN_COMMUNICATION),
328 TERMINATOR
329 };
330
331 template<>
332 const AudioContentTypeConverter::Table AudioContentTypeConverter::mTable[] = {
333 MAKE_STRING_FROM_ENUM(AUDIO_CONTENT_TYPE_UNKNOWN),
334 MAKE_STRING_FROM_ENUM(AUDIO_CONTENT_TYPE_SPEECH),
335 MAKE_STRING_FROM_ENUM(AUDIO_CONTENT_TYPE_MUSIC),
336 MAKE_STRING_FROM_ENUM(AUDIO_CONTENT_TYPE_MOVIE),
337 MAKE_STRING_FROM_ENUM(AUDIO_CONTENT_TYPE_SONIFICATION),
338 TERMINATOR
339 };
340
341 template <>
342 const UsageTypeConverter::Table UsageTypeConverter::mTable[] = {
343 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_UNKNOWN),
344 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_MEDIA),
345 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_VOICE_COMMUNICATION),
346 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING),
347 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_ALARM),
348 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_NOTIFICATION),
349 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE),
350 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_NOTIFICATION_COMMUNICATION_REQUEST),
351 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_NOTIFICATION_COMMUNICATION_INSTANT),
352 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_NOTIFICATION_COMMUNICATION_DELAYED),
353 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_NOTIFICATION_EVENT),
354 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY),
355 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE),
356 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_ASSISTANCE_SONIFICATION),
357 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_GAME),
358 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_VIRTUAL_SOURCE),
359 MAKE_STRING_FROM_ENUM(AUDIO_USAGE_ASSISTANT),
360 TERMINATOR
361 };
362
363 template <>
364 const SourceTypeConverter::Table SourceTypeConverter::mTable[] = {
365 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_DEFAULT),
366 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_MIC),
367 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_VOICE_UPLINK),
368 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_VOICE_DOWNLINK),
369 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_VOICE_CALL),
370 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_CAMCORDER),
371 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_VOICE_RECOGNITION),
372 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_VOICE_COMMUNICATION),
373 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_REMOTE_SUBMIX),
374 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_UNPROCESSED),
375 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_VOICE_PERFORMANCE),
376 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_ECHO_REFERENCE),
377 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_FM_TUNER),
378 MAKE_STRING_FROM_ENUM(AUDIO_SOURCE_HOTWORD),
379 TERMINATOR
380 };
381
382 template <>
383 const AudioFlagConverter::Table AudioFlagConverter::mTable[] = {
384 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_NONE),
385 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_AUDIBILITY_ENFORCED),
386 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_SECURE),
387 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_SCO),
388 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_BEACON),
389 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_HW_AV_SYNC),
390 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_HW_HOTWORD),
391 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_BYPASS_INTERRUPTION_POLICY),
392 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_BYPASS_MUTE),
393 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_LOW_LATENCY),
394 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_DEEP_BUFFER),
395 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_NO_MEDIA_PROJECTION),
396 MAKE_STRING_FROM_ENUM(AUDIO_FLAG_NO_SYSTEM_CAPTURE),
397 TERMINATOR
398 };
399
400 template class TypeConverter<OutputDeviceTraits>;
401 template class TypeConverter<InputDeviceTraits>;
402 template class TypeConverter<OutputFlagTraits>;
403 template class TypeConverter<InputFlagTraits>;
404 template class TypeConverter<FormatTraits>;
405 template class TypeConverter<OutputChannelTraits>;
406 template class TypeConverter<InputChannelTraits>;
407 template class TypeConverter<ChannelIndexTraits>;
408 template class TypeConverter<GainModeTraits>;
409 template class TypeConverter<StreamTraits>;
410 template class TypeConverter<AudioModeTraits>;
411 template class TypeConverter<UsageTraits>;
412 template class TypeConverter<SourceTraits>;
413 template class TypeConverter<AudioFlagTraits>;
414
deviceFromString(const std::string & literalDevice,audio_devices_t & device)415 bool deviceFromString(const std::string& literalDevice, audio_devices_t& device) {
416 return InputDeviceConverter::fromString(literalDevice, device) ||
417 OutputDeviceConverter::fromString(literalDevice, device);
418 }
419
samplingRatesFromString(const std::string & samplingRates,const char * del)420 SampleRateTraits::Collection samplingRatesFromString(
421 const std::string &samplingRates, const char *del)
422 {
423 SampleRateTraits::Collection samplingRateCollection;
424 collectionFromString<SampleRateTraits>(samplingRates, samplingRateCollection, del);
425 return samplingRateCollection;
426 }
427
formatsFromString(const std::string & formats,const char * del)428 FormatTraits::Collection formatsFromString(
429 const std::string &formats, const char *del)
430 {
431 FormatTraits::Collection formatCollection;
432 FormatConverter::collectionFromString(formats, formatCollection, del);
433 return formatCollection;
434 }
435
formatFromString(const std::string & literalFormat,audio_format_t defaultFormat)436 audio_format_t formatFromString(const std::string &literalFormat, audio_format_t defaultFormat)
437 {
438 audio_format_t format;
439 if (literalFormat.empty()) {
440 return defaultFormat;
441 }
442 FormatConverter::fromString(literalFormat, format);
443 return format;
444 }
445
channelMaskFromString(const std::string & literalChannels)446 audio_channel_mask_t channelMaskFromString(const std::string &literalChannels)
447 {
448 audio_channel_mask_t channels;
449 if (!OutputChannelConverter::fromString(literalChannels, channels) &&
450 !InputChannelConverter::fromString(literalChannels, channels)) {
451 return AUDIO_CHANNEL_INVALID;
452 }
453 return channels;
454 }
455
channelMasksFromString(const std::string & channels,const char * del)456 ChannelTraits::Collection channelMasksFromString(
457 const std::string &channels, const char *del)
458 {
459 ChannelTraits::Collection channelMaskCollection;
460 OutputChannelConverter::collectionFromString(channels, channelMaskCollection, del);
461 InputChannelConverter::collectionFromString(channels, channelMaskCollection, del);
462 ChannelIndexConverter::collectionFromString(channels, channelMaskCollection, del);
463 return channelMaskCollection;
464 }
465
inputChannelMasksFromString(const std::string & inChannels,const char * del)466 InputChannelTraits::Collection inputChannelMasksFromString(
467 const std::string &inChannels, const char *del)
468 {
469 InputChannelTraits::Collection inputChannelMaskCollection;
470 InputChannelConverter::collectionFromString(inChannels, inputChannelMaskCollection, del);
471 ChannelIndexConverter::collectionFromString(inChannels, inputChannelMaskCollection, del);
472 return inputChannelMaskCollection;
473 }
474
outputChannelMasksFromString(const std::string & outChannels,const char * del)475 OutputChannelTraits::Collection outputChannelMasksFromString(
476 const std::string &outChannels, const char *del)
477 {
478 OutputChannelTraits::Collection outputChannelMaskCollection;
479 OutputChannelConverter::collectionFromString(outChannels, outputChannelMaskCollection, del);
480 ChannelIndexConverter::collectionFromString(outChannels, outputChannelMaskCollection, del);
481 return outputChannelMaskCollection;
482 }
483
484 }; // namespace android
485