1a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie/*
2a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * Copyright (C) 2015 The Android Open Source Project
3a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie *
4a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * Licensed under the Apache License, Version 2.0 (the "License");
5a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * you may not use this file except in compliance with the License.
6a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * You may obtain a copy of the License at
7a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie *
8a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie *      http://www.apache.org/licenses/LICENSE-2.0
9a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie *
10a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * Unless required by applicable law or agreed to in writing, software
11a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * distributed under the License is distributed on an "AS IS" BASIS,
12a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * See the License for the specific language governing permissions and
14a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * limitations under the License.
15a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie */
16a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
17a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie#include "TypeConverter.h"
18a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
19a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffienamespace android {
20a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
21a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie#define MAKE_STRING_FROM_ENUM(string) { #string, string }
22a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
23a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate <>
24a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst DeviceConverter::Table DeviceConverter::mTable[] = {
25a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_EARPIECE),
26a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_SPEAKER),
27a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_SPEAKER_SAFE),
28a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_WIRED_HEADSET),
29a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_WIRED_HEADPHONE),
30a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_BLUETOOTH_SCO),
31a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET),
32a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT),
33a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_ALL_SCO),
34a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP),
35a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES),
36a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER),
37a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_ALL_A2DP),
38a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_AUX_DIGITAL),
39a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_HDMI),
40a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET),
41a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET),
42a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_USB_ACCESSORY),
43a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_USB_DEVICE),
44a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_ALL_USB),
45a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_REMOTE_SUBMIX),
46a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_TELEPHONY_TX),
47a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_LINE),
48a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_HDMI_ARC),
49a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_SPDIF),
50a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_FM),
51a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_AUX_LINE),
52a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_IP),
5358545be2ce4e701c8c37401edcc126a8b683890dEric Laurent        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_BUS),
545a2b62984c7cecd1761fe272c078dd814c167942Eric Laurent        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_OUT_STUB),
55a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_AMBIENT),
56a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BUILTIN_MIC),
57a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET),
58a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_ALL_SCO),
59a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_WIRED_HEADSET),
60a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_AUX_DIGITAL),
61a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_HDMI),
62a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_TELEPHONY_RX),
63a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_VOICE_CALL),
64a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BACK_MIC),
65a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_REMOTE_SUBMIX),
66a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET),
67a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET),
68a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_USB_ACCESSORY),
69a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_USB_DEVICE),
70a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_FM_TUNER),
71a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_TV_TUNER),
72a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_LINE),
73a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_SPDIF),
74a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BLUETOOTH_A2DP),
75a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_LOOPBACK),
76a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_IP),
7758545be2ce4e701c8c37401edcc126a8b683890dEric Laurent        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BUS),
785a2b62984c7cecd1761fe272c078dd814c167942Eric Laurent        MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_STUB),
79a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie};
80a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
81a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate<>
82a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst size_t DeviceConverter::mSize = sizeof(DeviceConverter::mTable) /
83a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        sizeof(DeviceConverter::mTable[0]);
84a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
85a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
86a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate <>
87a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst OutputFlagConverter::Table OutputFlagConverter::mTable[] = {
88a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_DIRECT),
89a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_PRIMARY),
90a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_FAST),
91a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_DEEP_BUFFER),
92a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD),
93a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_NON_BLOCKING),
94a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_HW_AV_SYNC),
95a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_TTS),
96a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_RAW),
97a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_SYNC),
98a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie};
99a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate<>
100a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst size_t OutputFlagConverter::mSize = sizeof(OutputFlagConverter::mTable) /
101a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        sizeof(OutputFlagConverter::mTable[0]);
102a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
103a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
104a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate <>
105a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst InputFlagConverter::Table InputFlagConverter::mTable[] = {
106a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_FAST),
107a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_HW_HOTWORD),
108a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_RAW),
109a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_SYNC),
110a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie};
111a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate<>
112a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst size_t InputFlagConverter::mSize = sizeof(InputFlagConverter::mTable) /
113a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        sizeof(InputFlagConverter::mTable[0]);
114a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
115a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
116a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate <>
117a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst FormatConverter::Table FormatConverter::mTable[] = {
118a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_16_BIT),
119a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_8_BIT),
120a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_32_BIT),
121a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_8_24_BIT),
122a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_FLOAT),
123a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_24_BIT_PACKED),
124a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_MP3),
125a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC),
126a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_MAIN),
127a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_LC),
128a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_SSR),
129a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_LTP),
130a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_HE_V1),
131a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_SCALABLE),
132a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ERLC),
133a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_LD),
134a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_HE_V2),
135a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ELD),
136a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_VORBIS),
137a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_HE_AAC_V1),
138a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_HE_AAC_V2),
139a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_OPUS),
140a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AC3),
141a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_E_AC3),
142a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_DTS),
143a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_DTS_HD),
144fdb3c07db5d44535eb8c3ec46dc78ad8446c01ebPhil Burk    MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_IEC61937),
145a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie};
146a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate<>
147a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst size_t FormatConverter::mSize = sizeof(FormatConverter::mTable) /
148a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        sizeof(FormatConverter::mTable[0]);
149a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
150a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
151a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate <>
152a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst OutputChannelConverter::Table OutputChannelConverter::mTable[] = {
153a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_MONO),
154a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_STEREO),
155a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_QUAD),
156a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_5POINT1),
157a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_7POINT1),
158a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie};
159a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate<>
160a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst size_t OutputChannelConverter::mSize = sizeof(OutputChannelConverter::mTable) /
161a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        sizeof(OutputChannelConverter::mTable[0]);
162a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
163a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
164a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate <>
165a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst InputChannelConverter::Table InputChannelConverter::mTable[] = {
166a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_MONO),
167a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_STEREO),
168a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_FRONT_BACK),
169a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie};
170a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate<>
171a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst size_t InputChannelConverter::mSize = sizeof(InputChannelConverter::mTable) /
172a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        sizeof(InputChannelConverter::mTable[0]);
173a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
174a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate <>
175a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst ChannelIndexConverter::Table ChannelIndexConverter::mTable[] = {
1767b279bbc24139ee1e01b58055ca94926ec18e2e9Eric Laurent    {"AUDIO_CHANNEL_INDEX_MASK_1", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_1)},
1777b279bbc24139ee1e01b58055ca94926ec18e2e9Eric Laurent    {"AUDIO_CHANNEL_INDEX_MASK_2", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_2)},
1787b279bbc24139ee1e01b58055ca94926ec18e2e9Eric Laurent    {"AUDIO_CHANNEL_INDEX_MASK_3", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_3)},
1797b279bbc24139ee1e01b58055ca94926ec18e2e9Eric Laurent    {"AUDIO_CHANNEL_INDEX_MASK_4", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_4)},
1807b279bbc24139ee1e01b58055ca94926ec18e2e9Eric Laurent    {"AUDIO_CHANNEL_INDEX_MASK_5", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_5)},
1817b279bbc24139ee1e01b58055ca94926ec18e2e9Eric Laurent    {"AUDIO_CHANNEL_INDEX_MASK_6", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_6)},
1827b279bbc24139ee1e01b58055ca94926ec18e2e9Eric Laurent    {"AUDIO_CHANNEL_INDEX_MASK_7", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_7)},
1837b279bbc24139ee1e01b58055ca94926ec18e2e9Eric Laurent    {"AUDIO_CHANNEL_INDEX_MASK_8", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_8)},
184a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie};
185a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate<>
186a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst size_t ChannelIndexConverter::mSize = sizeof(ChannelIndexConverter::mTable) /
187a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        sizeof(ChannelIndexConverter::mTable[0]);
188a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
189a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
190a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate <>
191a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst GainModeConverter::Table GainModeConverter::mTable[] = {
192a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_GAIN_MODE_JOINT),
193a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_GAIN_MODE_CHANNELS),
194a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_GAIN_MODE_RAMP),
195a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie};
196a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
197a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate<>
198a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst size_t GainModeConverter::mSize = sizeof(GainModeConverter::mTable) /
199a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        sizeof(GainModeConverter::mTable[0]);
200a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
2015fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate <>
2025fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffieconst DeviceCategoryConverter::Table DeviceCategoryConverter::mTable[] = {
2035fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    MAKE_STRING_FROM_ENUM(DEVICE_CATEGORY_HEADSET),
2045fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    MAKE_STRING_FROM_ENUM(DEVICE_CATEGORY_SPEAKER),
2055fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    MAKE_STRING_FROM_ENUM(DEVICE_CATEGORY_EARPIECE),
2065fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    MAKE_STRING_FROM_ENUM(DEVICE_CATEGORY_EXT_MEDIA)
2075fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie};
2085fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie
2095fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate<>
2105fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffieconst size_t DeviceCategoryConverter::mSize = sizeof(DeviceCategoryConverter::mTable) /
2115fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie        sizeof(DeviceCategoryConverter::mTable[0]);
2125fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie
2135fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate <>
2145fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffieconst StreamTypeConverter::Table StreamTypeConverter::mTable[] = {
2155fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_STREAM_VOICE_CALL),
2165fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_STREAM_SYSTEM),
2175fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_STREAM_RING),
2185fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_STREAM_MUSIC),
2195fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_STREAM_ALARM),
2205fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_STREAM_NOTIFICATION),
2215fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_STREAM_BLUETOOTH_SCO ),
2225fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_STREAM_ENFORCED_AUDIBLE),
2235fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_STREAM_DTMF),
2245fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_STREAM_TTS),
2255fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_STREAM_ACCESSIBILITY),
2265fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_STREAM_REROUTING),
227d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie    MAKE_STRING_FROM_ENUM(AUDIO_STREAM_PATCH),
2285fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie};
2295fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie
2305fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate<>
2315fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffieconst size_t StreamTypeConverter::mSize = sizeof(StreamTypeConverter::mTable) /
2325fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie        sizeof(StreamTypeConverter::mTable[0]);
233a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
2345fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate <class Traits>
2355fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffiebool TypeConverter<Traits>::toString(const typename Traits::Type &value, std::string &str)
236a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie{
237a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    for (size_t i = 0; i < mSize; i++) {
238a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        if (mTable[i].value == value) {
239a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie            str = mTable[i].literal;
240a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie            return true;
241a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        }
242a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    }
243a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    return false;
244a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie}
245a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
2465fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate <class Traits>
2475fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffiebool TypeConverter<Traits>::fromString(const std::string &str, typename Traits::Type &result)
248a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie{
249a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    for (size_t i = 0; i < mSize; i++) {
250a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        if (strcmp(mTable[i].literal, str.c_str()) == 0) {
251a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie            ALOGV("stringToEnum() found %s", mTable[i].literal);
252a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie            result = mTable[i].value;
253a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie            return true;
254a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        }
255a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    }
256a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    return false;
257a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie}
258a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
2595fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate <class Traits>
2605fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffievoid TypeConverter<Traits>::collectionFromString(const std::string &str,
2615fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie                                                 typename Traits::Collection &collection,
2625fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie                                                 const char *del)
263a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie{
264a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    char *literal = strdup(str.c_str());
265a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
2665fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    for (const char *cstr = strtok(literal, del); cstr != NULL; cstr = strtok(NULL, del)) {
2675fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie        typename Traits::Type value;
268a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        if (fromString(cstr, value)) {
269a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie            collection.add(value);
270a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        }
271a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    }
272a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    free(literal);
273a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie}
274a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
2755fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate <class Traits>
2765fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffieuint32_t TypeConverter<Traits>::maskFromString(const std::string &str, const char *del)
277a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie{
278a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    char *literal = strdup(str.c_str());
279a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    uint32_t value = 0;
2805fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie    for (const char *cstr = strtok(literal, del); cstr != NULL; cstr = strtok(NULL, del)) {
2815fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie        typename Traits::Type type;
282a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        if (fromString(cstr, type)) {
283a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie            value |= static_cast<uint32_t>(type);
284a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie        }
285a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    }
286a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    free(literal);
287a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie    return value;
288a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie}
289a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
2905fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<DeviceTraits>;
2915fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<OutputFlagTraits>;
2925fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<InputFlagTraits>;
2935fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<FormatTraits>;
2945fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<OutputChannelTraits>;
2955fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<InputChannelTraits>;
2965fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<ChannelIndexTraits>;
2975fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<GainModeTraits>;
2985fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<StreamTraits>;
2995fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<DeviceCategoryTraits>;
300a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
301a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie}; // namespace android
302a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie
303