Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_AUDIOPOLICYSERVICE_H |
| 18 | #define ANDROID_AUDIOPOLICYSERVICE_H |
| 19 | |
Eric Laurent | 464d5b3 | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 20 | #include <cutils/misc.h> |
| 21 | #include <cutils/config_utils.h> |
Glenn Kasten | 778170d | 2011-07-08 09:34:50 -0700 | [diff] [blame] | 22 | #include <utils/String8.h> |
Eric Laurent | 327c27b | 2009-08-27 00:48:47 -0700 | [diff] [blame] | 23 | #include <utils/Vector.h> |
Eric Laurent | 464d5b3 | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 24 | #include <utils/SortedVector.h> |
Glenn Kasten | 3515a33 | 2011-02-03 16:55:26 -0800 | [diff] [blame] | 25 | #include <binder/BinderService.h> |
Dima Zavin | 34bb419 | 2011-05-11 14:15:23 -0700 | [diff] [blame] | 26 | #include <system/audio.h> |
Dima Zavin | 290029d | 2011-06-13 18:16:26 -0700 | [diff] [blame] | 27 | #include <system/audio_policy.h> |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 28 | #include <hardware/audio_policy.h> |
Eric Laurent | 464d5b3 | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 29 | #include <media/IAudioPolicyService.h> |
| 30 | #include <media/ToneGenerator.h> |
| 31 | #include <media/AudioEffect.h> |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 32 | |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 33 | namespace android { |
| 34 | |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 35 | // ---------------------------------------------------------------------------- |
| 36 | |
Glenn Kasten | 3515a33 | 2011-02-03 16:55:26 -0800 | [diff] [blame] | 37 | class AudioPolicyService : |
| 38 | public BinderService<AudioPolicyService>, |
| 39 | public BnAudioPolicyService, |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 40 | // public AudioPolicyClientInterface, |
Eric Laurent | 8ed6ed0 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 41 | public IBinder::DeathRecipient |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 42 | { |
Glenn Kasten | 3515a33 | 2011-02-03 16:55:26 -0800 | [diff] [blame] | 43 | friend class BinderService<AudioPolicyService>; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 44 | |
| 45 | public: |
Glenn Kasten | 3515a33 | 2011-02-03 16:55:26 -0800 | [diff] [blame] | 46 | // for BinderService |
| 47 | static const char *getServiceName() { return "media.audio_policy"; } |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 48 | |
| 49 | virtual status_t dump(int fd, const Vector<String16>& args); |
| 50 | |
| 51 | // |
| 52 | // BnAudioPolicyService (see AudioPolicyInterface for method descriptions) |
| 53 | // |
| 54 | |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 55 | virtual status_t setDeviceConnectionState(audio_devices_t device, |
| 56 | audio_policy_dev_state_t state, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 57 | const char *device_address); |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 58 | virtual audio_policy_dev_state_t getDeviceConnectionState( |
| 59 | audio_devices_t device, |
Eric Laurent | 8ed6ed0 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 60 | const char *device_address); |
Glenn Kasten | accb114 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 61 | virtual status_t setPhoneState(audio_mode_t state); |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 62 | virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config); |
| 63 | virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage); |
| 64 | virtual audio_io_handle_t getOutput(audio_stream_type_t stream, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 65 | uint32_t samplingRate = 0, |
Glenn Kasten | 0a204ed | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 66 | audio_format_t format = AUDIO_FORMAT_DEFAULT, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 67 | uint32_t channels = 0, |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 68 | audio_policy_output_flags_t flags = |
Eric Laurent | 45d8c80 | 2012-03-01 09:38:00 -0800 | [diff] [blame] | 69 | AUDIO_POLICY_OUTPUT_FLAG_NONE); |
Eric Laurent | 8ed6ed0 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 70 | virtual status_t startOutput(audio_io_handle_t output, |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 71 | audio_stream_type_t stream, |
Eric Laurent | 8ed6ed0 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 72 | int session = 0); |
| 73 | virtual status_t stopOutput(audio_io_handle_t output, |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 74 | audio_stream_type_t stream, |
Eric Laurent | 8ed6ed0 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 75 | int session = 0); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 76 | virtual void releaseOutput(audio_io_handle_t output); |
Glenn Kasten | 0f0fbd9 | 2012-01-23 13:58:49 -0800 | [diff] [blame] | 77 | virtual audio_io_handle_t getInput(audio_source_t inputSource, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 78 | uint32_t samplingRate = 0, |
Glenn Kasten | 0a204ed | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 79 | audio_format_t format = AUDIO_FORMAT_DEFAULT, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 80 | uint32_t channels = 0, |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 81 | audio_in_acoustics_t acoustics = |
Glenn Kasten | 882c0a2 | 2012-01-27 12:32:34 -0800 | [diff] [blame] | 82 | (audio_in_acoustics_t)0 /*AUDIO_IN_ACOUSTICS_NONE*/, |
Eric Laurent | 464d5b3 | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 83 | int audioSession = 0); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 84 | virtual status_t startInput(audio_io_handle_t input); |
| 85 | virtual status_t stopInput(audio_io_handle_t input); |
| 86 | virtual void releaseInput(audio_io_handle_t input); |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 87 | virtual status_t initStreamVolume(audio_stream_type_t stream, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 88 | int indexMin, |
| 89 | int indexMax); |
Eric Laurent | 9bc8358d | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 90 | virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, |
| 91 | int index, |
| 92 | audio_devices_t device); |
| 93 | virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, |
| 94 | int *index, |
| 95 | audio_devices_t device); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 96 | |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 97 | virtual uint32_t getStrategyForStream(audio_stream_type_t stream); |
Eric Laurent | c9ab9f5 | 2012-03-08 13:42:42 -0800 | [diff] [blame] | 98 | virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream); |
Eric Laurent | 8ed6ed0 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 99 | |
| 100 | virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc); |
| 101 | virtual status_t registerEffect(effect_descriptor_t *desc, |
Eric Laurent | 464d5b3 | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 102 | audio_io_handle_t io, |
Eric Laurent | 8ed6ed0 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 103 | uint32_t strategy, |
| 104 | int session, |
| 105 | int id); |
| 106 | virtual status_t unregisterEffect(int id); |
Eric Laurent | 6752ec8 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 107 | virtual status_t setEffectEnabled(int id, bool enabled); |
Glenn Kasten | bc1d77b | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 108 | virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const; |
Eric Laurent | 8ed6ed0 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 109 | |
Eric Laurent | 0f7f4ec | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 110 | virtual status_t queryDefaultPreProcessing(int audioSession, |
| 111 | effect_descriptor_t *descriptors, |
| 112 | uint32_t *count); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 113 | virtual status_t onTransact( |
| 114 | uint32_t code, |
| 115 | const Parcel& data, |
| 116 | Parcel* reply, |
| 117 | uint32_t flags); |
| 118 | |
| 119 | // IBinder::DeathRecipient |
| 120 | virtual void binderDied(const wp<IBinder>& who); |
| 121 | |
| 122 | // |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 123 | // Helpers for the struct audio_policy_service_ops implementation. |
| 124 | // This is used by the audio policy manager for certain operations that |
| 125 | // are implemented by the policy service. |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 126 | // |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 127 | virtual void setParameters(audio_io_handle_t ioHandle, |
| 128 | const char *keyValuePairs, |
| 129 | int delayMs); |
| 130 | |
| 131 | virtual status_t setStreamVolume(audio_stream_type_t stream, |
Eric Laurent | 8ed6ed0 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 132 | float volume, |
| 133 | audio_io_handle_t output, |
| 134 | int delayMs = 0); |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 135 | virtual status_t startTone(audio_policy_tone_t tone, audio_stream_type_t stream); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 136 | virtual status_t stopTone(); |
Eric Laurent | 415f3e2 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 137 | virtual status_t setVoiceVolume(float volume, int delayMs = 0); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 138 | |
| 139 | private: |
| 140 | AudioPolicyService(); |
| 141 | virtual ~AudioPolicyService(); |
| 142 | |
Eric Laurent | f4ee40e | 2009-11-02 10:29:02 -0800 | [diff] [blame] | 143 | status_t dumpInternals(int fd); |
| 144 | |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 145 | // Thread used for tone playback and to send audio config commands to audio flinger |
| 146 | // For tone playback, using a separate thread is necessary to avoid deadlock with mLock because startTone() |
| 147 | // and stopTone() are normally called with mLock locked and requesting a tone start or stop will cause |
| 148 | // calls to AudioPolicyService and an attempt to lock mLock. |
| 149 | // For audio config commands, it is necessary because audio flinger requires that the calling process (user) |
| 150 | // has permission to modify audio settings. |
| 151 | class AudioCommandThread : public Thread { |
Eric Laurent | 327c27b | 2009-08-27 00:48:47 -0700 | [diff] [blame] | 152 | class AudioCommand; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 153 | public: |
| 154 | |
| 155 | // commands for tone AudioCommand |
| 156 | enum { |
| 157 | START_TONE, |
| 158 | STOP_TONE, |
| 159 | SET_VOLUME, |
Eric Laurent | 415f3e2 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 160 | SET_PARAMETERS, |
| 161 | SET_VOICE_VOLUME |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 162 | }; |
| 163 | |
Eric Laurent | cef3cd7 | 2009-12-10 01:03:50 -0800 | [diff] [blame] | 164 | AudioCommandThread (String8 name); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 165 | virtual ~AudioCommandThread(); |
| 166 | |
Eric Laurent | f4ee40e | 2009-11-02 10:29:02 -0800 | [diff] [blame] | 167 | status_t dump(int fd); |
| 168 | |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 169 | // Thread virtuals |
| 170 | virtual void onFirstRef(); |
| 171 | virtual bool threadLoop(); |
| 172 | |
| 173 | void exit(); |
Glenn Kasten | 23f7ad3 | 2012-01-27 15:25:25 -0800 | [diff] [blame] | 174 | void startToneCommand(ToneGenerator::tone_type type, |
| 175 | audio_stream_type_t stream); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 176 | void stopToneCommand(); |
Glenn Kasten | 39d00cb | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 177 | status_t volumeCommand(audio_stream_type_t stream, float volume, |
| 178 | audio_io_handle_t output, int delayMs = 0); |
| 179 | status_t parametersCommand(audio_io_handle_t ioHandle, |
| 180 | const char *keyValuePairs, int delayMs = 0); |
Eric Laurent | 415f3e2 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 181 | status_t voiceVolumeCommand(float volume, int delayMs = 0); |
Eric Laurent | 327c27b | 2009-08-27 00:48:47 -0700 | [diff] [blame] | 182 | void insertCommand_l(AudioCommand *command, int delayMs = 0); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 183 | |
| 184 | private: |
| 185 | // descriptor for requested tone playback event |
| 186 | class AudioCommand { |
Eric Laurent | 3fdb126 | 2009-11-07 00:01:32 -0800 | [diff] [blame] | 187 | |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 188 | public: |
Eric Laurent | 3fdb126 | 2009-11-07 00:01:32 -0800 | [diff] [blame] | 189 | AudioCommand() |
| 190 | : mCommand(-1) {} |
| 191 | |
Eric Laurent | f4ee40e | 2009-11-02 10:29:02 -0800 | [diff] [blame] | 192 | void dump(char* buffer, size_t size); |
| 193 | |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 194 | int mCommand; // START_TONE, STOP_TONE ... |
Eric Laurent | 327c27b | 2009-08-27 00:48:47 -0700 | [diff] [blame] | 195 | nsecs_t mTime; // time stamp |
| 196 | Condition mCond; // condition for status return |
| 197 | status_t mStatus; // command status |
| 198 | bool mWaitStatus; // true if caller is waiting for status |
| 199 | void *mParam; // command parameter (ToneData, VolumeData, ParametersData) |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 200 | }; |
| 201 | |
| 202 | class ToneData { |
| 203 | public: |
Glenn Kasten | 23f7ad3 | 2012-01-27 15:25:25 -0800 | [diff] [blame] | 204 | ToneGenerator::tone_type mType; // tone type (START_TONE only) |
Glenn Kasten | bc1d77b | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 205 | audio_stream_type_t mStream; // stream type (START_TONE only) |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 206 | }; |
| 207 | |
| 208 | class VolumeData { |
| 209 | public: |
Glenn Kasten | bc1d77b | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 210 | audio_stream_type_t mStream; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 211 | float mVolume; |
Glenn Kasten | 39d00cb | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 212 | audio_io_handle_t mIO; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 213 | }; |
Eric Laurent | 415f3e2 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 214 | |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 215 | class ParametersData { |
| 216 | public: |
Glenn Kasten | 39d00cb | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 217 | audio_io_handle_t mIO; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 218 | String8 mKeyValuePairs; |
| 219 | }; |
| 220 | |
Eric Laurent | 415f3e2 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 221 | class VoiceVolumeData { |
| 222 | public: |
| 223 | float mVolume; |
| 224 | }; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 225 | |
| 226 | Mutex mLock; |
| 227 | Condition mWaitWorkCV; |
Eric Laurent | 327c27b | 2009-08-27 00:48:47 -0700 | [diff] [blame] | 228 | Vector <AudioCommand *> mAudioCommands; // list of pending commands |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 229 | ToneGenerator *mpToneGenerator; // the tone generator |
Eric Laurent | cef3cd7 | 2009-12-10 01:03:50 -0800 | [diff] [blame] | 230 | AudioCommand mLastCommand; // last processed command (used by dump) |
| 231 | String8 mName; // string used by wake lock fo delayed commands |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 232 | }; |
| 233 | |
Eric Laurent | 464d5b3 | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 234 | class EffectDesc { |
| 235 | public: |
Glenn Kasten | afe9833 | 2012-02-02 14:04:37 -0800 | [diff] [blame] | 236 | EffectDesc(const char *name, const effect_uuid_t& uuid) : |
| 237 | mName(strdup(name)), |
| 238 | mUuid(uuid) { } |
| 239 | EffectDesc(const EffectDesc& orig) : |
| 240 | mName(strdup(orig.mName)), |
| 241 | mUuid(orig.mUuid) { |
| 242 | // deep copy mParams |
| 243 | for (size_t k = 0; k < orig.mParams.size(); k++) { |
| 244 | effect_param_t *origParam = orig.mParams[k]; |
| 245 | // psize and vsize are rounded up to an int boundary for allocation |
| 246 | size_t origSize = sizeof(effect_param_t) + |
| 247 | ((origParam->psize + 3) & ~3) + |
| 248 | ((origParam->vsize + 3) & ~3); |
| 249 | effect_param_t *dupParam = (effect_param_t *) malloc(origSize); |
| 250 | memcpy(dupParam, origParam, origSize); |
| 251 | // This works because the param buffer allocation is also done by |
| 252 | // multiples of 4 bytes originally. In theory we should memcpy only |
| 253 | // the actual param size, that is without rounding vsize. |
| 254 | mParams.add(dupParam); |
| 255 | } |
| 256 | } |
| 257 | /*virtual*/ ~EffectDesc() { |
| 258 | free(mName); |
| 259 | for (size_t k = 0; k < mParams.size(); k++) { |
| 260 | free(mParams[k]); |
| 261 | } |
| 262 | } |
Eric Laurent | 464d5b3 | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 263 | char *mName; |
| 264 | effect_uuid_t mUuid; |
| 265 | Vector <effect_param_t *> mParams; |
| 266 | }; |
| 267 | |
| 268 | class InputSourceDesc { |
| 269 | public: |
| 270 | InputSourceDesc() {} |
Glenn Kasten | afe9833 | 2012-02-02 14:04:37 -0800 | [diff] [blame] | 271 | /*virtual*/ ~InputSourceDesc() { |
| 272 | for (size_t j = 0; j < mEffects.size(); j++) { |
| 273 | delete mEffects[j]; |
| 274 | } |
| 275 | } |
Eric Laurent | 464d5b3 | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 276 | Vector <EffectDesc *> mEffects; |
| 277 | }; |
| 278 | |
| 279 | |
| 280 | class InputDesc { |
| 281 | public: |
Glenn Kasten | fcf2ac0 | 2012-03-07 16:49:22 -0800 | [diff] [blame] | 282 | InputDesc(int session) : mSessionId(session) {} |
| 283 | /*virtual*/ ~InputDesc() {} |
| 284 | const int mSessionId; |
Eric Laurent | 464d5b3 | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 285 | Vector< sp<AudioEffect> >mEffects; |
| 286 | }; |
| 287 | |
Glenn Kasten | 05d3310 | 2012-01-09 08:41:22 -0800 | [diff] [blame] | 288 | static const char * const kInputSourceNames[AUDIO_SOURCE_CNT -1]; |
Eric Laurent | 464d5b3 | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 289 | |
Glenn Kasten | fcf2ac0 | 2012-03-07 16:49:22 -0800 | [diff] [blame] | 290 | void setPreProcessorEnabled(const InputDesc *inputDesc, bool enabled); |
Eric Laurent | 464d5b3 | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 291 | status_t loadPreProcessorConfig(const char *path); |
| 292 | status_t loadEffects(cnode *root, Vector <EffectDesc *>& effects); |
| 293 | EffectDesc *loadEffect(cnode *root); |
| 294 | status_t loadInputSources(cnode *root, const Vector <EffectDesc *>& effects); |
| 295 | audio_source_t inputSourceNameToEnum(const char *name); |
| 296 | InputSourceDesc *loadInputSource(cnode *root, const Vector <EffectDesc *>& effects); |
| 297 | void loadEffectParameters(cnode *root, Vector <effect_param_t *>& params); |
| 298 | effect_param_t *loadEffectParameter(cnode *root); |
| 299 | size_t readParamValue(cnode *node, |
| 300 | char *param, |
| 301 | size_t *curSize, |
| 302 | size_t *totSize); |
| 303 | size_t growParamSize(char *param, |
| 304 | size_t size, |
| 305 | size_t *curSize, |
| 306 | size_t *totSize); |
| 307 | |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 308 | // Internal dump utilities. |
Eric Laurent | f4ee40e | 2009-11-02 10:29:02 -0800 | [diff] [blame] | 309 | status_t dumpPermissionDenial(int fd); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 310 | |
| 311 | |
Eric Laurent | 25101b0 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 312 | mutable Mutex mLock; // prevents concurrent access to AudioPolicy manager functions changing |
| 313 | // device connection state or routing |
Glenn Kasten | 18db49a | 2012-03-12 16:29:55 -0700 | [diff] [blame^] | 314 | sp<AudioCommandThread> mAudioCommandThread; // audio commands thread |
| 315 | sp<AudioCommandThread> mTonePlaybackThread; // tone playback thread |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 316 | struct audio_policy_device *mpAudioPolicyDev; |
| 317 | struct audio_policy *mpAudioPolicy; |
Eric Laurent | 464d5b3 | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 318 | KeyedVector< audio_source_t, InputSourceDesc* > mInputSources; |
| 319 | KeyedVector< audio_io_handle_t, InputDesc* > mInputs; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 320 | }; |
| 321 | |
| 322 | }; // namespace android |
| 323 | |
| 324 | #endif // ANDROID_AUDIOPOLICYSERVICE_H |