TypeConverter.cpp revision 5fcd6f99944d8722c57d2b2963814a1964ecfedd
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), 53a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_AMBIENT), 54a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BUILTIN_MIC), 55a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET), 56a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_ALL_SCO), 57a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_WIRED_HEADSET), 58a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_AUX_DIGITAL), 59a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_HDMI), 60a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_TELEPHONY_RX), 61a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_VOICE_CALL), 62a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BACK_MIC), 63a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_REMOTE_SUBMIX), 64a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET), 65a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET), 66a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_USB_ACCESSORY), 67a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_USB_DEVICE), 68a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_FM_TUNER), 69a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_TV_TUNER), 70a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_LINE), 71a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_SPDIF), 72a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BLUETOOTH_A2DP), 73a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_LOOPBACK), 74a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_IP), 75a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie}; 76a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 77a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate<> 78a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst size_t DeviceConverter::mSize = sizeof(DeviceConverter::mTable) / 79a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie sizeof(DeviceConverter::mTable[0]); 80a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 81a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 82a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate <> 83a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst OutputFlagConverter::Table OutputFlagConverter::mTable[] = { 84a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_DIRECT), 85a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_PRIMARY), 86a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_FAST), 87a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_DEEP_BUFFER), 88a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD), 89a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_NON_BLOCKING), 90a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_HW_AV_SYNC), 91a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_TTS), 92a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_RAW), 93a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_OUTPUT_FLAG_SYNC), 94a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie}; 95a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate<> 96a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst size_t OutputFlagConverter::mSize = sizeof(OutputFlagConverter::mTable) / 97a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie sizeof(OutputFlagConverter::mTable[0]); 98a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 99a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 100a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate <> 101a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst InputFlagConverter::Table InputFlagConverter::mTable[] = { 102a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_FAST), 103a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_HW_HOTWORD), 104a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_RAW), 105a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_INPUT_FLAG_SYNC), 106a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie}; 107a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate<> 108a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst size_t InputFlagConverter::mSize = sizeof(InputFlagConverter::mTable) / 109a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie sizeof(InputFlagConverter::mTable[0]); 110a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 111a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 112a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate <> 113a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst FormatConverter::Table FormatConverter::mTable[] = { 114a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_16_BIT), 115a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_8_BIT), 116a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_32_BIT), 117a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_8_24_BIT), 118a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_FLOAT), 119a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_PCM_24_BIT_PACKED), 120a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_MP3), 121a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC), 122a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_MAIN), 123a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_LC), 124a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_SSR), 125a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_LTP), 126a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_HE_V1), 127a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_SCALABLE), 128a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ERLC), 129a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_LD), 130a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_HE_V2), 131a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AAC_ELD), 132a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_VORBIS), 133a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_HE_AAC_V1), 134a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_HE_AAC_V2), 135a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_OPUS), 136a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_AC3), 137a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_E_AC3), 138a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_DTS), 139a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_FORMAT_DTS_HD), 140a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie}; 141a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate<> 142a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst size_t FormatConverter::mSize = sizeof(FormatConverter::mTable) / 143a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie sizeof(FormatConverter::mTable[0]); 144a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 145a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 146a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate <> 147a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst OutputChannelConverter::Table OutputChannelConverter::mTable[] = { 148a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_MONO), 149a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_STEREO), 150a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_QUAD), 151a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_5POINT1), 152a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_OUT_7POINT1), 153a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie}; 154a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate<> 155a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst size_t OutputChannelConverter::mSize = sizeof(OutputChannelConverter::mTable) / 156a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie sizeof(OutputChannelConverter::mTable[0]); 157a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 158a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 159a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate <> 160a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst InputChannelConverter::Table InputChannelConverter::mTable[] = { 161a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_MONO), 162a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_STEREO), 163a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_CHANNEL_IN_FRONT_BACK), 164a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie}; 165a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate<> 166a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst size_t InputChannelConverter::mSize = sizeof(InputChannelConverter::mTable) / 167a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie sizeof(InputChannelConverter::mTable[0]); 168a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 169a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate <> 170a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst ChannelIndexConverter::Table ChannelIndexConverter::mTable[] = { 171a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie "AUDIO_CHANNEL_INDEX_MASK_1", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_1), 172a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie "AUDIO_CHANNEL_INDEX_MASK_2", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_2), 173a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie "AUDIO_CHANNEL_INDEX_MASK_3", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_3), 174a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie "AUDIO_CHANNEL_INDEX_MASK_4", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_4), 175a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie "AUDIO_CHANNEL_INDEX_MASK_5", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_5), 176a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie "AUDIO_CHANNEL_INDEX_MASK_6", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_6), 177a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie "AUDIO_CHANNEL_INDEX_MASK_7", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_7), 178a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie "AUDIO_CHANNEL_INDEX_MASK_8", static_cast<audio_channel_mask_t>(AUDIO_CHANNEL_INDEX_MASK_8), 179a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie}; 180a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate<> 181a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst size_t ChannelIndexConverter::mSize = sizeof(ChannelIndexConverter::mTable) / 182a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie sizeof(ChannelIndexConverter::mTable[0]); 183a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 184a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 185a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate <> 186a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst GainModeConverter::Table GainModeConverter::mTable[] = { 187a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_GAIN_MODE_JOINT), 188a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_GAIN_MODE_CHANNELS), 189a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie MAKE_STRING_FROM_ENUM(AUDIO_GAIN_MODE_RAMP), 190a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie}; 191a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 192a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffietemplate<> 193a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieconst size_t GainModeConverter::mSize = sizeof(GainModeConverter::mTable) / 194a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie sizeof(GainModeConverter::mTable[0]); 195a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 1965fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate <> 1975fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffieconst DeviceCategoryConverter::Table DeviceCategoryConverter::mTable[] = { 1985fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(DEVICE_CATEGORY_HEADSET), 1995fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(DEVICE_CATEGORY_SPEAKER), 2005fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(DEVICE_CATEGORY_EARPIECE), 2015fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(DEVICE_CATEGORY_EXT_MEDIA) 2025fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie}; 2035fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie 2045fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate<> 2055fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffieconst size_t DeviceCategoryConverter::mSize = sizeof(DeviceCategoryConverter::mTable) / 2065fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie sizeof(DeviceCategoryConverter::mTable[0]); 2075fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie 2085fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate <> 2095fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffieconst StreamTypeConverter::Table StreamTypeConverter::mTable[] = { 2105fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(AUDIO_STREAM_VOICE_CALL), 2115fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(AUDIO_STREAM_SYSTEM), 2125fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(AUDIO_STREAM_RING), 2135fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(AUDIO_STREAM_MUSIC), 2145fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(AUDIO_STREAM_ALARM), 2155fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(AUDIO_STREAM_NOTIFICATION), 2165fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(AUDIO_STREAM_BLUETOOTH_SCO ), 2175fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(AUDIO_STREAM_ENFORCED_AUDIBLE), 2185fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(AUDIO_STREAM_DTMF), 2195fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(AUDIO_STREAM_TTS), 2205fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(AUDIO_STREAM_ACCESSIBILITY), 2215fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(AUDIO_STREAM_REROUTING), 2225fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie MAKE_STRING_FROM_ENUM(AUDIO_STREAM_PATCH) 2235fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie}; 2245fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie 2255fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate<> 2265fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffieconst size_t StreamTypeConverter::mSize = sizeof(StreamTypeConverter::mTable) / 2275fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie sizeof(StreamTypeConverter::mTable[0]); 228a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 2295fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate <class Traits> 2305fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffiebool TypeConverter<Traits>::toString(const typename Traits::Type &value, std::string &str) 231a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie{ 232a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie for (size_t i = 0; i < mSize; i++) { 233a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie if (mTable[i].value == value) { 234a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie str = mTable[i].literal; 235a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie return true; 236a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie } 237a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie } 238a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie return false; 239a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie} 240a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 2415fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate <class Traits> 2425fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffiebool TypeConverter<Traits>::fromString(const std::string &str, typename Traits::Type &result) 243a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie{ 244a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie for (size_t i = 0; i < mSize; i++) { 245a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie if (strcmp(mTable[i].literal, str.c_str()) == 0) { 246a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie ALOGV("stringToEnum() found %s", mTable[i].literal); 247a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie result = mTable[i].value; 248a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie return true; 249a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie } 250a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie } 251a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie return false; 252a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie} 253a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 2545fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate <class Traits> 2555fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffievoid TypeConverter<Traits>::collectionFromString(const std::string &str, 2565fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie typename Traits::Collection &collection, 2575fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie const char *del) 258a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie{ 259a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie char *literal = strdup(str.c_str()); 260a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 2615fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie for (const char *cstr = strtok(literal, del); cstr != NULL; cstr = strtok(NULL, del)) { 2625fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie typename Traits::Type value; 263a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie if (fromString(cstr, value)) { 264a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie collection.add(value); 265a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie } 266a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie } 267a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie free(literal); 268a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie} 269a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 2705fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate <class Traits> 2715fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffieuint32_t TypeConverter<Traits>::maskFromString(const std::string &str, const char *del) 272a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie{ 273a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie char *literal = strdup(str.c_str()); 274a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie uint32_t value = 0; 2755fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie for (const char *cstr = strtok(literal, del); cstr != NULL; cstr = strtok(NULL, del)) { 2765fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffie typename Traits::Type type; 277a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie if (fromString(cstr, type)) { 278a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie value |= static_cast<uint32_t>(type); 279a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie } 280a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie } 281a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie free(literal); 282a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie return value; 283a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie} 284a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 2855fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<DeviceTraits>; 2865fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<OutputFlagTraits>; 2875fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<InputFlagTraits>; 2885fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<FormatTraits>; 2895fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<OutputChannelTraits>; 2905fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<InputChannelTraits>; 2915fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<ChannelIndexTraits>; 2925fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<GainModeTraits>; 2935fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<StreamTraits>; 2945fcd6f99944d8722c57d2b2963814a1964ecfeddFrançois Gaffietemplate class TypeConverter<DeviceCategoryTraits>; 295a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 296a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie}; // namespace android 297a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 298