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> |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 29 | #include <media/IAudioPolicyService.h> |
| 30 | #include <media/ToneGenerator.h> |
| 31 | #include <media/AudioEffect.h> |
Eric Laurent | baac183 | 2014-12-01 17:52:59 -0800 | [diff] [blame] | 32 | #include <media/AudioPolicy.h> |
bryant_liu | ba2b439 | 2014-06-11 16:49:30 +0800 | [diff] [blame] | 33 | #include "AudioPolicyEffects.h" |
Jean-Michel Trivi | 56ec4ff | 2015-01-23 16:45:18 -0800 | [diff] [blame] | 34 | #include "managerdefault/AudioPolicyManager.h" |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 35 | |
bryant_liu | ba2b439 | 2014-06-11 16:49:30 +0800 | [diff] [blame] | 36 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 37 | namespace android { |
| 38 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 39 | // ---------------------------------------------------------------------------- |
| 40 | |
Glenn Kasten | d2dcb08 | 2011-02-03 16:55:26 -0800 | [diff] [blame] | 41 | class AudioPolicyService : |
| 42 | public BinderService<AudioPolicyService>, |
| 43 | public BnAudioPolicyService, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 44 | public IBinder::DeathRecipient |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 45 | { |
Glenn Kasten | d2dcb08 | 2011-02-03 16:55:26 -0800 | [diff] [blame] | 46 | friend class BinderService<AudioPolicyService>; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 47 | |
| 48 | public: |
Glenn Kasten | d2dcb08 | 2011-02-03 16:55:26 -0800 | [diff] [blame] | 49 | // for BinderService |
Mathias Agopian | e762be9 | 2013-05-09 16:26:45 -0700 | [diff] [blame] | 50 | static const char *getServiceName() ANDROID_API { return "media.audio_policy"; } |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 51 | |
| 52 | virtual status_t dump(int fd, const Vector<String16>& args); |
| 53 | |
| 54 | // |
| 55 | // BnAudioPolicyService (see AudioPolicyInterface for method descriptions) |
| 56 | // |
| 57 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 58 | virtual status_t setDeviceConnectionState(audio_devices_t device, |
| 59 | audio_policy_dev_state_t state, |
Paul McLean | e743a47 | 2015-01-28 11:07:31 -0800 | [diff] [blame] | 60 | const char *device_address, |
| 61 | const char *device_name); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 62 | virtual audio_policy_dev_state_t getDeviceConnectionState( |
| 63 | audio_devices_t device, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 64 | const char *device_address); |
Pavlin Radoslavov | f862bc6 | 2016-12-26 18:57:22 -0800 | [diff] [blame] | 65 | virtual status_t handleDeviceConfigChange(audio_devices_t device, |
| 66 | const char *device_address, |
| 67 | const char *device_name); |
Glenn Kasten | f78aee7 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 68 | virtual status_t setPhoneState(audio_mode_t state); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 69 | virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config); |
| 70 | virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage); |
Eric Laurent | f4e6345 | 2017-11-06 19:31:46 +0000 | [diff] [blame] | 71 | virtual audio_io_handle_t getOutput(audio_stream_type_t stream); |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 72 | virtual status_t getOutputForAttr(const audio_attributes_t *attr, |
| 73 | audio_io_handle_t *output, |
| 74 | audio_session_t session, |
| 75 | audio_stream_type_t *stream, |
Eric Laurent | 8c7e6da | 2015-04-21 17:37:00 -0700 | [diff] [blame] | 76 | uid_t uid, |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 77 | const audio_config_t *config, |
| 78 | audio_output_flags_t flags, |
Eric Laurent | 9ae8c59 | 2017-06-22 17:17:09 -0700 | [diff] [blame] | 79 | audio_port_handle_t *selectedDeviceId, |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 80 | audio_port_handle_t *portId); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 81 | virtual status_t startOutput(audio_io_handle_t output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 82 | audio_stream_type_t stream, |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 83 | audio_session_t session); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 84 | virtual status_t stopOutput(audio_io_handle_t output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 85 | audio_stream_type_t stream, |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 86 | audio_session_t session); |
| 87 | virtual void releaseOutput(audio_io_handle_t output, |
| 88 | audio_stream_type_t stream, |
| 89 | audio_session_t session); |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 90 | virtual status_t getInputForAttr(const audio_attributes_t *attr, |
| 91 | audio_io_handle_t *input, |
| 92 | audio_session_t session, |
Eric Laurent | b2379ba | 2016-05-23 17:42:12 -0700 | [diff] [blame] | 93 | pid_t pid, |
Eric Laurent | 8c7e6da | 2015-04-21 17:37:00 -0700 | [diff] [blame] | 94 | uid_t uid, |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 95 | const audio_config_base_t *config, |
Paul McLean | 466dc8e | 2015-04-17 13:15:36 -0600 | [diff] [blame] | 96 | audio_input_flags_t flags, |
Eric Laurent | 9ae8c59 | 2017-06-22 17:17:09 -0700 | [diff] [blame] | 97 | audio_port_handle_t *selectedDeviceId = NULL, |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 98 | audio_port_handle_t *portId = NULL); |
Eric Laurent | 4dc6806 | 2014-07-28 17:26:49 -0700 | [diff] [blame] | 99 | virtual status_t startInput(audio_io_handle_t input, |
| 100 | audio_session_t session); |
| 101 | virtual status_t stopInput(audio_io_handle_t input, |
| 102 | audio_session_t session); |
| 103 | virtual void releaseInput(audio_io_handle_t input, |
| 104 | audio_session_t session); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 105 | virtual status_t initStreamVolume(audio_stream_type_t stream, |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 106 | int indexMin, |
| 107 | int indexMax); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 108 | virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, |
| 109 | int index, |
| 110 | audio_devices_t device); |
| 111 | virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, |
| 112 | int *index, |
| 113 | audio_devices_t device); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 114 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 115 | virtual uint32_t getStrategyForStream(audio_stream_type_t stream); |
Eric Laurent | 6374252 | 2012-03-08 13:42:42 -0800 | [diff] [blame] | 116 | virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 117 | |
Glenn Kasten | 58e5aa3 | 2012-06-20 14:08:14 -0700 | [diff] [blame] | 118 | virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc); |
| 119 | virtual status_t registerEffect(const effect_descriptor_t *desc, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 120 | audio_io_handle_t io, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 121 | uint32_t strategy, |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 122 | audio_session_t session, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 123 | int id); |
| 124 | virtual status_t unregisterEffect(int id); |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 125 | virtual status_t setEffectEnabled(int id, bool enabled); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 126 | 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] | 127 | 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] | 128 | virtual bool isSourceActive(audio_source_t source) const; |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 129 | |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 130 | virtual status_t queryDefaultPreProcessing(audio_session_t audioSession, |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 131 | effect_descriptor_t *descriptors, |
| 132 | uint32_t *count); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 133 | virtual status_t onTransact( |
| 134 | uint32_t code, |
| 135 | const Parcel& data, |
| 136 | Parcel* reply, |
| 137 | uint32_t flags); |
| 138 | |
| 139 | // IBinder::DeathRecipient |
| 140 | virtual void binderDied(const wp<IBinder>& who); |
| 141 | |
Eric Laurent | f5ada6e | 2014-10-09 17:49:00 -0700 | [diff] [blame] | 142 | // RefBase |
| 143 | virtual void onFirstRef(); |
| 144 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 145 | // |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 146 | // Helpers for the struct audio_policy_service_ops implementation. |
| 147 | // This is used by the audio policy manager for certain operations that |
| 148 | // are implemented by the policy service. |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 149 | // |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 150 | virtual void setParameters(audio_io_handle_t ioHandle, |
| 151 | const char *keyValuePairs, |
| 152 | int delayMs); |
| 153 | |
| 154 | virtual status_t setStreamVolume(audio_stream_type_t stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 155 | float volume, |
| 156 | audio_io_handle_t output, |
| 157 | int delayMs = 0); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 158 | 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] | 159 | virtual status_t stopTone(); |
| 160 | virtual status_t setVoiceVolume(float volume, int delayMs = 0); |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 161 | virtual bool isOffloadSupported(const audio_offload_info_t &config); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 162 | |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 163 | virtual status_t listAudioPorts(audio_port_role_t role, |
| 164 | audio_port_type_t type, |
| 165 | unsigned int *num_ports, |
| 166 | struct audio_port *ports, |
| 167 | unsigned int *generation); |
| 168 | virtual status_t getAudioPort(struct audio_port *port); |
| 169 | virtual status_t createAudioPatch(const struct audio_patch *patch, |
| 170 | audio_patch_handle_t *handle); |
| 171 | virtual status_t releaseAudioPatch(audio_patch_handle_t handle); |
| 172 | virtual status_t listAudioPatches(unsigned int *num_patches, |
| 173 | struct audio_patch *patches, |
| 174 | unsigned int *generation); |
| 175 | virtual status_t setAudioPortConfig(const struct audio_port_config *config); |
| 176 | |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 177 | virtual void registerClient(const sp<IAudioPolicyServiceClient>& client); |
| 178 | |
Eric Laurent | e8726fe | 2015-06-26 09:39:24 -0700 | [diff] [blame] | 179 | virtual void setAudioPortCallbacksEnabled(bool enabled); |
| 180 | |
Eric Laurent | df3dc7e | 2014-07-27 18:39:40 -0700 | [diff] [blame] | 181 | virtual status_t acquireSoundTriggerSession(audio_session_t *session, |
| 182 | audio_io_handle_t *ioHandle, |
| 183 | audio_devices_t *device); |
| 184 | |
| 185 | virtual status_t releaseSoundTriggerSession(audio_session_t session); |
| 186 | |
Eric Laurent | bb6c9a0 | 2014-09-25 14:11:47 -0700 | [diff] [blame] | 187 | virtual audio_mode_t getPhoneState(); |
| 188 | |
Chih-Hung Hsieh | e964d4e | 2016-08-09 14:31:32 -0700 | [diff] [blame] | 189 | virtual status_t registerPolicyMixes(const Vector<AudioMix>& mixes, bool registration); |
Eric Laurent | baac183 | 2014-12-01 17:52:59 -0800 | [diff] [blame] | 190 | |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 191 | virtual status_t startAudioSource(const struct audio_port_config *source, |
| 192 | const audio_attributes_t *attributes, |
Glenn Kasten | 559d439 | 2016-03-29 13:42:57 -0700 | [diff] [blame] | 193 | audio_patch_handle_t *handle); |
| 194 | virtual status_t stopAudioSource(audio_patch_handle_t handle); |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 195 | |
Andy Hung | 2ddee19 | 2015-12-18 17:34:44 -0800 | [diff] [blame] | 196 | virtual status_t setMasterMono(bool mono); |
| 197 | virtual status_t getMasterMono(bool *mono); |
| 198 | |
Eric Laurent | ac9cef5 | 2017-06-09 15:46:26 -0700 | [diff] [blame] | 199 | virtual float getStreamVolumeDB( |
| 200 | audio_stream_type_t stream, int index, audio_devices_t device); |
| 201 | |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 202 | status_t doStopOutput(audio_io_handle_t output, |
| 203 | audio_stream_type_t stream, |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 204 | audio_session_t session); |
| 205 | void doReleaseOutput(audio_io_handle_t output, |
| 206 | audio_stream_type_t stream, |
| 207 | audio_session_t session); |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 208 | |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 209 | status_t clientCreateAudioPatch(const struct audio_patch *patch, |
| 210 | audio_patch_handle_t *handle, |
| 211 | int delayMs); |
| 212 | status_t clientReleaseAudioPatch(audio_patch_handle_t handle, |
| 213 | int delayMs); |
Eric Laurent | e1715a4 | 2014-05-20 11:30:42 -0700 | [diff] [blame] | 214 | virtual status_t clientSetAudioPortConfig(const struct audio_port_config *config, |
| 215 | int delayMs); |
| 216 | |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 217 | void removeNotificationClient(uid_t uid); |
| 218 | void onAudioPortListUpdate(); |
| 219 | void doOnAudioPortListUpdate(); |
| 220 | void onAudioPatchListUpdate(); |
| 221 | void doOnAudioPatchListUpdate(); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 222 | |
Chih-Hung Hsieh | e964d4e | 2016-08-09 14:31:32 -0700 | [diff] [blame] | 223 | void onDynamicPolicyMixStateUpdate(const String8& regId, int32_t state); |
| 224 | void doOnDynamicPolicyMixStateUpdate(const String8& regId, int32_t state); |
Jean-Michel Trivi | ac4e429 | 2016-12-22 11:39:31 -0800 | [diff] [blame] | 225 | void onRecordingConfigurationUpdate(int event, const record_client_info_t *clientInfo, |
| 226 | const audio_config_base_t *clientConfig, |
Jean-Michel Trivi | 8c7cf3b | 2016-02-25 17:08:24 -0800 | [diff] [blame] | 227 | const audio_config_base_t *deviceConfig, audio_patch_handle_t patchHandle); |
Jean-Michel Trivi | ac4e429 | 2016-12-22 11:39:31 -0800 | [diff] [blame] | 228 | void doOnRecordingConfigurationUpdate(int event, const record_client_info_t *clientInfo, |
| 229 | const audio_config_base_t *clientConfig, |
Jean-Michel Trivi | 8c7cf3b | 2016-02-25 17:08:24 -0800 | [diff] [blame] | 230 | const audio_config_base_t *deviceConfig, audio_patch_handle_t patchHandle); |
Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame] | 231 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 232 | private: |
Mathias Agopian | e762be9 | 2013-05-09 16:26:45 -0700 | [diff] [blame] | 233 | AudioPolicyService() ANDROID_API; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 234 | virtual ~AudioPolicyService(); |
| 235 | |
| 236 | status_t dumpInternals(int fd); |
| 237 | |
| 238 | // 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] | 239 | // For tone playback, using a separate thread is necessary to avoid deadlock with mLock because |
| 240 | // startTone() and stopTone() are normally called with mLock locked and requesting a tone start |
| 241 | // or stop will cause calls to AudioPolicyService and an attempt to lock mLock. |
| 242 | // For audio config commands, it is necessary because audio flinger requires that the calling |
| 243 | // process (user) has permission to modify audio settings. |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 244 | class AudioCommandThread : public Thread { |
| 245 | class AudioCommand; |
| 246 | public: |
| 247 | |
| 248 | // commands for tone AudioCommand |
| 249 | enum { |
| 250 | START_TONE, |
| 251 | STOP_TONE, |
| 252 | SET_VOLUME, |
| 253 | SET_PARAMETERS, |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 254 | SET_VOICE_VOLUME, |
| 255 | STOP_OUTPUT, |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 256 | RELEASE_OUTPUT, |
| 257 | CREATE_AUDIO_PATCH, |
| 258 | RELEASE_AUDIO_PATCH, |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 259 | UPDATE_AUDIOPORT_LIST, |
Eric Laurent | e1715a4 | 2014-05-20 11:30:42 -0700 | [diff] [blame] | 260 | UPDATE_AUDIOPATCH_LIST, |
| 261 | SET_AUDIOPORT_CONFIG, |
Jean-Michel Trivi | 2f4fe9f | 2015-12-04 16:20:59 -0800 | [diff] [blame] | 262 | DYN_POLICY_MIX_STATE_UPDATE, |
| 263 | RECORDING_CONFIGURATION_UPDATE |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 264 | }; |
| 265 | |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 266 | AudioCommandThread (String8 name, const wp<AudioPolicyService>& service); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 267 | virtual ~AudioCommandThread(); |
| 268 | |
| 269 | status_t dump(int fd); |
| 270 | |
| 271 | // Thread virtuals |
| 272 | virtual void onFirstRef(); |
| 273 | virtual bool threadLoop(); |
| 274 | |
| 275 | void exit(); |
Glenn Kasten | 3d2f877 | 2012-01-27 15:25:25 -0800 | [diff] [blame] | 276 | void startToneCommand(ToneGenerator::tone_type type, |
| 277 | audio_stream_type_t stream); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 278 | void stopToneCommand(); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 279 | status_t volumeCommand(audio_stream_type_t stream, float volume, |
| 280 | audio_io_handle_t output, int delayMs = 0); |
| 281 | status_t parametersCommand(audio_io_handle_t ioHandle, |
| 282 | const char *keyValuePairs, int delayMs = 0); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 283 | status_t voiceVolumeCommand(float volume, int delayMs = 0); |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 284 | void stopOutputCommand(audio_io_handle_t output, |
| 285 | audio_stream_type_t stream, |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 286 | audio_session_t session); |
| 287 | void releaseOutputCommand(audio_io_handle_t output, |
| 288 | audio_stream_type_t stream, |
| 289 | audio_session_t session); |
Eric Laurent | 0ede892 | 2014-05-09 18:04:42 -0700 | [diff] [blame] | 290 | status_t sendCommand(sp<AudioCommand>& command, int delayMs = 0); |
| 291 | void insertCommand_l(sp<AudioCommand>& command, int delayMs = 0); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 292 | status_t createAudioPatchCommand(const struct audio_patch *patch, |
| 293 | audio_patch_handle_t *handle, |
| 294 | int delayMs); |
| 295 | status_t releaseAudioPatchCommand(audio_patch_handle_t handle, |
| 296 | int delayMs); |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 297 | void updateAudioPortListCommand(); |
| 298 | void updateAudioPatchListCommand(); |
Eric Laurent | e1715a4 | 2014-05-20 11:30:42 -0700 | [diff] [blame] | 299 | status_t setAudioPortConfigCommand(const struct audio_port_config *config, |
| 300 | int delayMs); |
Chih-Hung Hsieh | e964d4e | 2016-08-09 14:31:32 -0700 | [diff] [blame] | 301 | void dynamicPolicyMixStateUpdateCommand(const String8& regId, int32_t state); |
Jean-Michel Trivi | 2f4fe9f | 2015-12-04 16:20:59 -0800 | [diff] [blame] | 302 | void recordingConfigurationUpdateCommand( |
Jean-Michel Trivi | ac4e429 | 2016-12-22 11:39:31 -0800 | [diff] [blame] | 303 | int event, |
| 304 | const record_client_info_t *clientInfo, |
Jean-Michel Trivi | 7281aa9 | 2016-02-17 15:33:40 -0800 | [diff] [blame] | 305 | const audio_config_base_t *clientConfig, |
Jean-Michel Trivi | 8c7cf3b | 2016-02-25 17:08:24 -0800 | [diff] [blame] | 306 | const audio_config_base_t *deviceConfig, |
| 307 | audio_patch_handle_t patchHandle); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 308 | void insertCommand_l(AudioCommand *command, int delayMs = 0); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 309 | |
| 310 | private: |
Jesper Tragardh | 48412dc | 2014-03-24 14:12:43 +0100 | [diff] [blame] | 311 | class AudioCommandData; |
| 312 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 313 | // descriptor for requested tone playback event |
Eric Laurent | 0ede892 | 2014-05-09 18:04:42 -0700 | [diff] [blame] | 314 | class AudioCommand: public RefBase { |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 315 | |
| 316 | public: |
| 317 | AudioCommand() |
Eric Laurent | 0ede892 | 2014-05-09 18:04:42 -0700 | [diff] [blame] | 318 | : mCommand(-1), mStatus(NO_ERROR), mWaitStatus(false) {} |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 319 | |
| 320 | void dump(char* buffer, size_t size); |
| 321 | |
| 322 | int mCommand; // START_TONE, STOP_TONE ... |
| 323 | nsecs_t mTime; // time stamp |
Eric Laurent | 0ede892 | 2014-05-09 18:04:42 -0700 | [diff] [blame] | 324 | Mutex mLock; // mutex associated to mCond |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 325 | Condition mCond; // condition for status return |
| 326 | status_t mStatus; // command status |
| 327 | bool mWaitStatus; // true if caller is waiting for status |
Eric Laurent | 0ede892 | 2014-05-09 18:04:42 -0700 | [diff] [blame] | 328 | sp<AudioCommandData> mParam; // command specific parameter data |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 329 | }; |
| 330 | |
Eric Laurent | 0ede892 | 2014-05-09 18:04:42 -0700 | [diff] [blame] | 331 | class AudioCommandData: public RefBase { |
Jesper Tragardh | 48412dc | 2014-03-24 14:12:43 +0100 | [diff] [blame] | 332 | public: |
| 333 | virtual ~AudioCommandData() {} |
| 334 | protected: |
| 335 | AudioCommandData() {} |
| 336 | }; |
| 337 | |
| 338 | class ToneData : public AudioCommandData { |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 339 | public: |
Glenn Kasten | 3d2f877 | 2012-01-27 15:25:25 -0800 | [diff] [blame] | 340 | ToneGenerator::tone_type mType; // tone type (START_TONE only) |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 341 | audio_stream_type_t mStream; // stream type (START_TONE only) |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 342 | }; |
| 343 | |
Jesper Tragardh | 48412dc | 2014-03-24 14:12:43 +0100 | [diff] [blame] | 344 | class VolumeData : public AudioCommandData { |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 345 | public: |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 346 | audio_stream_type_t mStream; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 347 | float mVolume; |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 348 | audio_io_handle_t mIO; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 349 | }; |
| 350 | |
Jesper Tragardh | 48412dc | 2014-03-24 14:12:43 +0100 | [diff] [blame] | 351 | class ParametersData : public AudioCommandData { |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 352 | public: |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 353 | audio_io_handle_t mIO; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 354 | String8 mKeyValuePairs; |
| 355 | }; |
| 356 | |
Jesper Tragardh | 48412dc | 2014-03-24 14:12:43 +0100 | [diff] [blame] | 357 | class VoiceVolumeData : public AudioCommandData { |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 358 | public: |
| 359 | float mVolume; |
| 360 | }; |
| 361 | |
Jesper Tragardh | 48412dc | 2014-03-24 14:12:43 +0100 | [diff] [blame] | 362 | class StopOutputData : public AudioCommandData { |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 363 | public: |
| 364 | audio_io_handle_t mIO; |
| 365 | audio_stream_type_t mStream; |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 366 | audio_session_t mSession; |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 367 | }; |
| 368 | |
Jesper Tragardh | 48412dc | 2014-03-24 14:12:43 +0100 | [diff] [blame] | 369 | class ReleaseOutputData : public AudioCommandData { |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 370 | public: |
| 371 | audio_io_handle_t mIO; |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 372 | audio_stream_type_t mStream; |
| 373 | audio_session_t mSession; |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 374 | }; |
| 375 | |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 376 | class CreateAudioPatchData : public AudioCommandData { |
| 377 | public: |
| 378 | struct audio_patch mPatch; |
| 379 | audio_patch_handle_t mHandle; |
| 380 | }; |
| 381 | |
| 382 | class ReleaseAudioPatchData : public AudioCommandData { |
| 383 | public: |
| 384 | audio_patch_handle_t mHandle; |
| 385 | }; |
| 386 | |
Eric Laurent | e1715a4 | 2014-05-20 11:30:42 -0700 | [diff] [blame] | 387 | class SetAudioPortConfigData : public AudioCommandData { |
| 388 | public: |
| 389 | struct audio_port_config mConfig; |
| 390 | }; |
| 391 | |
Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame] | 392 | class DynPolicyMixStateUpdateData : public AudioCommandData { |
| 393 | public: |
| 394 | String8 mRegId; |
| 395 | int32_t mState; |
| 396 | }; |
| 397 | |
Jean-Michel Trivi | 2f4fe9f | 2015-12-04 16:20:59 -0800 | [diff] [blame] | 398 | class RecordingConfigurationUpdateData : public AudioCommandData { |
| 399 | public: |
| 400 | int mEvent; |
Jean-Michel Trivi | ac4e429 | 2016-12-22 11:39:31 -0800 | [diff] [blame] | 401 | record_client_info_t mClientInfo; |
Jean-Michel Trivi | 7281aa9 | 2016-02-17 15:33:40 -0800 | [diff] [blame] | 402 | struct audio_config_base mClientConfig; |
| 403 | struct audio_config_base mDeviceConfig; |
Jean-Michel Trivi | 8c7cf3b | 2016-02-25 17:08:24 -0800 | [diff] [blame] | 404 | audio_patch_handle_t mPatchHandle; |
Jean-Michel Trivi | 2f4fe9f | 2015-12-04 16:20:59 -0800 | [diff] [blame] | 405 | }; |
| 406 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 407 | Mutex mLock; |
| 408 | Condition mWaitWorkCV; |
Eric Laurent | 0ede892 | 2014-05-09 18:04:42 -0700 | [diff] [blame] | 409 | Vector < sp<AudioCommand> > mAudioCommands; // list of pending commands |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 410 | ToneGenerator *mpToneGenerator; // the tone generator |
Eric Laurent | 0ede892 | 2014-05-09 18:04:42 -0700 | [diff] [blame] | 411 | sp<AudioCommand> mLastCommand; // last processed command (used by dump) |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 412 | String8 mName; // string used by wake lock fo delayed commands |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 413 | wp<AudioPolicyService> mService; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 414 | }; |
| 415 | |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 416 | class AudioPolicyClient : public AudioPolicyClientInterface |
| 417 | { |
| 418 | public: |
Chih-Hung Hsieh | e964d4e | 2016-08-09 14:31:32 -0700 | [diff] [blame] | 419 | explicit AudioPolicyClient(AudioPolicyService *service) : mAudioPolicyService(service) {} |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 420 | virtual ~AudioPolicyClient() {} |
| 421 | |
| 422 | // |
| 423 | // Audio HW module functions |
| 424 | // |
| 425 | |
| 426 | // loads a HW module. |
| 427 | virtual audio_module_handle_t loadHwModule(const char *name); |
| 428 | |
| 429 | // |
| 430 | // Audio output Control functions |
| 431 | // |
| 432 | |
| 433 | // opens an audio output with the requested parameters. The parameter values can indicate to use the default values |
| 434 | // in case the audio policy manager has no specific requirements for the output being opened. |
| 435 | // When the function returns, the parameter values reflect the actual values used by the audio hardware output stream. |
| 436 | // The audio policy manager can check if the proposed parameters are suitable or not and act accordingly. |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 437 | virtual status_t openOutput(audio_module_handle_t module, |
| 438 | audio_io_handle_t *output, |
| 439 | audio_config_t *config, |
| 440 | audio_devices_t *devices, |
| 441 | const String8& address, |
| 442 | uint32_t *latencyMs, |
| 443 | audio_output_flags_t flags); |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 444 | // creates a special output that is duplicated to the two outputs passed as arguments. The duplication is performed by |
| 445 | // a special mixer thread in the AudioFlinger. |
| 446 | virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1, audio_io_handle_t output2); |
| 447 | // closes the output stream |
| 448 | virtual status_t closeOutput(audio_io_handle_t output); |
| 449 | // suspends the output. When an output is suspended, the corresponding audio hardware output stream is placed in |
| 450 | // standby and the AudioTracks attached to the mixer thread are still processed but the output mix is discarded. |
| 451 | virtual status_t suspendOutput(audio_io_handle_t output); |
| 452 | // restores a suspended output. |
| 453 | virtual status_t restoreOutput(audio_io_handle_t output); |
| 454 | |
| 455 | // |
| 456 | // Audio input Control functions |
| 457 | // |
| 458 | |
| 459 | // opens an audio input |
| 460 | virtual audio_io_handle_t openInput(audio_module_handle_t module, |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 461 | audio_io_handle_t *input, |
| 462 | audio_config_t *config, |
| 463 | audio_devices_t *devices, |
| 464 | const String8& address, |
| 465 | audio_source_t source, |
Glenn Kasten | ec40d28 | 2014-07-15 15:31:26 -0700 | [diff] [blame] | 466 | audio_input_flags_t flags); |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 467 | // closes an audio input |
| 468 | virtual status_t closeInput(audio_io_handle_t input); |
| 469 | // |
| 470 | // misc control functions |
| 471 | // |
| 472 | |
| 473 | // set a stream volume for a particular output. For the same user setting, a given stream type can have different volumes |
| 474 | // for each output (destination device) it is attached to. |
| 475 | virtual status_t setStreamVolume(audio_stream_type_t stream, float volume, audio_io_handle_t output, int delayMs = 0); |
| 476 | |
| 477 | // invalidate a stream type, causing a reroute to an unspecified new output |
| 478 | virtual status_t invalidateStream(audio_stream_type_t stream); |
| 479 | |
| 480 | // function enabling to send proprietary informations directly from audio policy manager to audio hardware interface. |
| 481 | virtual void setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs, int delayMs = 0); |
| 482 | // function enabling to receive proprietary informations directly from audio hardware interface to audio policy manager. |
| 483 | virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys); |
| 484 | |
| 485 | // request the playback of a tone on the specified stream: used for instance to replace notification sounds when playing |
| 486 | // over a telephony device during a phone call. |
| 487 | virtual status_t startTone(audio_policy_tone_t tone, audio_stream_type_t stream); |
| 488 | virtual status_t stopTone(); |
| 489 | |
| 490 | // set down link audio volume. |
| 491 | virtual status_t setVoiceVolume(float volume, int delayMs = 0); |
| 492 | |
| 493 | // move effect to the specified output |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 494 | virtual status_t moveEffects(audio_session_t session, |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 495 | audio_io_handle_t srcOutput, |
| 496 | audio_io_handle_t dstOutput); |
| 497 | |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 498 | /* Create a patch between several source and sink ports */ |
| 499 | virtual status_t createAudioPatch(const struct audio_patch *patch, |
| 500 | audio_patch_handle_t *handle, |
| 501 | int delayMs); |
| 502 | |
| 503 | /* Release a patch */ |
| 504 | virtual status_t releaseAudioPatch(audio_patch_handle_t handle, |
| 505 | int delayMs); |
| 506 | |
Eric Laurent | e1715a4 | 2014-05-20 11:30:42 -0700 | [diff] [blame] | 507 | /* Set audio port configuration */ |
| 508 | virtual status_t setAudioPortConfig(const struct audio_port_config *config, int delayMs); |
| 509 | |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 510 | virtual void onAudioPortListUpdate(); |
| 511 | virtual void onAudioPatchListUpdate(); |
Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame] | 512 | virtual void onDynamicPolicyMixStateUpdate(String8 regId, int32_t state); |
Jean-Michel Trivi | 2f4fe9f | 2015-12-04 16:20:59 -0800 | [diff] [blame] | 513 | virtual void onRecordingConfigurationUpdate(int event, |
Jean-Michel Trivi | ac4e429 | 2016-12-22 11:39:31 -0800 | [diff] [blame] | 514 | const record_client_info_t *clientInfo, |
Jean-Michel Trivi | 7281aa9 | 2016-02-17 15:33:40 -0800 | [diff] [blame] | 515 | const audio_config_base_t *clientConfig, |
Jean-Michel Trivi | 8c7cf3b | 2016-02-25 17:08:24 -0800 | [diff] [blame] | 516 | const audio_config_base_t *deviceConfig, audio_patch_handle_t patchHandle); |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 517 | |
Glenn Kasten | eeecb98 | 2016-02-26 10:44:04 -0800 | [diff] [blame] | 518 | virtual audio_unique_id_t newAudioUniqueId(audio_unique_id_use_t use); |
Eric Laurent | de3f839 | 2014-07-27 18:38:22 -0700 | [diff] [blame] | 519 | |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 520 | private: |
| 521 | AudioPolicyService *mAudioPolicyService; |
| 522 | }; |
| 523 | |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 524 | // --- Notification Client --- |
| 525 | class NotificationClient : public IBinder::DeathRecipient { |
| 526 | public: |
| 527 | NotificationClient(const sp<AudioPolicyService>& service, |
| 528 | const sp<IAudioPolicyServiceClient>& client, |
| 529 | uid_t uid); |
| 530 | virtual ~NotificationClient(); |
| 531 | |
Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame] | 532 | void onAudioPortListUpdate(); |
| 533 | void onAudioPatchListUpdate(); |
Chih-Hung Hsieh | e964d4e | 2016-08-09 14:31:32 -0700 | [diff] [blame] | 534 | void onDynamicPolicyMixStateUpdate(const String8& regId, int32_t state); |
Jean-Michel Trivi | 2f4fe9f | 2015-12-04 16:20:59 -0800 | [diff] [blame] | 535 | void onRecordingConfigurationUpdate( |
Jean-Michel Trivi | ac4e429 | 2016-12-22 11:39:31 -0800 | [diff] [blame] | 536 | int event, const record_client_info_t *clientInfo, |
Jean-Michel Trivi | 7281aa9 | 2016-02-17 15:33:40 -0800 | [diff] [blame] | 537 | const audio_config_base_t *clientConfig, |
Jean-Michel Trivi | 8c7cf3b | 2016-02-25 17:08:24 -0800 | [diff] [blame] | 538 | const audio_config_base_t *deviceConfig, |
| 539 | audio_patch_handle_t patchHandle); |
Eric Laurent | e8726fe | 2015-06-26 09:39:24 -0700 | [diff] [blame] | 540 | void setAudioPortCallbacksEnabled(bool enabled); |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 541 | |
| 542 | // IBinder::DeathRecipient |
| 543 | virtual void binderDied(const wp<IBinder>& who); |
| 544 | |
| 545 | private: |
| 546 | NotificationClient(const NotificationClient&); |
| 547 | NotificationClient& operator = (const NotificationClient&); |
| 548 | |
| 549 | const wp<AudioPolicyService> mService; |
| 550 | const uid_t mUid; |
| 551 | const sp<IAudioPolicyServiceClient> mAudioPolicyServiceClient; |
Eric Laurent | e8726fe | 2015-06-26 09:39:24 -0700 | [diff] [blame] | 552 | bool mAudioPortCallbacksEnabled; |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 553 | }; |
| 554 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 555 | // Internal dump utilities. |
| 556 | status_t dumpPermissionDenial(int fd); |
| 557 | |
| 558 | |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 559 | mutable Mutex mLock; // prevents concurrent access to AudioPolicy manager functions changing |
| 560 | // device connection state or routing |
Haynes Mathew George | bab7bf4 | 2015-10-30 18:02:23 -0700 | [diff] [blame] | 561 | mutable Mutex mEffectsLock; // serialize access to Effect state within APM. |
| 562 | // Note: lock acquisition order is always mLock > mEffectsLock: |
| 563 | // mLock protects AudioPolicyManager methods that can call into audio flinger |
| 564 | // and possibly back in to audio policy service and acquire mEffectsLock. |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 565 | sp<AudioCommandThread> mAudioCommandThread; // audio commands thread |
| 566 | sp<AudioCommandThread> mTonePlaybackThread; // tone playback thread |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 567 | sp<AudioCommandThread> mOutputCommandThread; // process stop and release output |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 568 | struct audio_policy_device *mpAudioPolicyDev; |
| 569 | struct audio_policy *mpAudioPolicy; |
Eric Laurent | f269b8e | 2014-06-09 20:01:29 -0700 | [diff] [blame] | 570 | AudioPolicyInterface *mAudioPolicyManager; |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 571 | AudioPolicyClient *mAudioPolicyClient; |
| 572 | |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 573 | DefaultKeyedVector< uid_t, sp<NotificationClient> > mNotificationClients; |
Eric Laurent | 0ebd5f9 | 2014-11-19 19:04:52 -0800 | [diff] [blame] | 574 | Mutex mNotificationClientsLock; // protects mNotificationClients |
bryant_liu | ba2b439 | 2014-06-11 16:49:30 +0800 | [diff] [blame] | 575 | // Manage all effects configured in audio_effects.conf |
| 576 | sp<AudioPolicyEffects> mAudioPolicyEffects; |
Eric Laurent | bb6c9a0 | 2014-09-25 14:11:47 -0700 | [diff] [blame] | 577 | audio_mode_t mPhoneState; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 578 | }; |
| 579 | |
Mikhail Naganov | 1b2a794 | 2017-12-08 10:18:09 -0800 | [diff] [blame^] | 580 | } // namespace android |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 581 | |
| 582 | #endif // ANDROID_AUDIOPOLICYSERVICE_H |