Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (C) 2008 The Android Open Source Project |
michael@0 | 3 | * |
michael@0 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 5 | * you may not use this file except in compliance with the License. |
michael@0 | 6 | * You may obtain a copy of the License at |
michael@0 | 7 | * |
michael@0 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 9 | * |
michael@0 | 10 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 13 | * See the License for the specific language governing permissions and |
michael@0 | 14 | * limitations under the License. |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | #ifndef ANDROID_AUDIOSYSTEM_H_ |
michael@0 | 18 | #define ANDROID_AUDIOSYSTEM_H_ |
michael@0 | 19 | |
michael@0 | 20 | #include <utils/RefBase.h> |
michael@0 | 21 | #include <utils/threads.h> |
michael@0 | 22 | #include "IAudioFlinger.h" |
michael@0 | 23 | |
michael@0 | 24 | #ifndef VANILLA_ANDROID |
michael@0 | 25 | /* request to open a direct output with get_output() (by opposition to |
michael@0 | 26 | * sharing an output with other AudioTracks) |
michael@0 | 27 | */ |
michael@0 | 28 | typedef enum { |
michael@0 | 29 | AUDIO_POLICY_OUTPUT_FLAG_INDIRECT = 0x0, |
michael@0 | 30 | AUDIO_POLICY_OUTPUT_FLAG_DIRECT = 0x1 |
michael@0 | 31 | } audio_policy_output_flags_t; |
michael@0 | 32 | |
michael@0 | 33 | /* device categories used for audio_policy->set_force_use() */ |
michael@0 | 34 | typedef enum { |
michael@0 | 35 | AUDIO_POLICY_FORCE_NONE, |
michael@0 | 36 | AUDIO_POLICY_FORCE_SPEAKER, |
michael@0 | 37 | AUDIO_POLICY_FORCE_HEADPHONES, |
michael@0 | 38 | AUDIO_POLICY_FORCE_BT_SCO, |
michael@0 | 39 | AUDIO_POLICY_FORCE_BT_A2DP, |
michael@0 | 40 | AUDIO_POLICY_FORCE_WIRED_ACCESSORY, |
michael@0 | 41 | AUDIO_POLICY_FORCE_BT_CAR_DOCK, |
michael@0 | 42 | AUDIO_POLICY_FORCE_BT_DESK_DOCK, |
michael@0 | 43 | |
michael@0 | 44 | #ifdef VANILLA_ANDROID |
michael@0 | 45 | AUDIO_POLICY_FORCE_ANALOG_DOCK, |
michael@0 | 46 | AUDIO_POLICY_FORCE_DIGITAL_DOCK, |
michael@0 | 47 | #endif |
michael@0 | 48 | |
michael@0 | 49 | AUDIO_POLICY_FORCE_CFG_CNT, |
michael@0 | 50 | AUDIO_POLICY_FORCE_CFG_MAX = AUDIO_POLICY_FORCE_CFG_CNT - 1, |
michael@0 | 51 | |
michael@0 | 52 | AUDIO_POLICY_FORCE_DEFAULT = AUDIO_POLICY_FORCE_NONE, |
michael@0 | 53 | } audio_policy_forced_cfg_t; |
michael@0 | 54 | |
michael@0 | 55 | /* usages used for audio_policy->set_force_use() */ |
michael@0 | 56 | typedef enum { |
michael@0 | 57 | AUDIO_POLICY_FORCE_FOR_COMMUNICATION, |
michael@0 | 58 | AUDIO_POLICY_FORCE_FOR_MEDIA, |
michael@0 | 59 | AUDIO_POLICY_FORCE_FOR_RECORD, |
michael@0 | 60 | AUDIO_POLICY_FORCE_FOR_DOCK, |
michael@0 | 61 | |
michael@0 | 62 | AUDIO_POLICY_FORCE_USE_CNT, |
michael@0 | 63 | AUDIO_POLICY_FORCE_USE_MAX = AUDIO_POLICY_FORCE_USE_CNT - 1, |
michael@0 | 64 | } audio_policy_force_use_t; |
michael@0 | 65 | |
michael@0 | 66 | typedef enum { |
michael@0 | 67 | AUDIO_STREAM_DEFAULT = -1, |
michael@0 | 68 | AUDIO_STREAM_VOICE_CALL = 0, |
michael@0 | 69 | AUDIO_STREAM_SYSTEM = 1, |
michael@0 | 70 | AUDIO_STREAM_RING = 2, |
michael@0 | 71 | AUDIO_STREAM_MUSIC = 3, |
michael@0 | 72 | AUDIO_STREAM_ALARM = 4, |
michael@0 | 73 | AUDIO_STREAM_NOTIFICATION = 5, |
michael@0 | 74 | AUDIO_STREAM_BLUETOOTH_SCO = 6, |
michael@0 | 75 | AUDIO_STREAM_ENFORCED_AUDIBLE = 7, /* Sounds that cannot be muted by user and must be routed to speaker */ |
michael@0 | 76 | AUDIO_STREAM_DTMF = 8, |
michael@0 | 77 | AUDIO_STREAM_TTS = 9, |
michael@0 | 78 | AUDIO_STREAM_FM = 10, |
michael@0 | 79 | |
michael@0 | 80 | AUDIO_STREAM_CNT, |
michael@0 | 81 | AUDIO_STREAM_MAX = AUDIO_STREAM_CNT - 1, |
michael@0 | 82 | } audio_stream_type_t; |
michael@0 | 83 | |
michael@0 | 84 | /* PCM sub formats */ |
michael@0 | 85 | typedef enum { |
michael@0 | 86 | AUDIO_FORMAT_PCM_SUB_16_BIT = 0x1, /* DO NOT CHANGE - PCM signed 16 bits */ |
michael@0 | 87 | AUDIO_FORMAT_PCM_SUB_8_BIT = 0x2, /* DO NOT CHANGE - PCM unsigned 8 bits */ |
michael@0 | 88 | AUDIO_FORMAT_PCM_SUB_32_BIT = 0x3, /* PCM signed .31 fixed point */ |
michael@0 | 89 | AUDIO_FORMAT_PCM_SUB_8_24_BIT = 0x4, /* PCM signed 7.24 fixed point */ |
michael@0 | 90 | } audio_format_pcm_sub_fmt_t; |
michael@0 | 91 | |
michael@0 | 92 | /* Audio format consists in a main format field (upper 8 bits) and a sub format |
michael@0 | 93 | * field (lower 24 bits). |
michael@0 | 94 | * |
michael@0 | 95 | * The main format indicates the main codec type. The sub format field |
michael@0 | 96 | * indicates options and parameters for each format. The sub format is mainly |
michael@0 | 97 | * used for record to indicate for instance the requested bitrate or profile. |
michael@0 | 98 | * It can also be used for certain formats to give informations not present in |
michael@0 | 99 | * the encoded audio stream (e.g. octet alignement for AMR). |
michael@0 | 100 | */ |
michael@0 | 101 | typedef enum { |
michael@0 | 102 | AUDIO_FORMAT_INVALID = 0xFFFFFFFFUL, |
michael@0 | 103 | AUDIO_FORMAT_DEFAULT = 0, |
michael@0 | 104 | AUDIO_FORMAT_PCM = 0x00000000UL, /* DO NOT CHANGE */ |
michael@0 | 105 | AUDIO_FORMAT_MP3 = 0x01000000UL, |
michael@0 | 106 | AUDIO_FORMAT_AMR_NB = 0x02000000UL, |
michael@0 | 107 | AUDIO_FORMAT_AMR_WB = 0x03000000UL, |
michael@0 | 108 | AUDIO_FORMAT_AAC = 0x04000000UL, |
michael@0 | 109 | AUDIO_FORMAT_HE_AAC_V1 = 0x05000000UL, |
michael@0 | 110 | AUDIO_FORMAT_HE_AAC_V2 = 0x06000000UL, |
michael@0 | 111 | AUDIO_FORMAT_VORBIS = 0x07000000UL, |
michael@0 | 112 | AUDIO_FORMAT_MAIN_MASK = 0xFF000000UL, |
michael@0 | 113 | AUDIO_FORMAT_SUB_MASK = 0x00FFFFFFUL, |
michael@0 | 114 | |
michael@0 | 115 | /* Aliases */ |
michael@0 | 116 | AUDIO_FORMAT_PCM_16_BIT = (AUDIO_FORMAT_PCM | |
michael@0 | 117 | AUDIO_FORMAT_PCM_SUB_16_BIT), |
michael@0 | 118 | AUDIO_FORMAT_PCM_8_BIT = (AUDIO_FORMAT_PCM | |
michael@0 | 119 | AUDIO_FORMAT_PCM_SUB_8_BIT), |
michael@0 | 120 | AUDIO_FORMAT_PCM_32_BIT = (AUDIO_FORMAT_PCM | |
michael@0 | 121 | AUDIO_FORMAT_PCM_SUB_32_BIT), |
michael@0 | 122 | AUDIO_FORMAT_PCM_8_24_BIT = (AUDIO_FORMAT_PCM | |
michael@0 | 123 | AUDIO_FORMAT_PCM_SUB_8_24_BIT), |
michael@0 | 124 | } audio_format_t; |
michael@0 | 125 | |
michael@0 | 126 | typedef enum { |
michael@0 | 127 | /* output channels */ |
michael@0 | 128 | AUDIO_CHANNEL_OUT_FRONT_LEFT = 0x1, |
michael@0 | 129 | AUDIO_CHANNEL_OUT_FRONT_RIGHT = 0x2, |
michael@0 | 130 | AUDIO_CHANNEL_OUT_FRONT_CENTER = 0x4, |
michael@0 | 131 | AUDIO_CHANNEL_OUT_LOW_FREQUENCY = 0x8, |
michael@0 | 132 | AUDIO_CHANNEL_OUT_BACK_LEFT = 0x10, |
michael@0 | 133 | AUDIO_CHANNEL_OUT_BACK_RIGHT = 0x20, |
michael@0 | 134 | AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER = 0x40, |
michael@0 | 135 | AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER = 0x80, |
michael@0 | 136 | AUDIO_CHANNEL_OUT_BACK_CENTER = 0x100, |
michael@0 | 137 | AUDIO_CHANNEL_OUT_SIDE_LEFT = 0x200, |
michael@0 | 138 | AUDIO_CHANNEL_OUT_SIDE_RIGHT = 0x400, |
michael@0 | 139 | AUDIO_CHANNEL_OUT_TOP_CENTER = 0x800, |
michael@0 | 140 | AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT = 0x1000, |
michael@0 | 141 | AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER = 0x2000, |
michael@0 | 142 | AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT = 0x4000, |
michael@0 | 143 | AUDIO_CHANNEL_OUT_TOP_BACK_LEFT = 0x8000, |
michael@0 | 144 | AUDIO_CHANNEL_OUT_TOP_BACK_CENTER = 0x10000, |
michael@0 | 145 | AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT = 0x20000, |
michael@0 | 146 | |
michael@0 | 147 | AUDIO_CHANNEL_OUT_MONO = AUDIO_CHANNEL_OUT_FRONT_LEFT, |
michael@0 | 148 | AUDIO_CHANNEL_OUT_STEREO = (AUDIO_CHANNEL_OUT_FRONT_LEFT | |
michael@0 | 149 | AUDIO_CHANNEL_OUT_FRONT_RIGHT), |
michael@0 | 150 | AUDIO_CHANNEL_OUT_QUAD = (AUDIO_CHANNEL_OUT_FRONT_LEFT | |
michael@0 | 151 | AUDIO_CHANNEL_OUT_FRONT_RIGHT | |
michael@0 | 152 | AUDIO_CHANNEL_OUT_BACK_LEFT | |
michael@0 | 153 | AUDIO_CHANNEL_OUT_BACK_RIGHT), |
michael@0 | 154 | AUDIO_CHANNEL_OUT_SURROUND = (AUDIO_CHANNEL_OUT_FRONT_LEFT | |
michael@0 | 155 | AUDIO_CHANNEL_OUT_FRONT_RIGHT | |
michael@0 | 156 | AUDIO_CHANNEL_OUT_FRONT_CENTER | |
michael@0 | 157 | AUDIO_CHANNEL_OUT_BACK_CENTER), |
michael@0 | 158 | AUDIO_CHANNEL_OUT_5POINT1 = (AUDIO_CHANNEL_OUT_FRONT_LEFT | |
michael@0 | 159 | AUDIO_CHANNEL_OUT_FRONT_RIGHT | |
michael@0 | 160 | AUDIO_CHANNEL_OUT_FRONT_CENTER | |
michael@0 | 161 | AUDIO_CHANNEL_OUT_LOW_FREQUENCY | |
michael@0 | 162 | AUDIO_CHANNEL_OUT_BACK_LEFT | |
michael@0 | 163 | AUDIO_CHANNEL_OUT_BACK_RIGHT), |
michael@0 | 164 | // matches the correct AudioFormat.CHANNEL_OUT_7POINT1_SURROUND definition for 7.1 |
michael@0 | 165 | AUDIO_CHANNEL_OUT_7POINT1 = (AUDIO_CHANNEL_OUT_FRONT_LEFT | |
michael@0 | 166 | AUDIO_CHANNEL_OUT_FRONT_RIGHT | |
michael@0 | 167 | AUDIO_CHANNEL_OUT_FRONT_CENTER | |
michael@0 | 168 | AUDIO_CHANNEL_OUT_LOW_FREQUENCY | |
michael@0 | 169 | AUDIO_CHANNEL_OUT_BACK_LEFT | |
michael@0 | 170 | AUDIO_CHANNEL_OUT_BACK_RIGHT | |
michael@0 | 171 | AUDIO_CHANNEL_OUT_SIDE_LEFT | |
michael@0 | 172 | AUDIO_CHANNEL_OUT_SIDE_RIGHT), |
michael@0 | 173 | AUDIO_CHANNEL_OUT_ALL = (AUDIO_CHANNEL_OUT_FRONT_LEFT | |
michael@0 | 174 | AUDIO_CHANNEL_OUT_FRONT_RIGHT | |
michael@0 | 175 | AUDIO_CHANNEL_OUT_FRONT_CENTER | |
michael@0 | 176 | AUDIO_CHANNEL_OUT_LOW_FREQUENCY | |
michael@0 | 177 | AUDIO_CHANNEL_OUT_BACK_LEFT | |
michael@0 | 178 | AUDIO_CHANNEL_OUT_BACK_RIGHT | |
michael@0 | 179 | AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER | |
michael@0 | 180 | AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER | |
michael@0 | 181 | AUDIO_CHANNEL_OUT_BACK_CENTER| |
michael@0 | 182 | AUDIO_CHANNEL_OUT_SIDE_LEFT| |
michael@0 | 183 | AUDIO_CHANNEL_OUT_SIDE_RIGHT| |
michael@0 | 184 | AUDIO_CHANNEL_OUT_TOP_CENTER| |
michael@0 | 185 | AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT| |
michael@0 | 186 | AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER| |
michael@0 | 187 | AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT| |
michael@0 | 188 | AUDIO_CHANNEL_OUT_TOP_BACK_LEFT| |
michael@0 | 189 | AUDIO_CHANNEL_OUT_TOP_BACK_CENTER| |
michael@0 | 190 | AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT), |
michael@0 | 191 | |
michael@0 | 192 | /* input channels */ |
michael@0 | 193 | AUDIO_CHANNEL_IN_LEFT = 0x4, |
michael@0 | 194 | AUDIO_CHANNEL_IN_RIGHT = 0x8, |
michael@0 | 195 | AUDIO_CHANNEL_IN_FRONT = 0x10, |
michael@0 | 196 | AUDIO_CHANNEL_IN_BACK = 0x20, |
michael@0 | 197 | AUDIO_CHANNEL_IN_LEFT_PROCESSED = 0x40, |
michael@0 | 198 | AUDIO_CHANNEL_IN_RIGHT_PROCESSED = 0x80, |
michael@0 | 199 | AUDIO_CHANNEL_IN_FRONT_PROCESSED = 0x100, |
michael@0 | 200 | AUDIO_CHANNEL_IN_BACK_PROCESSED = 0x200, |
michael@0 | 201 | AUDIO_CHANNEL_IN_PRESSURE = 0x400, |
michael@0 | 202 | AUDIO_CHANNEL_IN_X_AXIS = 0x800, |
michael@0 | 203 | AUDIO_CHANNEL_IN_Y_AXIS = 0x1000, |
michael@0 | 204 | AUDIO_CHANNEL_IN_Z_AXIS = 0x2000, |
michael@0 | 205 | AUDIO_CHANNEL_IN_VOICE_UPLINK = 0x4000, |
michael@0 | 206 | AUDIO_CHANNEL_IN_VOICE_DNLINK = 0x8000, |
michael@0 | 207 | |
michael@0 | 208 | AUDIO_CHANNEL_IN_MONO = AUDIO_CHANNEL_IN_FRONT, |
michael@0 | 209 | AUDIO_CHANNEL_IN_STEREO = (AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_RIGHT), |
michael@0 | 210 | AUDIO_CHANNEL_IN_ALL = (AUDIO_CHANNEL_IN_LEFT | |
michael@0 | 211 | AUDIO_CHANNEL_IN_RIGHT | |
michael@0 | 212 | AUDIO_CHANNEL_IN_FRONT | |
michael@0 | 213 | AUDIO_CHANNEL_IN_BACK| |
michael@0 | 214 | AUDIO_CHANNEL_IN_LEFT_PROCESSED | |
michael@0 | 215 | AUDIO_CHANNEL_IN_RIGHT_PROCESSED | |
michael@0 | 216 | AUDIO_CHANNEL_IN_FRONT_PROCESSED | |
michael@0 | 217 | AUDIO_CHANNEL_IN_BACK_PROCESSED| |
michael@0 | 218 | AUDIO_CHANNEL_IN_PRESSURE | |
michael@0 | 219 | AUDIO_CHANNEL_IN_X_AXIS | |
michael@0 | 220 | AUDIO_CHANNEL_IN_Y_AXIS | |
michael@0 | 221 | AUDIO_CHANNEL_IN_Z_AXIS | |
michael@0 | 222 | AUDIO_CHANNEL_IN_VOICE_UPLINK | |
michael@0 | 223 | AUDIO_CHANNEL_IN_VOICE_DNLINK), |
michael@0 | 224 | } audio_channels_t; |
michael@0 | 225 | |
michael@0 | 226 | #if ANDROID_VERSION >= 17 |
michael@0 | 227 | typedef enum { |
michael@0 | 228 | AUDIO_MODE_INVALID = -2, |
michael@0 | 229 | AUDIO_MODE_CURRENT = -1, |
michael@0 | 230 | AUDIO_MODE_NORMAL = 0, |
michael@0 | 231 | AUDIO_MODE_RINGTONE = 1, |
michael@0 | 232 | AUDIO_MODE_IN_CALL = 2, |
michael@0 | 233 | AUDIO_MODE_IN_COMMUNICATION = 3, |
michael@0 | 234 | |
michael@0 | 235 | AUDIO_MODE_CNT, |
michael@0 | 236 | AUDIO_MODE_MAX = AUDIO_MODE_CNT - 1, |
michael@0 | 237 | } audio_mode_t; |
michael@0 | 238 | #endif |
michael@0 | 239 | #endif |
michael@0 | 240 | |
michael@0 | 241 | #if ANDROID_VERSION < 17 |
michael@0 | 242 | typedef enum { |
michael@0 | 243 | /* output devices */ |
michael@0 | 244 | AUDIO_DEVICE_OUT_EARPIECE = 0x1, |
michael@0 | 245 | AUDIO_DEVICE_OUT_SPEAKER = 0x2, |
michael@0 | 246 | AUDIO_DEVICE_OUT_WIRED_HEADSET = 0x4, |
michael@0 | 247 | AUDIO_DEVICE_OUT_WIRED_HEADPHONE = 0x8, |
michael@0 | 248 | AUDIO_DEVICE_OUT_BLUETOOTH_SCO = 0x10, |
michael@0 | 249 | AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET = 0x20, |
michael@0 | 250 | AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT = 0x40, |
michael@0 | 251 | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP = 0x80, |
michael@0 | 252 | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100, |
michael@0 | 253 | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = 0x200, |
michael@0 | 254 | AUDIO_DEVICE_OUT_AUX_DIGITAL = 0x400, |
michael@0 | 255 | AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET = 0x800, |
michael@0 | 256 | AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET = 0x1000, |
michael@0 | 257 | AUDIO_DEVICE_OUT_FM = 0x2000, |
michael@0 | 258 | AUDIO_DEVICE_OUT_ANC_HEADSET = 0x4000, |
michael@0 | 259 | AUDIO_DEVICE_OUT_ANC_HEADPHONE = 0x8000, |
michael@0 | 260 | AUDIO_DEVICE_OUT_FM_TX = 0x10000, |
michael@0 | 261 | AUDIO_DEVICE_OUT_DIRECTOUTPUT = 0x20000, |
michael@0 | 262 | AUDIO_DEVICE_OUT_PROXY = 0x40000, |
michael@0 | 263 | AUDIO_DEVICE_OUT_DEFAULT = 0x80000, |
michael@0 | 264 | AUDIO_DEVICE_OUT_ALL = (AUDIO_DEVICE_OUT_EARPIECE | |
michael@0 | 265 | AUDIO_DEVICE_OUT_SPEAKER | |
michael@0 | 266 | AUDIO_DEVICE_OUT_WIRED_HEADSET | |
michael@0 | 267 | AUDIO_DEVICE_OUT_WIRED_HEADPHONE | |
michael@0 | 268 | AUDIO_DEVICE_OUT_BLUETOOTH_SCO | |
michael@0 | 269 | AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET | |
michael@0 | 270 | AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT | |
michael@0 | 271 | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP | |
michael@0 | 272 | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | |
michael@0 | 273 | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER | |
michael@0 | 274 | AUDIO_DEVICE_OUT_AUX_DIGITAL | |
michael@0 | 275 | AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET | |
michael@0 | 276 | AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET | |
michael@0 | 277 | AUDIO_DEVICE_OUT_FM | |
michael@0 | 278 | AUDIO_DEVICE_OUT_ANC_HEADSET | |
michael@0 | 279 | AUDIO_DEVICE_OUT_ANC_HEADPHONE | |
michael@0 | 280 | AUDIO_DEVICE_OUT_FM_TX | |
michael@0 | 281 | AUDIO_DEVICE_OUT_DIRECTOUTPUT | |
michael@0 | 282 | AUDIO_DEVICE_OUT_PROXY | |
michael@0 | 283 | AUDIO_DEVICE_OUT_DEFAULT), |
michael@0 | 284 | AUDIO_DEVICE_OUT_ALL_A2DP = (AUDIO_DEVICE_OUT_BLUETOOTH_A2DP | |
michael@0 | 285 | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | |
michael@0 | 286 | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER), |
michael@0 | 287 | AUDIO_DEVICE_OUT_ALL_SCO = (AUDIO_DEVICE_OUT_BLUETOOTH_SCO | |
michael@0 | 288 | AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET | |
michael@0 | 289 | AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT), |
michael@0 | 290 | /* input devices */ |
michael@0 | 291 | AUDIO_DEVICE_IN_COMMUNICATION = 0x100000, |
michael@0 | 292 | AUDIO_DEVICE_IN_AMBIENT = 0x200000, |
michael@0 | 293 | AUDIO_DEVICE_IN_BUILTIN_MIC = 0x400000, |
michael@0 | 294 | AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET = 0x800000, |
michael@0 | 295 | AUDIO_DEVICE_IN_WIRED_HEADSET = 0x1000000, |
michael@0 | 296 | AUDIO_DEVICE_IN_AUX_DIGITAL = 0x2000000, |
michael@0 | 297 | AUDIO_DEVICE_IN_VOICE_CALL = 0x4000000, |
michael@0 | 298 | AUDIO_DEVICE_IN_BACK_MIC = 0x8000000, |
michael@0 | 299 | AUDIO_DEVICE_IN_ANC_HEADSET = 0x10000000, |
michael@0 | 300 | AUDIO_DEVICE_IN_FM_RX = 0x20000000, |
michael@0 | 301 | AUDIO_DEVICE_IN_FM_RX_A2DP = 0x40000000, |
michael@0 | 302 | AUDIO_DEVICE_IN_DEFAULT = 0x80000000, |
michael@0 | 303 | |
michael@0 | 304 | AUDIO_DEVICE_IN_ALL = (AUDIO_DEVICE_IN_COMMUNICATION | |
michael@0 | 305 | AUDIO_DEVICE_IN_AMBIENT | |
michael@0 | 306 | AUDIO_DEVICE_IN_BUILTIN_MIC | |
michael@0 | 307 | AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET | |
michael@0 | 308 | AUDIO_DEVICE_IN_WIRED_HEADSET | |
michael@0 | 309 | AUDIO_DEVICE_IN_AUX_DIGITAL | |
michael@0 | 310 | AUDIO_DEVICE_IN_VOICE_CALL | |
michael@0 | 311 | AUDIO_DEVICE_IN_BACK_MIC | |
michael@0 | 312 | AUDIO_DEVICE_IN_ANC_HEADSET | |
michael@0 | 313 | AUDIO_DEVICE_IN_FM_RX | |
michael@0 | 314 | AUDIO_DEVICE_IN_FM_RX_A2DP | |
michael@0 | 315 | AUDIO_DEVICE_IN_DEFAULT), |
michael@0 | 316 | AUDIO_DEVICE_IN_ALL_SCO = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET, |
michael@0 | 317 | } audio_devices_t; |
michael@0 | 318 | #else |
michael@0 | 319 | enum { |
michael@0 | 320 | AUDIO_DEVICE_NONE = 0x0, |
michael@0 | 321 | /* reserved bits */ |
michael@0 | 322 | AUDIO_DEVICE_BIT_IN = 0x80000000, |
michael@0 | 323 | AUDIO_DEVICE_BIT_DEFAULT = 0x40000000, |
michael@0 | 324 | /* output devices */ |
michael@0 | 325 | AUDIO_DEVICE_OUT_EARPIECE = 0x1, |
michael@0 | 326 | AUDIO_DEVICE_OUT_SPEAKER = 0x2, |
michael@0 | 327 | AUDIO_DEVICE_OUT_WIRED_HEADSET = 0x4, |
michael@0 | 328 | AUDIO_DEVICE_OUT_WIRED_HEADPHONE = 0x8, |
michael@0 | 329 | AUDIO_DEVICE_OUT_BLUETOOTH_SCO = 0x10, |
michael@0 | 330 | AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET = 0x20, |
michael@0 | 331 | AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT = 0x40, |
michael@0 | 332 | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP = 0x80, |
michael@0 | 333 | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100, |
michael@0 | 334 | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = 0x200, |
michael@0 | 335 | AUDIO_DEVICE_OUT_AUX_DIGITAL = 0x400, |
michael@0 | 336 | AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET = 0x800, |
michael@0 | 337 | AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET = 0x1000, |
michael@0 | 338 | AUDIO_DEVICE_OUT_USB_ACCESSORY = 0x2000, |
michael@0 | 339 | AUDIO_DEVICE_OUT_USB_DEVICE = 0x4000, |
michael@0 | 340 | AUDIO_DEVICE_OUT_REMOTE_SUBMIX = 0x8000, |
michael@0 | 341 | AUDIO_DEVICE_OUT_ANC_HEADSET = 0x10000, |
michael@0 | 342 | AUDIO_DEVICE_OUT_ANC_HEADPHONE = 0x20000, |
michael@0 | 343 | AUDIO_DEVICE_OUT_PROXY = 0x40000, |
michael@0 | 344 | AUDIO_DEVICE_OUT_FM = 0x80000, |
michael@0 | 345 | AUDIO_DEVICE_OUT_FM_TX = 0x100000, |
michael@0 | 346 | AUDIO_DEVICE_OUT_DEFAULT = AUDIO_DEVICE_BIT_DEFAULT, |
michael@0 | 347 | AUDIO_DEVICE_OUT_ALL = (AUDIO_DEVICE_OUT_EARPIECE | |
michael@0 | 348 | AUDIO_DEVICE_OUT_SPEAKER | |
michael@0 | 349 | AUDIO_DEVICE_OUT_WIRED_HEADSET | |
michael@0 | 350 | AUDIO_DEVICE_OUT_WIRED_HEADPHONE | |
michael@0 | 351 | AUDIO_DEVICE_OUT_BLUETOOTH_SCO | |
michael@0 | 352 | AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET | |
michael@0 | 353 | AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT | |
michael@0 | 354 | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP | |
michael@0 | 355 | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | |
michael@0 | 356 | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER | |
michael@0 | 357 | AUDIO_DEVICE_OUT_AUX_DIGITAL | |
michael@0 | 358 | AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET | |
michael@0 | 359 | AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET | |
michael@0 | 360 | AUDIO_DEVICE_OUT_USB_ACCESSORY | |
michael@0 | 361 | AUDIO_DEVICE_OUT_USB_DEVICE | |
michael@0 | 362 | AUDIO_DEVICE_OUT_REMOTE_SUBMIX | |
michael@0 | 363 | AUDIO_DEVICE_OUT_ANC_HEADSET | |
michael@0 | 364 | AUDIO_DEVICE_OUT_ANC_HEADPHONE | |
michael@0 | 365 | AUDIO_DEVICE_OUT_PROXY | |
michael@0 | 366 | AUDIO_DEVICE_OUT_FM | |
michael@0 | 367 | AUDIO_DEVICE_OUT_FM_TX | |
michael@0 | 368 | AUDIO_DEVICE_OUT_DEFAULT), |
michael@0 | 369 | AUDIO_DEVICE_OUT_ALL_A2DP = (AUDIO_DEVICE_OUT_BLUETOOTH_A2DP | |
michael@0 | 370 | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | |
michael@0 | 371 | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER), |
michael@0 | 372 | AUDIO_DEVICE_OUT_ALL_SCO = (AUDIO_DEVICE_OUT_BLUETOOTH_SCO | |
michael@0 | 373 | AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET | |
michael@0 | 374 | AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT), |
michael@0 | 375 | AUDIO_DEVICE_OUT_ALL_USB = (AUDIO_DEVICE_OUT_USB_ACCESSORY | |
michael@0 | 376 | AUDIO_DEVICE_OUT_USB_DEVICE), |
michael@0 | 377 | |
michael@0 | 378 | /* input devices */ |
michael@0 | 379 | AUDIO_DEVICE_IN_COMMUNICATION = AUDIO_DEVICE_BIT_IN | 0x1, |
michael@0 | 380 | AUDIO_DEVICE_IN_AMBIENT = AUDIO_DEVICE_BIT_IN | 0x2, |
michael@0 | 381 | AUDIO_DEVICE_IN_BUILTIN_MIC = AUDIO_DEVICE_BIT_IN | 0x4, |
michael@0 | 382 | AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET = AUDIO_DEVICE_BIT_IN | 0x8, |
michael@0 | 383 | AUDIO_DEVICE_IN_WIRED_HEADSET = AUDIO_DEVICE_BIT_IN | 0x10, |
michael@0 | 384 | AUDIO_DEVICE_IN_AUX_DIGITAL = AUDIO_DEVICE_BIT_IN | 0x20, |
michael@0 | 385 | AUDIO_DEVICE_IN_VOICE_CALL = AUDIO_DEVICE_BIT_IN | 0x40, |
michael@0 | 386 | AUDIO_DEVICE_IN_BACK_MIC = AUDIO_DEVICE_BIT_IN | 0x80, |
michael@0 | 387 | AUDIO_DEVICE_IN_REMOTE_SUBMIX = AUDIO_DEVICE_BIT_IN | 0x100, |
michael@0 | 388 | AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET = AUDIO_DEVICE_BIT_IN | 0x200, |
michael@0 | 389 | AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET = AUDIO_DEVICE_BIT_IN | 0x400, |
michael@0 | 390 | AUDIO_DEVICE_IN_USB_ACCESSORY = AUDIO_DEVICE_BIT_IN | 0x800, |
michael@0 | 391 | AUDIO_DEVICE_IN_USB_DEVICE = AUDIO_DEVICE_BIT_IN | 0x1000, |
michael@0 | 392 | AUDIO_DEVICE_IN_ANC_HEADSET = AUDIO_DEVICE_BIT_IN | 0x2000, |
michael@0 | 393 | AUDIO_DEVICE_IN_PROXY = AUDIO_DEVICE_BIT_IN | 0x4000, |
michael@0 | 394 | AUDIO_DEVICE_IN_FM_RX = AUDIO_DEVICE_BIT_IN | 0x8000, |
michael@0 | 395 | AUDIO_DEVICE_IN_FM_RX_A2DP = AUDIO_DEVICE_BIT_IN | 0x10000, |
michael@0 | 396 | AUDIO_DEVICE_IN_DEFAULT = AUDIO_DEVICE_BIT_IN | AUDIO_DEVICE_BIT_DEFAULT, |
michael@0 | 397 | |
michael@0 | 398 | AUDIO_DEVICE_IN_ALL = (AUDIO_DEVICE_IN_COMMUNICATION | |
michael@0 | 399 | AUDIO_DEVICE_IN_AMBIENT | |
michael@0 | 400 | AUDIO_DEVICE_IN_BUILTIN_MIC | |
michael@0 | 401 | AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET | |
michael@0 | 402 | AUDIO_DEVICE_IN_WIRED_HEADSET | |
michael@0 | 403 | AUDIO_DEVICE_IN_AUX_DIGITAL | |
michael@0 | 404 | AUDIO_DEVICE_IN_VOICE_CALL | |
michael@0 | 405 | AUDIO_DEVICE_IN_BACK_MIC | |
michael@0 | 406 | AUDIO_DEVICE_IN_REMOTE_SUBMIX | |
michael@0 | 407 | AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET | |
michael@0 | 408 | AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET | |
michael@0 | 409 | AUDIO_DEVICE_IN_USB_ACCESSORY | |
michael@0 | 410 | AUDIO_DEVICE_IN_USB_DEVICE | |
michael@0 | 411 | AUDIO_DEVICE_IN_ANC_HEADSET | |
michael@0 | 412 | AUDIO_DEVICE_IN_FM_RX | |
michael@0 | 413 | AUDIO_DEVICE_IN_FM_RX_A2DP | |
michael@0 | 414 | AUDIO_DEVICE_IN_PROXY | |
michael@0 | 415 | AUDIO_DEVICE_IN_DEFAULT), |
michael@0 | 416 | AUDIO_DEVICE_IN_ALL_SCO = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET, |
michael@0 | 417 | }; |
michael@0 | 418 | |
michael@0 | 419 | typedef uint32_t audio_devices_t; |
michael@0 | 420 | #endif |
michael@0 | 421 | |
michael@0 | 422 | /* device connection states used for audio_policy->set_device_connection_state() |
michael@0 | 423 | * */ |
michael@0 | 424 | typedef enum { |
michael@0 | 425 | AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, |
michael@0 | 426 | AUDIO_POLICY_DEVICE_STATE_AVAILABLE, |
michael@0 | 427 | |
michael@0 | 428 | AUDIO_POLICY_DEVICE_STATE_CNT, |
michael@0 | 429 | AUDIO_POLICY_DEVICE_STATE_MAX = AUDIO_POLICY_DEVICE_STATE_CNT - 1, |
michael@0 | 430 | } audio_policy_dev_state_t; |
michael@0 | 431 | |
michael@0 | 432 | namespace android { |
michael@0 | 433 | |
michael@0 | 434 | typedef void (*audio_error_callback)(status_t err); |
michael@0 | 435 | typedef int audio_io_handle_t; |
michael@0 | 436 | |
michael@0 | 437 | class IAudioPolicyService; |
michael@0 | 438 | class String8; |
michael@0 | 439 | |
michael@0 | 440 | class AudioSystem |
michael@0 | 441 | { |
michael@0 | 442 | public: |
michael@0 | 443 | |
michael@0 | 444 | enum stream_type { |
michael@0 | 445 | DEFAULT =-1, |
michael@0 | 446 | VOICE_CALL = 0, |
michael@0 | 447 | SYSTEM = 1, |
michael@0 | 448 | RING = 2, |
michael@0 | 449 | MUSIC = 3, |
michael@0 | 450 | ALARM = 4, |
michael@0 | 451 | NOTIFICATION = 5, |
michael@0 | 452 | BLUETOOTH_SCO = 6, |
michael@0 | 453 | ENFORCED_AUDIBLE = 7, // Sounds that cannot be muted by user and must be routed to speaker |
michael@0 | 454 | DTMF = 8, |
michael@0 | 455 | TTS = 9, |
michael@0 | 456 | FM = 10, |
michael@0 | 457 | NUM_STREAM_TYPES |
michael@0 | 458 | }; |
michael@0 | 459 | |
michael@0 | 460 | // Audio sub formats (see AudioSystem::audio_format). |
michael@0 | 461 | enum pcm_sub_format { |
michael@0 | 462 | PCM_SUB_16_BIT = 0x1, // must be 1 for backward compatibility |
michael@0 | 463 | PCM_SUB_8_BIT = 0x2, // must be 2 for backward compatibility |
michael@0 | 464 | }; |
michael@0 | 465 | |
michael@0 | 466 | // MP3 sub format field definition : can use 11 LSBs in the same way as MP3 frame header to specify |
michael@0 | 467 | // bit rate, stereo mode, version... |
michael@0 | 468 | enum mp3_sub_format { |
michael@0 | 469 | //TODO |
michael@0 | 470 | }; |
michael@0 | 471 | |
michael@0 | 472 | // AMR NB/WB sub format field definition: specify frame block interleaving, bandwidth efficient or octet aligned, |
michael@0 | 473 | // encoding mode for recording... |
michael@0 | 474 | enum amr_sub_format { |
michael@0 | 475 | //TODO |
michael@0 | 476 | }; |
michael@0 | 477 | |
michael@0 | 478 | // AAC sub format field definition: specify profile or bitrate for recording... |
michael@0 | 479 | enum aac_sub_format { |
michael@0 | 480 | //TODO |
michael@0 | 481 | }; |
michael@0 | 482 | |
michael@0 | 483 | // VORBIS sub format field definition: specify quality for recording... |
michael@0 | 484 | enum vorbis_sub_format { |
michael@0 | 485 | //TODO |
michael@0 | 486 | }; |
michael@0 | 487 | |
michael@0 | 488 | // Audio format consists in a main format field (upper 8 bits) and a sub format field (lower 24 bits). |
michael@0 | 489 | // The main format indicates the main codec type. The sub format field indicates options and parameters |
michael@0 | 490 | // for each format. The sub format is mainly used for record to indicate for instance the requested bitrate |
michael@0 | 491 | // or profile. It can also be used for certain formats to give informations not present in the encoded |
michael@0 | 492 | // audio stream (e.g. octet alignement for AMR). |
michael@0 | 493 | enum audio_format { |
michael@0 | 494 | INVALID_FORMAT = -1, |
michael@0 | 495 | FORMAT_DEFAULT = 0, |
michael@0 | 496 | PCM = 0x00000000, // must be 0 for backward compatibility |
michael@0 | 497 | MP3 = 0x01000000, |
michael@0 | 498 | AMR_NB = 0x02000000, |
michael@0 | 499 | AMR_WB = 0x03000000, |
michael@0 | 500 | AAC = 0x04000000, |
michael@0 | 501 | HE_AAC_V1 = 0x05000000, |
michael@0 | 502 | HE_AAC_V2 = 0x06000000, |
michael@0 | 503 | VORBIS = 0x07000000, |
michael@0 | 504 | EVRC = 0x08000000, |
michael@0 | 505 | QCELP = 0x09000000, |
michael@0 | 506 | VOIP_PCM_INPUT = 0x0A000000, |
michael@0 | 507 | MAIN_FORMAT_MASK = 0xFF000000, |
michael@0 | 508 | SUB_FORMAT_MASK = 0x00FFFFFF, |
michael@0 | 509 | // Aliases |
michael@0 | 510 | PCM_16_BIT = (PCM|PCM_SUB_16_BIT), |
michael@0 | 511 | PCM_8_BIT = (PCM|PCM_SUB_8_BIT) |
michael@0 | 512 | }; |
michael@0 | 513 | |
michael@0 | 514 | |
michael@0 | 515 | // Channel mask definitions must be kept in sync with JAVA values in /media/java/android/media/AudioFormat.java |
michael@0 | 516 | enum audio_channels { |
michael@0 | 517 | // output channels |
michael@0 | 518 | CHANNEL_OUT_FRONT_LEFT = 0x4, |
michael@0 | 519 | CHANNEL_OUT_FRONT_RIGHT = 0x8, |
michael@0 | 520 | CHANNEL_OUT_FRONT_CENTER = 0x10, |
michael@0 | 521 | CHANNEL_OUT_LOW_FREQUENCY = 0x20, |
michael@0 | 522 | CHANNEL_OUT_BACK_LEFT = 0x40, |
michael@0 | 523 | CHANNEL_OUT_BACK_RIGHT = 0x80, |
michael@0 | 524 | CHANNEL_OUT_FRONT_LEFT_OF_CENTER = 0x100, |
michael@0 | 525 | CHANNEL_OUT_FRONT_RIGHT_OF_CENTER = 0x200, |
michael@0 | 526 | CHANNEL_OUT_BACK_CENTER = 0x400, |
michael@0 | 527 | CHANNEL_OUT_MONO = CHANNEL_OUT_FRONT_LEFT, |
michael@0 | 528 | CHANNEL_OUT_STEREO = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT), |
michael@0 | 529 | CHANNEL_OUT_QUAD = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT | |
michael@0 | 530 | CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT), |
michael@0 | 531 | CHANNEL_OUT_SURROUND = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT | |
michael@0 | 532 | CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_BACK_CENTER), |
michael@0 | 533 | CHANNEL_OUT_5POINT1 = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT | |
michael@0 | 534 | CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY | CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT), |
michael@0 | 535 | CHANNEL_OUT_7POINT1 = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT | |
michael@0 | 536 | CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY | CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT | |
michael@0 | 537 | CHANNEL_OUT_FRONT_LEFT_OF_CENTER | CHANNEL_OUT_FRONT_RIGHT_OF_CENTER), |
michael@0 | 538 | CHANNEL_OUT_ALL = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT | |
michael@0 | 539 | CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY | CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT | |
michael@0 | 540 | CHANNEL_OUT_FRONT_LEFT_OF_CENTER | CHANNEL_OUT_FRONT_RIGHT_OF_CENTER | CHANNEL_OUT_BACK_CENTER), |
michael@0 | 541 | |
michael@0 | 542 | // input channels |
michael@0 | 543 | CHANNEL_IN_LEFT = 0x4, |
michael@0 | 544 | CHANNEL_IN_RIGHT = 0x8, |
michael@0 | 545 | CHANNEL_IN_FRONT = 0x10, |
michael@0 | 546 | CHANNEL_IN_BACK = 0x20, |
michael@0 | 547 | CHANNEL_IN_LEFT_PROCESSED = 0x40, |
michael@0 | 548 | CHANNEL_IN_RIGHT_PROCESSED = 0x80, |
michael@0 | 549 | CHANNEL_IN_FRONT_PROCESSED = 0x100, |
michael@0 | 550 | CHANNEL_IN_BACK_PROCESSED = 0x200, |
michael@0 | 551 | CHANNEL_IN_PRESSURE = 0x400, |
michael@0 | 552 | CHANNEL_IN_X_AXIS = 0x800, |
michael@0 | 553 | CHANNEL_IN_Y_AXIS = 0x1000, |
michael@0 | 554 | CHANNEL_IN_Z_AXIS = 0x2000, |
michael@0 | 555 | CHANNEL_IN_VOICE_UPLINK = 0x4000, |
michael@0 | 556 | CHANNEL_IN_VOICE_DNLINK = 0x8000, |
michael@0 | 557 | CHANNEL_IN_MONO = CHANNEL_IN_FRONT, |
michael@0 | 558 | CHANNEL_IN_STEREO = (CHANNEL_IN_LEFT | CHANNEL_IN_RIGHT), |
michael@0 | 559 | CHANNEL_IN_ALL = (CHANNEL_IN_LEFT | CHANNEL_IN_RIGHT | CHANNEL_IN_FRONT | CHANNEL_IN_BACK| |
michael@0 | 560 | CHANNEL_IN_LEFT_PROCESSED | CHANNEL_IN_RIGHT_PROCESSED | CHANNEL_IN_FRONT_PROCESSED | CHANNEL_IN_BACK_PROCESSED| |
michael@0 | 561 | CHANNEL_IN_PRESSURE | CHANNEL_IN_X_AXIS | CHANNEL_IN_Y_AXIS | CHANNEL_IN_Z_AXIS | |
michael@0 | 562 | CHANNEL_IN_VOICE_UPLINK | CHANNEL_IN_VOICE_DNLINK) |
michael@0 | 563 | }; |
michael@0 | 564 | |
michael@0 | 565 | enum audio_mode { |
michael@0 | 566 | MODE_INVALID = -2, |
michael@0 | 567 | MODE_CURRENT = -1, |
michael@0 | 568 | MODE_NORMAL = 0, |
michael@0 | 569 | MODE_RINGTONE, |
michael@0 | 570 | MODE_IN_CALL, |
michael@0 | 571 | MODE_IN_COMMUNICATION, |
michael@0 | 572 | NUM_MODES // not a valid entry, denotes end-of-list |
michael@0 | 573 | }; |
michael@0 | 574 | |
michael@0 | 575 | enum audio_in_acoustics { |
michael@0 | 576 | AGC_ENABLE = 0x0001, |
michael@0 | 577 | AGC_DISABLE = 0, |
michael@0 | 578 | NS_ENABLE = 0x0002, |
michael@0 | 579 | NS_DISABLE = 0, |
michael@0 | 580 | TX_IIR_ENABLE = 0x0004, |
michael@0 | 581 | TX_DISABLE = 0 |
michael@0 | 582 | }; |
michael@0 | 583 | |
michael@0 | 584 | // special audio session values |
michael@0 | 585 | enum audio_sessions { |
michael@0 | 586 | SESSION_OUTPUT_STAGE = -1, // session for effects attached to a particular output stream |
michael@0 | 587 | // (value must be less than 0) |
michael@0 | 588 | SESSION_OUTPUT_MIX = 0, // session for effects applied to output mix. These effects can |
michael@0 | 589 | // be moved by audio policy manager to another output stream |
michael@0 | 590 | // (value must be 0) |
michael@0 | 591 | }; |
michael@0 | 592 | |
michael@0 | 593 | /* These are static methods to control the system-wide AudioFlinger |
michael@0 | 594 | * only privileged processes can have access to them |
michael@0 | 595 | */ |
michael@0 | 596 | |
michael@0 | 597 | // mute/unmute microphone |
michael@0 | 598 | static status_t muteMicrophone(bool state); |
michael@0 | 599 | static status_t isMicrophoneMuted(bool *state); |
michael@0 | 600 | |
michael@0 | 601 | // set/get master volume |
michael@0 | 602 | static status_t setMasterVolume(float value); |
michael@0 | 603 | static status_t getMasterVolume(float* volume); |
michael@0 | 604 | // mute/unmute audio outputs |
michael@0 | 605 | static status_t setMasterMute(bool mute); |
michael@0 | 606 | static status_t getMasterMute(bool* mute); |
michael@0 | 607 | |
michael@0 | 608 | // set/get stream volume on specified output |
michael@0 | 609 | static status_t setStreamVolume(int stream, float value, int output); |
michael@0 | 610 | static status_t getStreamVolume(int stream, float* volume, int output); |
michael@0 | 611 | |
michael@0 | 612 | // mute/unmute stream |
michael@0 | 613 | static status_t setStreamMute(int stream, bool mute); |
michael@0 | 614 | static status_t getStreamMute(int stream, bool* mute); |
michael@0 | 615 | |
michael@0 | 616 | // set audio mode in audio hardware (see AudioSystem::audio_mode) |
michael@0 | 617 | static status_t setMode(int mode); |
michael@0 | 618 | |
michael@0 | 619 | // returns true in *state if tracks are active on the specified stream |
michael@0 | 620 | static status_t isStreamActive(int stream, bool *state); |
michael@0 | 621 | |
michael@0 | 622 | // set/get audio hardware parameters. The function accepts a list of parameters |
michael@0 | 623 | // key value pairs in the form: key1=value1;key2=value2;... |
michael@0 | 624 | // Some keys are reserved for standard parameters (See AudioParameter class). |
michael@0 | 625 | static status_t setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs); |
michael@0 | 626 | static String8 getParameters(audio_io_handle_t ioHandle, const String8& keys); |
michael@0 | 627 | |
michael@0 | 628 | static void setErrorCallback(audio_error_callback cb); |
michael@0 | 629 | |
michael@0 | 630 | // helper function to obtain AudioFlinger service handle |
michael@0 | 631 | static const sp<IAudioFlinger>& get_audio_flinger(); |
michael@0 | 632 | |
michael@0 | 633 | static float linearToLog(int volume); |
michael@0 | 634 | static int logToLinear(float volume); |
michael@0 | 635 | |
michael@0 | 636 | static status_t getOutputSamplingRate(int* samplingRate, int stream = DEFAULT); |
michael@0 | 637 | static status_t getOutputFrameCount(int* frameCount, int stream = DEFAULT); |
michael@0 | 638 | static status_t getOutputLatency(uint32_t* latency, int stream = DEFAULT); |
michael@0 | 639 | |
michael@0 | 640 | static bool routedToA2dpOutput(int streamType); |
michael@0 | 641 | |
michael@0 | 642 | static status_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount, |
michael@0 | 643 | size_t* buffSize); |
michael@0 | 644 | |
michael@0 | 645 | static status_t setVoiceVolume(float volume); |
michael@0 | 646 | |
michael@0 | 647 | // return the number of audio frames written by AudioFlinger to audio HAL and |
michael@0 | 648 | // audio dsp to DAC since the output on which the specificed stream is playing |
michael@0 | 649 | // has exited standby. |
michael@0 | 650 | // returned status (from utils/Errors.h) can be: |
michael@0 | 651 | // - NO_ERROR: successful operation, halFrames and dspFrames point to valid data |
michael@0 | 652 | // - INVALID_OPERATION: Not supported on current hardware platform |
michael@0 | 653 | // - BAD_VALUE: invalid parameter |
michael@0 | 654 | // NOTE: this feature is not supported on all hardware platforms and it is |
michael@0 | 655 | // necessary to check returned status before using the returned values. |
michael@0 | 656 | static status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int stream = DEFAULT); |
michael@0 | 657 | |
michael@0 | 658 | static unsigned int getInputFramesLost(audio_io_handle_t ioHandle); |
michael@0 | 659 | |
michael@0 | 660 | static int newAudioSessionId(); |
michael@0 | 661 | // |
michael@0 | 662 | // AudioPolicyService interface |
michael@0 | 663 | // |
michael@0 | 664 | |
michael@0 | 665 | enum audio_devices { |
michael@0 | 666 | // output devices |
michael@0 | 667 | DEVICE_OUT_EARPIECE = 0x1, |
michael@0 | 668 | DEVICE_OUT_SPEAKER = 0x2, |
michael@0 | 669 | DEVICE_OUT_WIRED_HEADSET = 0x4, |
michael@0 | 670 | DEVICE_OUT_WIRED_HEADPHONE = 0x8, |
michael@0 | 671 | DEVICE_OUT_BLUETOOTH_SCO = 0x10, |
michael@0 | 672 | DEVICE_OUT_BLUETOOTH_SCO_HEADSET = 0x20, |
michael@0 | 673 | DEVICE_OUT_BLUETOOTH_SCO_CARKIT = 0x40, |
michael@0 | 674 | DEVICE_OUT_BLUETOOTH_A2DP = 0x80, |
michael@0 | 675 | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100, |
michael@0 | 676 | DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = 0x200, |
michael@0 | 677 | DEVICE_OUT_AUX_DIGITAL = 0x400, |
michael@0 | 678 | DEVICE_OUT_DEFAULT = 0x8000, |
michael@0 | 679 | DEVICE_OUT_ALL = (DEVICE_OUT_EARPIECE | DEVICE_OUT_SPEAKER | DEVICE_OUT_WIRED_HEADSET | |
michael@0 | 680 | DEVICE_OUT_WIRED_HEADPHONE | DEVICE_OUT_BLUETOOTH_SCO | DEVICE_OUT_BLUETOOTH_SCO_HEADSET | |
michael@0 | 681 | DEVICE_OUT_BLUETOOTH_SCO_CARKIT | DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | |
michael@0 | 682 | DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER | DEVICE_OUT_AUX_DIGITAL | DEVICE_OUT_DEFAULT), |
michael@0 | 683 | DEVICE_OUT_ALL_A2DP = (DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | |
michael@0 | 684 | DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER), |
michael@0 | 685 | |
michael@0 | 686 | // input devices |
michael@0 | 687 | DEVICE_IN_COMMUNICATION = 0x10000, |
michael@0 | 688 | DEVICE_IN_AMBIENT = 0x20000, |
michael@0 | 689 | DEVICE_IN_BUILTIN_MIC = 0x40000, |
michael@0 | 690 | DEVICE_IN_BLUETOOTH_SCO_HEADSET = 0x80000, |
michael@0 | 691 | DEVICE_IN_WIRED_HEADSET = 0x100000, |
michael@0 | 692 | DEVICE_IN_AUX_DIGITAL = 0x200000, |
michael@0 | 693 | DEVICE_IN_VOICE_CALL = 0x400000, |
michael@0 | 694 | DEVICE_IN_BACK_MIC = 0x800000, |
michael@0 | 695 | DEVICE_IN_DEFAULT = 0x80000000, |
michael@0 | 696 | |
michael@0 | 697 | DEVICE_IN_ALL = (DEVICE_IN_COMMUNICATION | DEVICE_IN_AMBIENT | DEVICE_IN_BUILTIN_MIC | |
michael@0 | 698 | DEVICE_IN_BLUETOOTH_SCO_HEADSET | DEVICE_IN_WIRED_HEADSET | DEVICE_IN_AUX_DIGITAL | |
michael@0 | 699 | DEVICE_IN_VOICE_CALL | DEVICE_IN_BACK_MIC | DEVICE_IN_DEFAULT) |
michael@0 | 700 | }; |
michael@0 | 701 | |
michael@0 | 702 | // device connection states used for setDeviceConnectionState() |
michael@0 | 703 | enum device_connection_state { |
michael@0 | 704 | DEVICE_STATE_UNAVAILABLE, |
michael@0 | 705 | DEVICE_STATE_AVAILABLE, |
michael@0 | 706 | NUM_DEVICE_STATES |
michael@0 | 707 | }; |
michael@0 | 708 | |
michael@0 | 709 | // request to open a direct output with getOutput() (by opposition to sharing an output with other AudioTracks) |
michael@0 | 710 | enum output_flags { |
michael@0 | 711 | OUTPUT_FLAG_INDIRECT = 0x0, |
michael@0 | 712 | OUTPUT_FLAG_DIRECT = 0x1 |
michael@0 | 713 | }; |
michael@0 | 714 | |
michael@0 | 715 | // device categories used for setForceUse() |
michael@0 | 716 | enum forced_config { |
michael@0 | 717 | FORCE_NONE, |
michael@0 | 718 | FORCE_SPEAKER, |
michael@0 | 719 | FORCE_HEADPHONES, |
michael@0 | 720 | FORCE_BT_SCO, |
michael@0 | 721 | FORCE_BT_A2DP, |
michael@0 | 722 | FORCE_WIRED_ACCESSORY, |
michael@0 | 723 | FORCE_BT_CAR_DOCK, |
michael@0 | 724 | FORCE_BT_DESK_DOCK, |
michael@0 | 725 | NUM_FORCE_CONFIG, |
michael@0 | 726 | FORCE_DEFAULT = FORCE_NONE |
michael@0 | 727 | }; |
michael@0 | 728 | |
michael@0 | 729 | // usages used for setForceUse() |
michael@0 | 730 | enum force_use { |
michael@0 | 731 | FOR_COMMUNICATION, |
michael@0 | 732 | FOR_MEDIA, |
michael@0 | 733 | FOR_RECORD, |
michael@0 | 734 | FOR_DOCK, |
michael@0 | 735 | NUM_FORCE_USE |
michael@0 | 736 | }; |
michael@0 | 737 | |
michael@0 | 738 | // types of io configuration change events received with ioConfigChanged() |
michael@0 | 739 | enum io_config_event { |
michael@0 | 740 | OUTPUT_OPENED, |
michael@0 | 741 | OUTPUT_CLOSED, |
michael@0 | 742 | OUTPUT_CONFIG_CHANGED, |
michael@0 | 743 | INPUT_OPENED, |
michael@0 | 744 | INPUT_CLOSED, |
michael@0 | 745 | INPUT_CONFIG_CHANGED, |
michael@0 | 746 | STREAM_CONFIG_CHANGED, |
michael@0 | 747 | NUM_CONFIG_EVENTS |
michael@0 | 748 | }; |
michael@0 | 749 | |
michael@0 | 750 | // audio output descritor used to cache output configurations in client process to avoid frequent calls |
michael@0 | 751 | // through IAudioFlinger |
michael@0 | 752 | class OutputDescriptor { |
michael@0 | 753 | public: |
michael@0 | 754 | OutputDescriptor() |
michael@0 | 755 | : samplingRate(0), format(0), channels(0), frameCount(0), latency(0) {} |
michael@0 | 756 | |
michael@0 | 757 | uint32_t samplingRate; |
michael@0 | 758 | int32_t format; |
michael@0 | 759 | int32_t channels; |
michael@0 | 760 | size_t frameCount; |
michael@0 | 761 | uint32_t latency; |
michael@0 | 762 | }; |
michael@0 | 763 | |
michael@0 | 764 | // |
michael@0 | 765 | // IAudioPolicyService interface (see AudioPolicyInterface for method descriptions) |
michael@0 | 766 | // |
michael@0 | 767 | static status_t setDeviceConnectionState(audio_devices device, device_connection_state state, const char *device_address); |
michael@0 | 768 | static device_connection_state getDeviceConnectionState(audio_devices device, const char *device_address); |
michael@0 | 769 | static status_t setPhoneState(int state); |
michael@0 | 770 | #if ANDROID_VERSION >= 17 |
michael@0 | 771 | static status_t setPhoneState(audio_mode_t state); |
michael@0 | 772 | #endif |
michael@0 | 773 | static status_t setRingerMode(uint32_t mode, uint32_t mask); |
michael@0 | 774 | #ifdef VANILLA_ANDROID |
michael@0 | 775 | static status_t setForceUse(force_use usage, forced_config config); |
michael@0 | 776 | static forced_config getForceUse(force_use usage); |
michael@0 | 777 | static audio_io_handle_t getOutput(stream_type stream, |
michael@0 | 778 | uint32_t samplingRate = 0, |
michael@0 | 779 | uint32_t format = FORMAT_DEFAULT, |
michael@0 | 780 | uint32_t channels = CHANNEL_OUT_STEREO, |
michael@0 | 781 | output_flags flags = OUTPUT_FLAG_INDIRECT); |
michael@0 | 782 | static status_t setDeviceConnectionState(audio_devices_t device, audio_policy_dev_state_t state, const char *device_address); |
michael@0 | 783 | static status_t setFmVolume(float volume); |
michael@0 | 784 | static audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device, const char *device_address); |
michael@0 | 785 | #else |
michael@0 | 786 | static status_t setForceUse(force_use usage, forced_config config) __attribute__((weak)); |
michael@0 | 787 | static forced_config getForceUse(force_use usage) __attribute__((weak)); |
michael@0 | 788 | static audio_io_handle_t getOutput(stream_type stream, |
michael@0 | 789 | uint32_t samplingRate = 0, |
michael@0 | 790 | uint32_t format = FORMAT_DEFAULT, |
michael@0 | 791 | uint32_t channels = CHANNEL_OUT_STEREO, |
michael@0 | 792 | output_flags flags = OUTPUT_FLAG_INDIRECT) __attribute__((weak)); |
michael@0 | 793 | |
michael@0 | 794 | static status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) __attribute__((weak)); |
michael@0 | 795 | static audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) __attribute__((weak)); |
michael@0 | 796 | static audio_io_handle_t getOutput(audio_stream_type_t stream, |
michael@0 | 797 | uint32_t samplingRate = 0, |
michael@0 | 798 | uint32_t format = AUDIO_FORMAT_DEFAULT, |
michael@0 | 799 | uint32_t channels = AUDIO_CHANNEL_OUT_STEREO, |
michael@0 | 800 | audio_policy_output_flags_t flags = AUDIO_POLICY_OUTPUT_FLAG_INDIRECT) __attribute__((weak)); |
michael@0 | 801 | static status_t setDeviceConnectionState(audio_devices_t device, audio_policy_dev_state_t state, const char *device_address) __attribute__((weak)); |
michael@0 | 802 | static status_t setFmVolume(float volume) __attribute__((weak)); |
michael@0 | 803 | static audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device, const char *device_address) __attribute__((weak)); |
michael@0 | 804 | |
michael@0 | 805 | #endif |
michael@0 | 806 | static status_t startOutput(audio_io_handle_t output, |
michael@0 | 807 | AudioSystem::stream_type stream, |
michael@0 | 808 | int session = 0); |
michael@0 | 809 | static status_t stopOutput(audio_io_handle_t output, |
michael@0 | 810 | AudioSystem::stream_type stream, |
michael@0 | 811 | int session = 0); |
michael@0 | 812 | static void releaseOutput(audio_io_handle_t output); |
michael@0 | 813 | static audio_io_handle_t getInput(int inputSource, |
michael@0 | 814 | uint32_t samplingRate = 0, |
michael@0 | 815 | uint32_t format = FORMAT_DEFAULT, |
michael@0 | 816 | uint32_t channels = CHANNEL_IN_MONO, |
michael@0 | 817 | audio_in_acoustics acoustics = (audio_in_acoustics)0); |
michael@0 | 818 | static status_t startInput(audio_io_handle_t input); |
michael@0 | 819 | static status_t stopInput(audio_io_handle_t input); |
michael@0 | 820 | static void releaseInput(audio_io_handle_t input); |
michael@0 | 821 | static status_t initStreamVolume(stream_type stream, |
michael@0 | 822 | int indexMin, |
michael@0 | 823 | int indexMax); |
michael@0 | 824 | static status_t initStreamVolume(audio_stream_type_t stream, |
michael@0 | 825 | int indexMin, |
michael@0 | 826 | int indexMax); |
michael@0 | 827 | static status_t setStreamVolumeIndex(stream_type stream, int index); |
michael@0 | 828 | static status_t setStreamVolumeIndex(audio_stream_type_t stream, int index); |
michael@0 | 829 | #if ANDROID_VERSION >= 17 |
michael@0 | 830 | static status_t setStreamVolumeIndex(audio_stream_type_t stream, |
michael@0 | 831 | int index, |
michael@0 | 832 | audio_devices_t device); |
michael@0 | 833 | static status_t getStreamVolumeIndex(audio_stream_type_t stream, |
michael@0 | 834 | int *index, |
michael@0 | 835 | audio_devices_t device); |
michael@0 | 836 | #endif |
michael@0 | 837 | static status_t getStreamVolumeIndex(stream_type stream, int *index); |
michael@0 | 838 | static status_t getStreamVolumeIndex(audio_stream_type_t stream, int *index); |
michael@0 | 839 | |
michael@0 | 840 | static uint32_t getStrategyForStream(stream_type stream); |
michael@0 | 841 | |
michael@0 | 842 | static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc); |
michael@0 | 843 | static status_t registerEffect(effect_descriptor_t *desc, |
michael@0 | 844 | audio_io_handle_t output, |
michael@0 | 845 | uint32_t strategy, |
michael@0 | 846 | int session, |
michael@0 | 847 | int id); |
michael@0 | 848 | static status_t unregisterEffect(int id); |
michael@0 | 849 | |
michael@0 | 850 | static const sp<IAudioPolicyService>& get_audio_policy_service(); |
michael@0 | 851 | |
michael@0 | 852 | // ---------------------------------------------------------------------------- |
michael@0 | 853 | |
michael@0 | 854 | static uint32_t popCount(uint32_t u); |
michael@0 | 855 | static bool isOutputDevice(audio_devices device); |
michael@0 | 856 | static bool isInputDevice(audio_devices device); |
michael@0 | 857 | static bool isA2dpDevice(audio_devices device); |
michael@0 | 858 | static bool isBluetoothScoDevice(audio_devices device); |
michael@0 | 859 | static bool isSeperatedStream(stream_type stream); |
michael@0 | 860 | static bool isLowVisibility(stream_type stream); |
michael@0 | 861 | static bool isOutputChannel(uint32_t channel); |
michael@0 | 862 | static bool isInputChannel(uint32_t channel); |
michael@0 | 863 | static bool isValidFormat(uint32_t format); |
michael@0 | 864 | static bool isLinearPCM(uint32_t format); |
michael@0 | 865 | static bool isModeInCall(); |
michael@0 | 866 | |
michael@0 | 867 | private: |
michael@0 | 868 | |
michael@0 | 869 | class AudioFlingerClient: public IBinder::DeathRecipient, public BnAudioFlingerClient |
michael@0 | 870 | { |
michael@0 | 871 | public: |
michael@0 | 872 | AudioFlingerClient() { |
michael@0 | 873 | } |
michael@0 | 874 | |
michael@0 | 875 | // DeathRecipient |
michael@0 | 876 | virtual void binderDied(const wp<IBinder>& who); |
michael@0 | 877 | |
michael@0 | 878 | // IAudioFlingerClient |
michael@0 | 879 | |
michael@0 | 880 | // indicate a change in the configuration of an output or input: keeps the cached |
michael@0 | 881 | // values for output/input parameters upto date in client process |
michael@0 | 882 | virtual void ioConfigChanged(int event, int ioHandle, void *param2); |
michael@0 | 883 | }; |
michael@0 | 884 | |
michael@0 | 885 | class AudioPolicyServiceClient: public IBinder::DeathRecipient |
michael@0 | 886 | { |
michael@0 | 887 | public: |
michael@0 | 888 | AudioPolicyServiceClient() { |
michael@0 | 889 | } |
michael@0 | 890 | |
michael@0 | 891 | // DeathRecipient |
michael@0 | 892 | virtual void binderDied(const wp<IBinder>& who); |
michael@0 | 893 | }; |
michael@0 | 894 | |
michael@0 | 895 | static sp<AudioFlingerClient> gAudioFlingerClient; |
michael@0 | 896 | static sp<AudioPolicyServiceClient> gAudioPolicyServiceClient; |
michael@0 | 897 | friend class AudioFlingerClient; |
michael@0 | 898 | friend class AudioPolicyServiceClient; |
michael@0 | 899 | |
michael@0 | 900 | static Mutex gLock; |
michael@0 | 901 | static sp<IAudioFlinger> gAudioFlinger; |
michael@0 | 902 | static audio_error_callback gAudioErrorCallback; |
michael@0 | 903 | |
michael@0 | 904 | static size_t gInBuffSize; |
michael@0 | 905 | // previous parameters for recording buffer size queries |
michael@0 | 906 | static uint32_t gPrevInSamplingRate; |
michael@0 | 907 | static int gPrevInFormat; |
michael@0 | 908 | static int gPrevInChannelCount; |
michael@0 | 909 | |
michael@0 | 910 | static sp<IAudioPolicyService> gAudioPolicyService; |
michael@0 | 911 | |
michael@0 | 912 | // mapping between stream types and outputs |
michael@0 | 913 | static DefaultKeyedVector<int, audio_io_handle_t> gStreamOutputMap; |
michael@0 | 914 | // list of output descritor containing cached parameters (sampling rate, framecount, channel count...) |
michael@0 | 915 | static DefaultKeyedVector<audio_io_handle_t, OutputDescriptor *> gOutputs; |
michael@0 | 916 | }; |
michael@0 | 917 | |
michael@0 | 918 | class AudioParameter { |
michael@0 | 919 | |
michael@0 | 920 | public: |
michael@0 | 921 | AudioParameter() {} |
michael@0 | 922 | AudioParameter(const String8& keyValuePairs); |
michael@0 | 923 | virtual ~AudioParameter(); |
michael@0 | 924 | |
michael@0 | 925 | // reserved parameter keys for changing standard parameters with setParameters() function. |
michael@0 | 926 | // Using these keys is mandatory for AudioFlinger to properly monitor audio output/input |
michael@0 | 927 | // configuration changes and act accordingly. |
michael@0 | 928 | // keyRouting: to change audio routing, value is an int in AudioSystem::audio_devices |
michael@0 | 929 | // keySamplingRate: to change sampling rate routing, value is an int |
michael@0 | 930 | // keyFormat: to change audio format, value is an int in AudioSystem::audio_format |
michael@0 | 931 | // keyChannels: to change audio channel configuration, value is an int in AudioSystem::audio_channels |
michael@0 | 932 | // keyFrameCount: to change audio output frame count, value is an int |
michael@0 | 933 | // keyInputSource: to change audio input source, value is an int in audio_source |
michael@0 | 934 | // (defined in media/mediarecorder.h) |
michael@0 | 935 | static const char *keyRouting; |
michael@0 | 936 | static const char *keySamplingRate; |
michael@0 | 937 | static const char *keyFormat; |
michael@0 | 938 | static const char *keyChannels; |
michael@0 | 939 | static const char *keyFrameCount; |
michael@0 | 940 | static const char *keyInputSource; |
michael@0 | 941 | |
michael@0 | 942 | String8 toString(); |
michael@0 | 943 | |
michael@0 | 944 | status_t add(const String8& key, const String8& value); |
michael@0 | 945 | status_t addInt(const String8& key, const int value); |
michael@0 | 946 | status_t addFloat(const String8& key, const float value); |
michael@0 | 947 | |
michael@0 | 948 | status_t remove(const String8& key); |
michael@0 | 949 | |
michael@0 | 950 | status_t get(const String8& key, String8& value); |
michael@0 | 951 | status_t getInt(const String8& key, int& value); |
michael@0 | 952 | status_t getFloat(const String8& key, float& value); |
michael@0 | 953 | status_t getAt(size_t index, String8& key, String8& value); |
michael@0 | 954 | |
michael@0 | 955 | size_t size() { return mParameters.size(); } |
michael@0 | 956 | |
michael@0 | 957 | private: |
michael@0 | 958 | String8 mKeyValuePairs; |
michael@0 | 959 | KeyedVector <String8, String8> mParameters; |
michael@0 | 960 | }; |
michael@0 | 961 | |
michael@0 | 962 | }; // namespace android |
michael@0 | 963 | |
michael@0 | 964 | #endif /*ANDROID_AUDIOSYSTEM_H_*/ |