AudioSystem.h revision 4bcae82f9b07d1a39956c45a6f5bec0b696c4dd1
189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project/* 289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project 389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * 489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * you may not use this file except in compliance with the License. 689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * You may obtain a copy of the License at 789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * 889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * 1089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * Unless required by applicable law or agreed to in writing, software 1189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 1289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * See the License for the specific language governing permissions and 1489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * limitations under the License. 1589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project */ 1689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 1789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#ifndef ANDROID_AUDIOSYSTEM_H_ 1889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#define ANDROID_AUDIOSYSTEM_H_ 1989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 2089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#include <utils/RefBase.h> 2189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#include <utils/threads.h> 2289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#include <media/IAudioFlinger.h> 2389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 2489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectnamespace android { 2589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 2689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projecttypedef void (*audio_error_callback)(status_t err); 27fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurenttypedef int audio_io_handle_t; 28c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 29c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass IAudioPolicyService; 30c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass String8; 3189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 3289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectclass AudioSystem 3389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project{ 3489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectpublic: 3589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 364bcae82f9b07d1a39956c45a6f5bec0b696c4dd1Glenn Kasten // must match android/media/AudioSystem.java STREAM_* constants 3789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project enum stream_type { 38c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEFAULT =-1, 39c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent VOICE_CALL = 0, 40c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SYSTEM = 1, 41c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent RING = 2, 42c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent MUSIC = 3, 43c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent ALARM = 4, 44c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent NOTIFICATION = 5, 45c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent BLUETOOTH_SCO = 6, 4629a65006e517ae5bb164e973b2d805ebfa834a2eEric Laurent ENFORCED_AUDIBLE = 7, // Sounds that cannot be muted by user and must be routed to speaker 47c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DTMF = 8, 48c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent TTS = 9, 4989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project NUM_STREAM_TYPES 5089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project }; 5189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 52c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // Audio sub formats (see AudioSystem::audio_format). 53c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent enum pcm_sub_format { 54ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent PCM_SUB_16_BIT = 0x1, // must be 1 for backward compatibility 55ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent PCM_SUB_8_BIT = 0x2, // must be 2 for backward compatibility 56c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent }; 57c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 584bcae82f9b07d1a39956c45a6f5bec0b696c4dd1Glenn Kasten // FIXME These sub_format enums are currently unused 594bcae82f9b07d1a39956c45a6f5bec0b696c4dd1Glenn Kasten 60c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // MP3 sub format field definition : can use 11 LSBs in the same way as MP3 frame header to specify 61c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // bit rate, stereo mode, version... 62c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent enum mp3_sub_format { 63c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent //TODO 64c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent }; 65c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 66c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // AMR NB/WB sub format field definition: specify frame block interleaving, bandwidth efficient or octet aligned, 67c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // encoding mode for recording... 68c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent enum amr_sub_format { 69c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent //TODO 70c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent }; 71c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 72c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // AAC sub format field definition: specify profile or bitrate for recording... 73c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent enum aac_sub_format { 74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent //TODO 7589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project }; 7689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 77c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // VORBIS sub format field definition: specify quality for recording... 78c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent enum vorbis_sub_format { 79c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent //TODO 80c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent }; 81c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 82c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // Audio format consists in a main format field (upper 8 bits) and a sub format field (lower 24 bits). 83c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // The main format indicates the main codec type. The sub format field indicates options and parameters 84c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // for each format. The sub format is mainly used for record to indicate for instance the requested bitrate 85c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // or profile. It can also be used for certain formats to give informations not present in the encoded 86c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // audio stream (e.g. octet alignement for AMR). 8789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project enum audio_format { 88c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent INVALID_FORMAT = -1, 89c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent FORMAT_DEFAULT = 0, 90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent PCM = 0x00000000, // must be 0 for backward compatibility 91c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent MP3 = 0x01000000, 92c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent AMR_NB = 0x02000000, 93c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent AMR_WB = 0x03000000, 94c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent AAC = 0x04000000, 95c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent HE_AAC_V1 = 0x05000000, 96c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent HE_AAC_V2 = 0x06000000, 97c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent VORBIS = 0x07000000, 98c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent MAIN_FORMAT_MASK = 0xFF000000, 99c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SUB_FORMAT_MASK = 0x00FFFFFF, 100c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // Aliases 101c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent PCM_16_BIT = (PCM|PCM_SUB_16_BIT), 102c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent PCM_8_BIT = (PCM|PCM_SUB_8_BIT) 103c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent }; 104c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 105c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 1064bcae82f9b07d1a39956c45a6f5bec0b696c4dd1Glenn Kasten // Channel mask definitions must be kept in sync with values in /media/java/android/media/AudioFormat.java 107c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent enum audio_channels { 108c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // output channels 109ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_FRONT_LEFT = 0x4, 110ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_FRONT_RIGHT = 0x8, 111ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_FRONT_CENTER = 0x10, 112ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_LOW_FREQUENCY = 0x20, 113ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_BACK_LEFT = 0x40, 114ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_BACK_RIGHT = 0x80, 115ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_FRONT_LEFT_OF_CENTER = 0x100, 116ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_FRONT_RIGHT_OF_CENTER = 0x200, 117ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_BACK_CENTER = 0x400, 118ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_MONO = CHANNEL_OUT_FRONT_LEFT, 119ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_STEREO = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT), 120ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_QUAD = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT | 121ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT), 122ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_SURROUND = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT | 123ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_BACK_CENTER), 124ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_5POINT1 = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT | 125ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY | CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT), 126ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_7POINT1 = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT | 127ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY | CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT | 128ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent CHANNEL_OUT_FRONT_LEFT_OF_CENTER | CHANNEL_OUT_FRONT_RIGHT_OF_CENTER), 129c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHANNEL_OUT_ALL = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT | 130c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY | CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT | 131c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHANNEL_OUT_FRONT_LEFT_OF_CENTER | CHANNEL_OUT_FRONT_RIGHT_OF_CENTER | CHANNEL_OUT_BACK_CENTER), 132c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 133c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // input channels 1349a92037bd6477533062d635b676a6c9833aab96eEric Laurent CHANNEL_IN_LEFT = 0x4, 1359a92037bd6477533062d635b676a6c9833aab96eEric Laurent CHANNEL_IN_RIGHT = 0x8, 1369a92037bd6477533062d635b676a6c9833aab96eEric Laurent CHANNEL_IN_FRONT = 0x10, 1379a92037bd6477533062d635b676a6c9833aab96eEric Laurent CHANNEL_IN_BACK = 0x20, 1389a92037bd6477533062d635b676a6c9833aab96eEric Laurent CHANNEL_IN_LEFT_PROCESSED = 0x40, 1399a92037bd6477533062d635b676a6c9833aab96eEric Laurent CHANNEL_IN_RIGHT_PROCESSED = 0x80, 1409a92037bd6477533062d635b676a6c9833aab96eEric Laurent CHANNEL_IN_FRONT_PROCESSED = 0x100, 1419a92037bd6477533062d635b676a6c9833aab96eEric Laurent CHANNEL_IN_BACK_PROCESSED = 0x200, 1429a92037bd6477533062d635b676a6c9833aab96eEric Laurent CHANNEL_IN_PRESSURE = 0x400, 1439a92037bd6477533062d635b676a6c9833aab96eEric Laurent CHANNEL_IN_X_AXIS = 0x800, 1449a92037bd6477533062d635b676a6c9833aab96eEric Laurent CHANNEL_IN_Y_AXIS = 0x1000, 1459a92037bd6477533062d635b676a6c9833aab96eEric Laurent CHANNEL_IN_Z_AXIS = 0x2000, 1469a92037bd6477533062d635b676a6c9833aab96eEric Laurent CHANNEL_IN_VOICE_UPLINK = 0x4000, 1479a92037bd6477533062d635b676a6c9833aab96eEric Laurent CHANNEL_IN_VOICE_DNLINK = 0x8000, 148c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHANNEL_IN_MONO = CHANNEL_IN_FRONT, 149c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHANNEL_IN_STEREO = (CHANNEL_IN_LEFT | CHANNEL_IN_RIGHT), 150c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHANNEL_IN_ALL = (CHANNEL_IN_LEFT | CHANNEL_IN_RIGHT | CHANNEL_IN_FRONT | CHANNEL_IN_BACK| 151c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHANNEL_IN_LEFT_PROCESSED | CHANNEL_IN_RIGHT_PROCESSED | CHANNEL_IN_FRONT_PROCESSED | CHANNEL_IN_BACK_PROCESSED| 152c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHANNEL_IN_PRESSURE | CHANNEL_IN_X_AXIS | CHANNEL_IN_Y_AXIS | CHANNEL_IN_Z_AXIS | 153c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHANNEL_IN_VOICE_UPLINK | CHANNEL_IN_VOICE_DNLINK) 15489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project }; 15589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 1564bcae82f9b07d1a39956c45a6f5bec0b696c4dd1Glenn Kasten // must match android/media/AudioSystem.java MODE_* values 15789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project enum audio_mode { 15889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project MODE_INVALID = -2, 15989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project MODE_CURRENT = -1, 16089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project MODE_NORMAL = 0, 16189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project MODE_RINGTONE, 16289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project MODE_IN_CALL, 163f1fb01a7f00b8da90a36268aba8584a872e99175Jean-Michel Trivi MODE_IN_COMMUNICATION, 16489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project NUM_MODES // not a valid entry, denotes end-of-list 16589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project }; 16689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 16789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project enum audio_in_acoustics { 16889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project AGC_ENABLE = 0x0001, 16989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project AGC_DISABLE = 0, 17089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project NS_ENABLE = 0x0002, 17189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project NS_DISABLE = 0, 17289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project TX_IIR_ENABLE = 0x0004, 17389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project TX_DISABLE = 0 17489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project }; 17589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 176de070137f11d346fba77605bd76a44c040a618fcEric Laurent // special audio session values 177de070137f11d346fba77605bd76a44c040a618fcEric Laurent enum audio_sessions { 178de070137f11d346fba77605bd76a44c040a618fcEric Laurent SESSION_OUTPUT_STAGE = -1, // session for effects attached to a particular output stream 179de070137f11d346fba77605bd76a44c040a618fcEric Laurent // (value must be less than 0) 180de070137f11d346fba77605bd76a44c040a618fcEric Laurent SESSION_OUTPUT_MIX = 0, // session for effects applied to output mix. These effects can 181de070137f11d346fba77605bd76a44c040a618fcEric Laurent // be moved by audio policy manager to another output stream 182de070137f11d346fba77605bd76a44c040a618fcEric Laurent // (value must be 0) 183de070137f11d346fba77605bd76a44c040a618fcEric Laurent }; 184de070137f11d346fba77605bd76a44c040a618fcEric Laurent 18589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project /* These are static methods to control the system-wide AudioFlinger 18689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * only privileged processes can have access to them 18789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project */ 18889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 189c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // mute/unmute microphone 19089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static status_t muteMicrophone(bool state); 19189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static status_t isMicrophoneMuted(bool *state); 19289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 193c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // set/get master volume 19489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static status_t setMasterVolume(float value); 19589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static status_t getMasterVolume(float* volume); 1964bcae82f9b07d1a39956c45a6f5bec0b696c4dd1Glenn Kasten 197c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // mute/unmute audio outputs 198c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static status_t setMasterMute(bool mute); 19989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static status_t getMasterMute(bool* mute); 20089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 201c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // set/get stream volume on specified output 202fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent static status_t setStreamVolume(int stream, float value, int output); 203fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent static status_t getStreamVolume(int stream, float* volume, int output); 204c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 205c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // mute/unmute stream 20689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static status_t setStreamMute(int stream, bool mute); 20789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static status_t getStreamMute(int stream, bool* mute); 20889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 209c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // set audio mode in audio hardware (see AudioSystem::audio_mode) 21089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static status_t setMode(int mode); 21189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 212eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent // returns true in *state if tracks are active on the specified stream or has been active 213eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent // in the past inPastMs milliseconds 214eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent static status_t isStreamActive(int stream, bool *state, uint32_t inPastMs = 0); 21589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 216c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // set/get audio hardware parameters. The function accepts a list of parameters 217c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // key value pairs in the form: key1=value1;key2=value2;... 218c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // Some keys are reserved for standard parameters (See AudioParameter class). 219c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static status_t setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs); 220c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static String8 getParameters(audio_io_handle_t ioHandle, const String8& keys); 221c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 22289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static void setErrorCallback(audio_error_callback cb); 22389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 22489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project // helper function to obtain AudioFlinger service handle 22589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static const sp<IAudioFlinger>& get_audio_flinger(); 22689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 22789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static float linearToLog(int volume); 22889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static int logToLinear(float volume); 22989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 23089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static status_t getOutputSamplingRate(int* samplingRate, int stream = DEFAULT); 23189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static status_t getOutputFrameCount(int* frameCount, int stream = DEFAULT); 23289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static status_t getOutputLatency(uint32_t* latency, int stream = DEFAULT); 23389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 23489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static bool routedToA2dpOutput(int streamType); 235c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 236c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static status_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount, 23789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project size_t* buffSize); 23889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 239f0ee6f4055e26fb35d9c526a596668a4dc9da5baEric Laurent static status_t setVoiceVolume(float volume); 240c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 241342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent // return the number of audio frames written by AudioFlinger to audio HAL and 2424bcae82f9b07d1a39956c45a6f5bec0b696c4dd1Glenn Kasten // audio dsp to DAC since the output on which the specified stream is playing 243342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent // has exited standby. 244342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent // returned status (from utils/Errors.h) can be: 245342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent // - NO_ERROR: successful operation, halFrames and dspFrames point to valid data 246342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent // - INVALID_OPERATION: Not supported on current hardware platform 247342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent // - BAD_VALUE: invalid parameter 248342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent // NOTE: this feature is not supported on all hardware platforms and it is 249342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent // necessary to check returned status before using the returned values. 250342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent static status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int stream = DEFAULT); 251342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent 25205bca2fde53bfe3063d2a0a877f2b6bfdd6052cfEric Laurent static unsigned int getInputFramesLost(audio_io_handle_t ioHandle); 253be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent 254be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent static int newAudioSessionId(); 255c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // 256c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // AudioPolicyService interface 257c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // 258c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 259c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent enum audio_devices { 260c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // output devices 261ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent DEVICE_OUT_EARPIECE = 0x1, 262ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent DEVICE_OUT_SPEAKER = 0x2, 263ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent DEVICE_OUT_WIRED_HEADSET = 0x4, 264ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent DEVICE_OUT_WIRED_HEADPHONE = 0x8, 265ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent DEVICE_OUT_BLUETOOTH_SCO = 0x10, 266ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent DEVICE_OUT_BLUETOOTH_SCO_HEADSET = 0x20, 267ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent DEVICE_OUT_BLUETOOTH_SCO_CARKIT = 0x40, 268ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent DEVICE_OUT_BLUETOOTH_A2DP = 0x80, 269ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100, 270ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = 0x200, 271ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent DEVICE_OUT_AUX_DIGITAL = 0x400, 272b235dee7be544a6c990ba4f8d89ab03e38c826f8Praveen Bharathi DEVICE_OUT_ANLG_DOCK_HEADSET = 0x800, 273b235dee7be544a6c990ba4f8d89ab03e38c826f8Praveen Bharathi DEVICE_OUT_DGTL_DOCK_HEADSET = 0x1000, 274c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEVICE_OUT_DEFAULT = 0x8000, 275c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEVICE_OUT_ALL = (DEVICE_OUT_EARPIECE | DEVICE_OUT_SPEAKER | DEVICE_OUT_WIRED_HEADSET | 276c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEVICE_OUT_WIRED_HEADPHONE | DEVICE_OUT_BLUETOOTH_SCO | DEVICE_OUT_BLUETOOTH_SCO_HEADSET | 277c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEVICE_OUT_BLUETOOTH_SCO_CARKIT | DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | 278b235dee7be544a6c990ba4f8d89ab03e38c826f8Praveen Bharathi DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER | DEVICE_OUT_AUX_DIGITAL | 279b235dee7be544a6c990ba4f8d89ab03e38c826f8Praveen Bharathi DEVICE_OUT_ANLG_DOCK_HEADSET | DEVICE_OUT_DGTL_DOCK_HEADSET | 280b235dee7be544a6c990ba4f8d89ab03e38c826f8Praveen Bharathi DEVICE_OUT_DEFAULT), 281492e666e47795326f4b12b87b150b550e6074bd8Eric Laurent DEVICE_OUT_ALL_A2DP = (DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | 282492e666e47795326f4b12b87b150b550e6074bd8Eric Laurent DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER), 283c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 284c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // input devices 285c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEVICE_IN_COMMUNICATION = 0x10000, 286c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEVICE_IN_AMBIENT = 0x20000, 287c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEVICE_IN_BUILTIN_MIC = 0x40000, 288c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEVICE_IN_BLUETOOTH_SCO_HEADSET = 0x80000, 289c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEVICE_IN_WIRED_HEADSET = 0x100000, 290c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEVICE_IN_AUX_DIGITAL = 0x200000, 291c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEVICE_IN_VOICE_CALL = 0x400000, 29290b75fbd19571784c8ceee4841a28b8333a8198eEric Laurent DEVICE_IN_BACK_MIC = 0x800000, 293c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEVICE_IN_DEFAULT = 0x80000000, 294c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 295c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEVICE_IN_ALL = (DEVICE_IN_COMMUNICATION | DEVICE_IN_AMBIENT | DEVICE_IN_BUILTIN_MIC | 296c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEVICE_IN_BLUETOOTH_SCO_HEADSET | DEVICE_IN_WIRED_HEADSET | DEVICE_IN_AUX_DIGITAL | 29790b75fbd19571784c8ceee4841a28b8333a8198eEric Laurent DEVICE_IN_VOICE_CALL | DEVICE_IN_BACK_MIC | DEVICE_IN_DEFAULT) 298c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent }; 299c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 300c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // device connection states used for setDeviceConnectionState() 301c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent enum device_connection_state { 302c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEVICE_STATE_UNAVAILABLE, 303c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent DEVICE_STATE_AVAILABLE, 304c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent NUM_DEVICE_STATES 305c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent }; 306c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 307c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // request to open a direct output with getOutput() (by opposition to sharing an output with other AudioTracks) 308c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent enum output_flags { 309c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent OUTPUT_FLAG_INDIRECT = 0x0, 310c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent OUTPUT_FLAG_DIRECT = 0x1 311c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent }; 312c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 313c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // device categories used for setForceUse() 314c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent enum forced_config { 315c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent FORCE_NONE, 316c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent FORCE_SPEAKER, 317c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent FORCE_HEADPHONES, 318c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent FORCE_BT_SCO, 319c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent FORCE_BT_A2DP, 320c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent FORCE_WIRED_ACCESSORY, 3217ddd450f91dc508b26cc550f5b42fded8a731654Eric Laurent FORCE_BT_CAR_DOCK, 3227ddd450f91dc508b26cc550f5b42fded8a731654Eric Laurent FORCE_BT_DESK_DOCK, 323b235dee7be544a6c990ba4f8d89ab03e38c826f8Praveen Bharathi FORCE_ANALOG_DOCK, 324b235dee7be544a6c990ba4f8d89ab03e38c826f8Praveen Bharathi FORCE_DIGITAL_DOCK, 325c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent NUM_FORCE_CONFIG, 326c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent FORCE_DEFAULT = FORCE_NONE 327c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent }; 328c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 3294bcae82f9b07d1a39956c45a6f5bec0b696c4dd1Glenn Kasten // usages used for setForceUse(), must match AudioSystem.java 330c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent enum force_use { 331c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent FOR_COMMUNICATION, 332c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent FOR_MEDIA, 333c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent FOR_RECORD, 33448643f38c9e92dd0a3d4a31c293c954f3df4db1bJean-Michel Trivi FOR_DOCK, 335c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent NUM_FORCE_USE 336c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent }; 337c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 338c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // types of io configuration change events received with ioConfigChanged() 339c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent enum io_config_event { 340c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent OUTPUT_OPENED, 341c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent OUTPUT_CLOSED, 342c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent OUTPUT_CONFIG_CHANGED, 343c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent INPUT_OPENED, 344c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent INPUT_CLOSED, 345c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent INPUT_CONFIG_CHANGED, 346c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent STREAM_CONFIG_CHANGED, 347c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent NUM_CONFIG_EVENTS 348c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent }; 349c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 350c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // audio output descritor used to cache output configurations in client process to avoid frequent calls 351c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // through IAudioFlinger 352c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent class OutputDescriptor { 353c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent public: 354c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent OutputDescriptor() 355c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent : samplingRate(0), format(0), channels(0), frameCount(0), latency(0) {} 356c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 357c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate; 358c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int32_t format; 359c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int32_t channels; 360c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent size_t frameCount; 361c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t latency; 362c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent }; 363c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 364c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // 365c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // IAudioPolicyService interface (see AudioPolicyInterface for method descriptions) 366c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // 367c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static status_t setDeviceConnectionState(audio_devices device, device_connection_state state, const char *device_address); 368c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static device_connection_state getDeviceConnectionState(audio_devices device, const char *device_address); 369c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static status_t setPhoneState(int state); 370c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static status_t setRingerMode(uint32_t mode, uint32_t mask); 371c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static status_t setForceUse(force_use usage, forced_config config); 372c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static forced_config getForceUse(force_use usage); 373c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static audio_io_handle_t getOutput(stream_type stream, 374c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = 0, 375c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t format = FORMAT_DEFAULT, 376c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t channels = CHANNEL_OUT_STEREO, 377c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent output_flags flags = OUTPUT_FLAG_INDIRECT); 378de070137f11d346fba77605bd76a44c040a618fcEric Laurent static status_t startOutput(audio_io_handle_t output, 379de070137f11d346fba77605bd76a44c040a618fcEric Laurent AudioSystem::stream_type stream, 380de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = 0); 381de070137f11d346fba77605bd76a44c040a618fcEric Laurent static status_t stopOutput(audio_io_handle_t output, 382de070137f11d346fba77605bd76a44c040a618fcEric Laurent AudioSystem::stream_type stream, 383de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = 0); 384c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static void releaseOutput(audio_io_handle_t output); 385c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static audio_io_handle_t getInput(int inputSource, 386c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = 0, 387c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t format = FORMAT_DEFAULT, 388c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t channels = CHANNEL_IN_MONO, 389c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_in_acoustics acoustics = (audio_in_acoustics)0); 390c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static status_t startInput(audio_io_handle_t input); 391c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static status_t stopInput(audio_io_handle_t input); 392c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static void releaseInput(audio_io_handle_t input); 393c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static status_t initStreamVolume(stream_type stream, 394c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin, 395c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax); 396c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static status_t setStreamVolumeIndex(stream_type stream, int index); 397c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static status_t getStreamVolumeIndex(stream_type stream, int *index); 398c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 399de070137f11d346fba77605bd76a44c040a618fcEric Laurent static uint32_t getStrategyForStream(stream_type stream); 4006b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten static uint32_t getDevicesForStream(stream_type stream); 401de070137f11d346fba77605bd76a44c040a618fcEric Laurent 402de070137f11d346fba77605bd76a44c040a618fcEric Laurent static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc); 403de070137f11d346fba77605bd76a44c040a618fcEric Laurent static status_t registerEffect(effect_descriptor_t *desc, 404de070137f11d346fba77605bd76a44c040a618fcEric Laurent audio_io_handle_t output, 405de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy, 406de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session, 407de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id); 408de070137f11d346fba77605bd76a44c040a618fcEric Laurent static status_t unregisterEffect(int id); 409de070137f11d346fba77605bd76a44c040a618fcEric Laurent 410c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static const sp<IAudioPolicyService>& get_audio_policy_service(); 411c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 41289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project // ---------------------------------------------------------------------------- 41389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 414c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static uint32_t popCount(uint32_t u); 415c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static bool isOutputDevice(audio_devices device); 416c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static bool isInputDevice(audio_devices device); 417c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static bool isA2dpDevice(audio_devices device); 418c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static bool isBluetoothScoDevice(audio_devices device); 419c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static bool isLowVisibility(stream_type stream); 420c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static bool isOutputChannel(uint32_t channel); 421c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static bool isInputChannel(uint32_t channel); 422c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static bool isValidFormat(uint32_t format); 423c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static bool isLinearPCM(uint32_t format); 424c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 42589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectprivate: 42689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 42789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project class AudioFlingerClient: public IBinder::DeathRecipient, public BnAudioFlingerClient 42889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project { 42989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project public: 430c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent AudioFlingerClient() { 43189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 432c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 43389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project // DeathRecipient 43489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project virtual void binderDied(const wp<IBinder>& who); 435c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 43689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project // IAudioFlingerClient 437c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 438c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // indicate a change in the configuration of an output or input: keeps the cached 439c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // values for output/input parameters upto date in client process 440fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent virtual void ioConfigChanged(int event, int ioHandle, void *param2); 44189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project }; 44289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 443c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent class AudioPolicyServiceClient: public IBinder::DeathRecipient 444c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 445c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent public: 446c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent AudioPolicyServiceClient() { 447c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 44889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 449c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // DeathRecipient 450c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void binderDied(const wp<IBinder>& who); 451c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent }; 452c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 453c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static sp<AudioFlingerClient> gAudioFlingerClient; 454c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static sp<AudioPolicyServiceClient> gAudioPolicyServiceClient; 45589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project friend class AudioFlingerClient; 456c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent friend class AudioPolicyServiceClient; 45789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 45889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static Mutex gLock; 45989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static sp<IAudioFlinger> gAudioFlinger; 46089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static audio_error_callback gAudioErrorCallback; 461c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 46289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static size_t gInBuffSize; 46389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project // previous parameters for recording buffer size queries 46489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static uint32_t gPrevInSamplingRate; 46589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static int gPrevInFormat; 46689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project static int gPrevInChannelCount; 46789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 468c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static sp<IAudioPolicyService> gAudioPolicyService; 469c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 470c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // mapping between stream types and outputs 471c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static DefaultKeyedVector<int, audio_io_handle_t> gStreamOutputMap; 472c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // list of output descritor containing cached parameters (sampling rate, framecount, channel count...) 473c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static DefaultKeyedVector<audio_io_handle_t, OutputDescriptor *> gOutputs; 474c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 475c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 476c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass AudioParameter { 477c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 478c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic: 479c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent AudioParameter() {} 480c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent AudioParameter(const String8& keyValuePairs); 481c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual ~AudioParameter(); 482c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 48356ecd20263d7f63476f756fc5d8b043b325c7bfbJean-Michel Trivi // reserved parameter keys for changing standard parameters with setParameters() function. 484c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // Using these keys is mandatory for AudioFlinger to properly monitor audio output/input 485c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // configuration changes and act accordingly. 486c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // keyRouting: to change audio routing, value is an int in AudioSystem::audio_devices 487c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // keySamplingRate: to change sampling rate routing, value is an int 488c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // keyFormat: to change audio format, value is an int in AudioSystem::audio_format 489c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // keyChannels: to change audio channel configuration, value is an int in AudioSystem::audio_channels 490c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent // keyFrameCount: to change audio output frame count, value is an int 49156ecd20263d7f63476f756fc5d8b043b325c7bfbJean-Michel Trivi // keyInputSource: to change audio input source, value is an int in audio_source 49256ecd20263d7f63476f756fc5d8b043b325c7bfbJean-Michel Trivi // (defined in media/mediarecorder.h) 493c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static const char *keyRouting; 494c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static const char *keySamplingRate; 495c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static const char *keyFormat; 496c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static const char *keyChannels; 497c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent static const char *keyFrameCount; 49856ecd20263d7f63476f756fc5d8b043b325c7bfbJean-Michel Trivi static const char *keyInputSource; 499c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 500c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent String8 toString(); 501c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 502c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent status_t add(const String8& key, const String8& value); 503c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent status_t addInt(const String8& key, const int value); 504c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent status_t addFloat(const String8& key, const float value); 505c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 506c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent status_t remove(const String8& key); 507c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 508c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent status_t get(const String8& key, String8& value); 509c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent status_t getInt(const String8& key, int& value); 510c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent status_t getFloat(const String8& key, float& value); 511a9c322e398a1f5fdcace3b8b73967f010b1c31caEric Laurent status_t getAt(size_t index, String8& key, String8& value); 512c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 513c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent size_t size() { return mParameters.size(); } 514c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 515c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentprivate: 516c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent String8 mKeyValuePairs; 517c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent KeyedVector <String8, String8> mParameters; 51889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project}; 51989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 52089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project}; // namespace android 52189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 52289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#endif /*ANDROID_AUDIOSYSTEM_H_*/ 523