Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -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 | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 20 | #include <cutils/misc.h> |
| 21 | #include <cutils/config_utils.h> |
Mathias Agopian | e762be9 | 2013-05-09 16:26:45 -0700 | [diff] [blame] | 22 | #include <cutils/compiler.h> |
Glenn Kasten | d1d8f23 | 2011-07-08 09:34:50 -0700 | [diff] [blame] | 23 | #include <utils/String8.h> |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 24 | #include <utils/Vector.h> |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 25 | #include <utils/SortedVector.h> |
Glenn Kasten | d2dcb08 | 2011-02-03 16:55:26 -0800 | [diff] [blame] | 26 | #include <binder/BinderService.h> |
Dima Zavin | 6476024 | 2011-05-11 14:15:23 -0700 | [diff] [blame] | 27 | #include <system/audio.h> |
Dima Zavin | 7394a4f | 2011-06-13 18:16:26 -0700 | [diff] [blame] | 28 | #include <system/audio_policy.h> |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 29 | #include <hardware/audio_policy.h> |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 30 | #include <media/IAudioPolicyService.h> |
| 31 | #include <media/ToneGenerator.h> |
| 32 | #include <media/AudioEffect.h> |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 33 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 34 | namespace android { |
| 35 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 36 | // ---------------------------------------------------------------------------- |
| 37 | |
Glenn Kasten | d2dcb08 | 2011-02-03 16:55:26 -0800 | [diff] [blame] | 38 | class AudioPolicyService : |
| 39 | public BinderService<AudioPolicyService>, |
| 40 | public BnAudioPolicyService, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 41 | // public AudioPolicyClientInterface, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 42 | public IBinder::DeathRecipient |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 43 | { |
Glenn Kasten | d2dcb08 | 2011-02-03 16:55:26 -0800 | [diff] [blame] | 44 | friend class BinderService<AudioPolicyService>; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 45 | |
| 46 | public: |
Glenn Kasten | d2dcb08 | 2011-02-03 16:55:26 -0800 | [diff] [blame] | 47 | // for BinderService |
Mathias Agopian | e762be9 | 2013-05-09 16:26:45 -0700 | [diff] [blame] | 48 | static const char *getServiceName() ANDROID_API { return "media.audio_policy"; } |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 49 | |
| 50 | virtual status_t dump(int fd, const Vector<String16>& args); |
| 51 | |
| 52 | // |
| 53 | // BnAudioPolicyService (see AudioPolicyInterface for method descriptions) |
| 54 | // |
| 55 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 56 | virtual status_t setDeviceConnectionState(audio_devices_t device, |
| 57 | audio_policy_dev_state_t state, |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 58 | const char *device_address); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 59 | virtual audio_policy_dev_state_t getDeviceConnectionState( |
| 60 | audio_devices_t device, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 61 | const char *device_address); |
Glenn Kasten | f78aee7 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 62 | virtual status_t setPhoneState(audio_mode_t state); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 63 | virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config); |
| 64 | virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage); |
| 65 | virtual audio_io_handle_t getOutput(audio_stream_type_t stream, |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 66 | uint32_t samplingRate = 0, |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 67 | audio_format_t format = AUDIO_FORMAT_DEFAULT, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 68 | audio_channel_mask_t channelMask = 0, |
Eric Laurent | 0ca3cf9 | 2012-04-18 09:24:29 -0700 | [diff] [blame] | 69 | audio_output_flags_t flags = |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 70 | AUDIO_OUTPUT_FLAG_NONE, |
| 71 | const audio_offload_info_t *offloadInfo = NULL); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 72 | virtual status_t startOutput(audio_io_handle_t output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 73 | audio_stream_type_t stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 74 | int session = 0); |
| 75 | virtual status_t stopOutput(audio_io_handle_t output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 76 | audio_stream_type_t stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 77 | int session = 0); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 78 | virtual void releaseOutput(audio_io_handle_t output); |
Glenn Kasten | eba51fb | 2012-01-23 13:58:49 -0800 | [diff] [blame] | 79 | virtual audio_io_handle_t getInput(audio_source_t inputSource, |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 80 | uint32_t samplingRate = 0, |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 81 | audio_format_t format = AUDIO_FORMAT_DEFAULT, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 82 | audio_channel_mask_t channelMask = 0, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 83 | int audioSession = 0); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -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 | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 87 | virtual status_t initStreamVolume(audio_stream_type_t stream, |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 88 | int indexMin, |
| 89 | int indexMax); |
Eric Laurent | 83844cc | 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); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 96 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 97 | virtual uint32_t getStrategyForStream(audio_stream_type_t stream); |
Eric Laurent | 6374252 | 2012-03-08 13:42:42 -0800 | [diff] [blame] | 98 | virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 99 | |
Glenn Kasten | 58e5aa3 | 2012-06-20 14:08:14 -0700 | [diff] [blame] | 100 | virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc); |
| 101 | virtual status_t registerEffect(const effect_descriptor_t *desc, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 102 | audio_io_handle_t io, |
Eric Laurent | de07013 | 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 | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 107 | virtual status_t setEffectEnabled(int id, bool enabled); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 108 | virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const; |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 109 | virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs = 0) const; |
Jean-Michel Trivi | d708603 | 2012-10-10 12:11:16 -0700 | [diff] [blame] | 110 | virtual bool isSourceActive(audio_source_t source) const; |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 111 | |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 112 | virtual status_t queryDefaultPreProcessing(int audioSession, |
| 113 | effect_descriptor_t *descriptors, |
| 114 | uint32_t *count); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 115 | virtual status_t onTransact( |
| 116 | uint32_t code, |
| 117 | const Parcel& data, |
| 118 | Parcel* reply, |
| 119 | uint32_t flags); |
| 120 | |
| 121 | // IBinder::DeathRecipient |
| 122 | virtual void binderDied(const wp<IBinder>& who); |
| 123 | |
| 124 | // |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 125 | // Helpers for the struct audio_policy_service_ops implementation. |
| 126 | // This is used by the audio policy manager for certain operations that |
| 127 | // are implemented by the policy service. |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 128 | // |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 129 | virtual void setParameters(audio_io_handle_t ioHandle, |
| 130 | const char *keyValuePairs, |
| 131 | int delayMs); |
| 132 | |
| 133 | virtual status_t setStreamVolume(audio_stream_type_t stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 134 | float volume, |
| 135 | audio_io_handle_t output, |
| 136 | int delayMs = 0); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 137 | virtual status_t startTone(audio_policy_tone_t tone, audio_stream_type_t stream); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 138 | virtual status_t stopTone(); |
| 139 | virtual status_t setVoiceVolume(float volume, int delayMs = 0); |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 140 | virtual bool isOffloadSupported(const audio_offload_info_t &config); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 141 | |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame^] | 142 | status_t doStopOutput(audio_io_handle_t output, |
| 143 | audio_stream_type_t stream, |
| 144 | int session = 0); |
| 145 | void doReleaseOutput(audio_io_handle_t output); |
| 146 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 147 | private: |
Mathias Agopian | e762be9 | 2013-05-09 16:26:45 -0700 | [diff] [blame] | 148 | AudioPolicyService() ANDROID_API; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 149 | virtual ~AudioPolicyService(); |
| 150 | |
| 151 | status_t dumpInternals(int fd); |
| 152 | |
| 153 | // Thread used for tone playback and to send audio config commands to audio flinger |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 154 | // For tone playback, using a separate thread is necessary to avoid deadlock with mLock because |
| 155 | // startTone() and stopTone() are normally called with mLock locked and requesting a tone start |
| 156 | // or stop will cause calls to AudioPolicyService and an attempt to lock mLock. |
| 157 | // For audio config commands, it is necessary because audio flinger requires that the calling |
| 158 | // process (user) has permission to modify audio settings. |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 159 | class AudioCommandThread : public Thread { |
| 160 | class AudioCommand; |
| 161 | public: |
| 162 | |
| 163 | // commands for tone AudioCommand |
| 164 | enum { |
| 165 | START_TONE, |
| 166 | STOP_TONE, |
| 167 | SET_VOLUME, |
| 168 | SET_PARAMETERS, |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame^] | 169 | SET_VOICE_VOLUME, |
| 170 | STOP_OUTPUT, |
| 171 | RELEASE_OUTPUT |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 172 | }; |
| 173 | |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame^] | 174 | AudioCommandThread (String8 name, const wp<AudioPolicyService>& service); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 175 | virtual ~AudioCommandThread(); |
| 176 | |
| 177 | status_t dump(int fd); |
| 178 | |
| 179 | // Thread virtuals |
| 180 | virtual void onFirstRef(); |
| 181 | virtual bool threadLoop(); |
| 182 | |
| 183 | void exit(); |
Glenn Kasten | 3d2f877 | 2012-01-27 15:25:25 -0800 | [diff] [blame] | 184 | void startToneCommand(ToneGenerator::tone_type type, |
| 185 | audio_stream_type_t stream); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 186 | void stopToneCommand(); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 187 | status_t volumeCommand(audio_stream_type_t stream, float volume, |
| 188 | audio_io_handle_t output, int delayMs = 0); |
| 189 | status_t parametersCommand(audio_io_handle_t ioHandle, |
| 190 | const char *keyValuePairs, int delayMs = 0); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 191 | status_t voiceVolumeCommand(float volume, int delayMs = 0); |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame^] | 192 | void stopOutputCommand(audio_io_handle_t output, |
| 193 | audio_stream_type_t stream, |
| 194 | int session); |
| 195 | void releaseOutputCommand(audio_io_handle_t output); |
| 196 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 197 | void insertCommand_l(AudioCommand *command, int delayMs = 0); |
| 198 | |
| 199 | private: |
| 200 | // descriptor for requested tone playback event |
| 201 | class AudioCommand { |
| 202 | |
| 203 | public: |
| 204 | AudioCommand() |
| 205 | : mCommand(-1) {} |
| 206 | |
| 207 | void dump(char* buffer, size_t size); |
| 208 | |
| 209 | int mCommand; // START_TONE, STOP_TONE ... |
| 210 | nsecs_t mTime; // time stamp |
| 211 | Condition mCond; // condition for status return |
| 212 | status_t mStatus; // command status |
| 213 | bool mWaitStatus; // true if caller is waiting for status |
| 214 | void *mParam; // command parameter (ToneData, VolumeData, ParametersData) |
| 215 | }; |
| 216 | |
| 217 | class ToneData { |
| 218 | public: |
Glenn Kasten | 3d2f877 | 2012-01-27 15:25:25 -0800 | [diff] [blame] | 219 | ToneGenerator::tone_type mType; // tone type (START_TONE only) |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 220 | audio_stream_type_t mStream; // stream type (START_TONE only) |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 221 | }; |
| 222 | |
| 223 | class VolumeData { |
| 224 | public: |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 225 | audio_stream_type_t mStream; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 226 | float mVolume; |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 227 | audio_io_handle_t mIO; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 228 | }; |
| 229 | |
| 230 | class ParametersData { |
| 231 | public: |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 232 | audio_io_handle_t mIO; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 233 | String8 mKeyValuePairs; |
| 234 | }; |
| 235 | |
| 236 | class VoiceVolumeData { |
| 237 | public: |
| 238 | float mVolume; |
| 239 | }; |
| 240 | |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame^] | 241 | class StopOutputData { |
| 242 | public: |
| 243 | audio_io_handle_t mIO; |
| 244 | audio_stream_type_t mStream; |
| 245 | int mSession; |
| 246 | }; |
| 247 | |
| 248 | class ReleaseOutputData { |
| 249 | public: |
| 250 | audio_io_handle_t mIO; |
| 251 | }; |
| 252 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 253 | Mutex mLock; |
| 254 | Condition mWaitWorkCV; |
| 255 | Vector <AudioCommand *> mAudioCommands; // list of pending commands |
| 256 | ToneGenerator *mpToneGenerator; // the tone generator |
| 257 | AudioCommand mLastCommand; // last processed command (used by dump) |
| 258 | String8 mName; // string used by wake lock fo delayed commands |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame^] | 259 | wp<AudioPolicyService> mService; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 260 | }; |
| 261 | |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 262 | class EffectDesc { |
| 263 | public: |
Glenn Kasten | 9fda4b8 | 2012-02-02 14:04:37 -0800 | [diff] [blame] | 264 | EffectDesc(const char *name, const effect_uuid_t& uuid) : |
| 265 | mName(strdup(name)), |
| 266 | mUuid(uuid) { } |
| 267 | EffectDesc(const EffectDesc& orig) : |
| 268 | mName(strdup(orig.mName)), |
| 269 | mUuid(orig.mUuid) { |
| 270 | // deep copy mParams |
| 271 | for (size_t k = 0; k < orig.mParams.size(); k++) { |
| 272 | effect_param_t *origParam = orig.mParams[k]; |
| 273 | // psize and vsize are rounded up to an int boundary for allocation |
| 274 | size_t origSize = sizeof(effect_param_t) + |
| 275 | ((origParam->psize + 3) & ~3) + |
| 276 | ((origParam->vsize + 3) & ~3); |
| 277 | effect_param_t *dupParam = (effect_param_t *) malloc(origSize); |
| 278 | memcpy(dupParam, origParam, origSize); |
| 279 | // This works because the param buffer allocation is also done by |
| 280 | // multiples of 4 bytes originally. In theory we should memcpy only |
| 281 | // the actual param size, that is without rounding vsize. |
| 282 | mParams.add(dupParam); |
| 283 | } |
| 284 | } |
| 285 | /*virtual*/ ~EffectDesc() { |
| 286 | free(mName); |
| 287 | for (size_t k = 0; k < mParams.size(); k++) { |
| 288 | free(mParams[k]); |
| 289 | } |
| 290 | } |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 291 | char *mName; |
| 292 | effect_uuid_t mUuid; |
| 293 | Vector <effect_param_t *> mParams; |
| 294 | }; |
| 295 | |
| 296 | class InputSourceDesc { |
| 297 | public: |
| 298 | InputSourceDesc() {} |
Glenn Kasten | 9fda4b8 | 2012-02-02 14:04:37 -0800 | [diff] [blame] | 299 | /*virtual*/ ~InputSourceDesc() { |
| 300 | for (size_t j = 0; j < mEffects.size(); j++) { |
| 301 | delete mEffects[j]; |
| 302 | } |
| 303 | } |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 304 | Vector <EffectDesc *> mEffects; |
| 305 | }; |
| 306 | |
| 307 | |
| 308 | class InputDesc { |
| 309 | public: |
Glenn Kasten | 81872a2 | 2012-03-07 16:49:22 -0800 | [diff] [blame] | 310 | InputDesc(int session) : mSessionId(session) {} |
| 311 | /*virtual*/ ~InputDesc() {} |
| 312 | const int mSessionId; |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 313 | Vector< sp<AudioEffect> >mEffects; |
| 314 | }; |
| 315 | |
Glenn Kasten | 8dad0e3 | 2012-01-09 08:41:22 -0800 | [diff] [blame] | 316 | static const char * const kInputSourceNames[AUDIO_SOURCE_CNT -1]; |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 317 | |
Glenn Kasten | 81872a2 | 2012-03-07 16:49:22 -0800 | [diff] [blame] | 318 | void setPreProcessorEnabled(const InputDesc *inputDesc, bool enabled); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 319 | status_t loadPreProcessorConfig(const char *path); |
| 320 | status_t loadEffects(cnode *root, Vector <EffectDesc *>& effects); |
| 321 | EffectDesc *loadEffect(cnode *root); |
| 322 | status_t loadInputSources(cnode *root, const Vector <EffectDesc *>& effects); |
| 323 | audio_source_t inputSourceNameToEnum(const char *name); |
| 324 | InputSourceDesc *loadInputSource(cnode *root, const Vector <EffectDesc *>& effects); |
| 325 | void loadEffectParameters(cnode *root, Vector <effect_param_t *>& params); |
| 326 | effect_param_t *loadEffectParameter(cnode *root); |
| 327 | size_t readParamValue(cnode *node, |
| 328 | char *param, |
| 329 | size_t *curSize, |
| 330 | size_t *totSize); |
| 331 | size_t growParamSize(char *param, |
| 332 | size_t size, |
| 333 | size_t *curSize, |
| 334 | size_t *totSize); |
| 335 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 336 | // Internal dump utilities. |
| 337 | status_t dumpPermissionDenial(int fd); |
| 338 | |
| 339 | |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 340 | mutable Mutex mLock; // prevents concurrent access to AudioPolicy manager functions changing |
| 341 | // device connection state or routing |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 342 | sp<AudioCommandThread> mAudioCommandThread; // audio commands thread |
| 343 | sp<AudioCommandThread> mTonePlaybackThread; // tone playback thread |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame^] | 344 | sp<AudioCommandThread> mOutputCommandThread; // process stop and release output |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 345 | struct audio_policy_device *mpAudioPolicyDev; |
| 346 | struct audio_policy *mpAudioPolicy; |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 347 | KeyedVector< audio_source_t, InputSourceDesc* > mInputSources; |
| 348 | KeyedVector< audio_io_handle_t, InputDesc* > mInputs; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 349 | }; |
| 350 | |
| 351 | }; // namespace android |
| 352 | |
| 353 | #endif // ANDROID_AUDIOPOLICYSERVICE_H |