blob: 279dc93e6dc2a89e277005a65d5009c83c789836 [file] [log] [blame]
Jean-Michel Trivi56ec4ff2015-01-23 16:45:18 -08001/*
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
François Gaffiead3183e2015-03-18 16:55:35 +010017#pragma once
Jean-Michel Trivi56ec4ff2015-01-23 16:45:18 -080018
19#include <stdint.h>
20#include <sys/types.h>
21#include <cutils/config_utils.h>
22#include <cutils/misc.h>
23#include <utils/Timers.h>
24#include <utils/Errors.h>
25#include <utils/KeyedVector.h>
26#include <utils/SortedVector.h>
27#include <media/AudioPolicy.h>
28#include "AudioPolicyInterface.h"
29
François Gaffie98cc1912015-03-18 17:52:40 +010030#include <AudioGain.h>
31#include <AudioPort.h>
32#include <AudioPatch.h>
33#include <ConfigParsingUtils.h>
34#include <DeviceDescriptor.h>
35#include <IOProfile.h>
36#include <HwModule.h>
37#include <AudioInputDescriptor.h>
38#include <AudioOutputDescriptor.h>
Jean-Michel Trivi56ec4ff2015-01-23 16:45:18 -080039
40namespace android {
41
42// ----------------------------------------------------------------------------
43
44// Attenuation applied to STRATEGY_SONIFICATION streams when a headset is connected: 6dB
45#define SONIFICATION_HEADSET_VOLUME_FACTOR 0.5
46// Min volume for STRATEGY_SONIFICATION streams when limited by music volume: -36dB
47#define SONIFICATION_HEADSET_VOLUME_MIN 0.016
48// Time in milliseconds during which we consider that music is still active after a music
49// track was stopped - see computeVolume()
50#define SONIFICATION_HEADSET_MUSIC_DELAY 5000
51// Time in milliseconds after media stopped playing during which we consider that the
52// sonification should be as unobtrusive as during the time media was playing.
53#define SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY 5000
54// Time in milliseconds during witch some streams are muted while the audio path
55// is switched
56#define MUTE_TIME_MS 2000
57
58#define NUM_TEST_OUTPUTS 5
59
60#define NUM_VOL_CURVE_KNEES 2
61
62// Default minimum length allowed for offloading a compressed track
63// Can be overridden by the audio.offload.min.duration.secs property
64#define OFFLOAD_DEFAULT_MIN_DURATION_SECS 60
65
Jean-Michel Trivi56ec4ff2015-01-23 16:45:18 -080066// ----------------------------------------------------------------------------
67// AudioPolicyManager implements audio policy manager behavior common to all platforms.
68// ----------------------------------------------------------------------------
69
70class AudioPolicyManager: public AudioPolicyInterface
71#ifdef AUDIO_POLICY_TEST
72 , public Thread
73#endif //AUDIO_POLICY_TEST
74{
75
76public:
77 AudioPolicyManager(AudioPolicyClientInterface *clientInterface);
78 virtual ~AudioPolicyManager();
79
80 // AudioPolicyInterface
81 virtual status_t setDeviceConnectionState(audio_devices_t device,
82 audio_policy_dev_state_t state,
83 const char *device_address,
84 const char *device_name);
85 virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device,
86 const char *device_address);
87 virtual void setPhoneState(audio_mode_t state);
88 virtual void setForceUse(audio_policy_force_use_t usage,
89 audio_policy_forced_cfg_t config);
90 virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage);
91 virtual void setSystemProperty(const char* property, const char* value);
92 virtual status_t initCheck();
93 virtual audio_io_handle_t getOutput(audio_stream_type_t stream,
94 uint32_t samplingRate,
95 audio_format_t format,
96 audio_channel_mask_t channelMask,
97 audio_output_flags_t flags,
98 const audio_offload_info_t *offloadInfo);
99 virtual status_t getOutputForAttr(const audio_attributes_t *attr,
100 audio_io_handle_t *output,
101 audio_session_t session,
102 audio_stream_type_t *stream,
103 uint32_t samplingRate,
104 audio_format_t format,
105 audio_channel_mask_t channelMask,
106 audio_output_flags_t flags,
107 const audio_offload_info_t *offloadInfo);
108 virtual status_t startOutput(audio_io_handle_t output,
109 audio_stream_type_t stream,
110 audio_session_t session);
111 virtual status_t stopOutput(audio_io_handle_t output,
112 audio_stream_type_t stream,
113 audio_session_t session);
114 virtual void releaseOutput(audio_io_handle_t output,
115 audio_stream_type_t stream,
116 audio_session_t session);
117 virtual status_t getInputForAttr(const audio_attributes_t *attr,
118 audio_io_handle_t *input,
119 audio_session_t session,
120 uint32_t samplingRate,
121 audio_format_t format,
122 audio_channel_mask_t channelMask,
123 audio_input_flags_t flags,
124 input_type_t *inputType);
125
126 // indicates to the audio policy manager that the input starts being used.
127 virtual status_t startInput(audio_io_handle_t input,
128 audio_session_t session);
129
130 // indicates to the audio policy manager that the input stops being used.
131 virtual status_t stopInput(audio_io_handle_t input,
132 audio_session_t session);
133 virtual void releaseInput(audio_io_handle_t input,
134 audio_session_t session);
135 virtual void closeAllInputs();
136 virtual void initStreamVolume(audio_stream_type_t stream,
137 int indexMin,
138 int indexMax);
139 virtual status_t setStreamVolumeIndex(audio_stream_type_t stream,
140 int index,
141 audio_devices_t device);
142 virtual status_t getStreamVolumeIndex(audio_stream_type_t stream,
143 int *index,
144 audio_devices_t device);
145
146 // return the strategy corresponding to a given stream type
147 virtual uint32_t getStrategyForStream(audio_stream_type_t stream);
148 // return the strategy corresponding to the given audio attributes
149 virtual uint32_t getStrategyForAttr(const audio_attributes_t *attr);
150
151 // return the enabled output devices for the given stream type
152 virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream);
153
154 virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc = NULL);
155 virtual status_t registerEffect(const effect_descriptor_t *desc,
156 audio_io_handle_t io,
157 uint32_t strategy,
158 int session,
159 int id);
160 virtual status_t unregisterEffect(int id);
161 virtual status_t setEffectEnabled(int id, bool enabled);
162
163 virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const;
164 // return whether a stream is playing remotely, override to change the definition of
165 // local/remote playback, used for instance by notification manager to not make
166 // media players lose audio focus when not playing locally
167 // For the base implementation, "remotely" means playing during screen mirroring which
168 // uses an output for playback with a non-empty, non "0" address.
169 virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs = 0) const;
170 virtual bool isSourceActive(audio_source_t source) const;
171
172 virtual status_t dump(int fd);
173
174 virtual bool isOffloadSupported(const audio_offload_info_t& offloadInfo);
175
176 virtual status_t listAudioPorts(audio_port_role_t role,
177 audio_port_type_t type,
178 unsigned int *num_ports,
179 struct audio_port *ports,
180 unsigned int *generation);
181 virtual status_t getAudioPort(struct audio_port *port);
182 virtual status_t createAudioPatch(const struct audio_patch *patch,
183 audio_patch_handle_t *handle,
184 uid_t uid);
185 virtual status_t releaseAudioPatch(audio_patch_handle_t handle,
186 uid_t uid);
187 virtual status_t listAudioPatches(unsigned int *num_patches,
188 struct audio_patch *patches,
189 unsigned int *generation);
190 virtual status_t setAudioPortConfig(const struct audio_port_config *config);
191 virtual void clearAudioPatches(uid_t uid);
192
193 virtual status_t acquireSoundTriggerSession(audio_session_t *session,
194 audio_io_handle_t *ioHandle,
195 audio_devices_t *device);
196
197 virtual status_t releaseSoundTriggerSession(audio_session_t session);
198
199 virtual status_t registerPolicyMixes(Vector<AudioMix> mixes);
200 virtual status_t unregisterPolicyMixes(Vector<AudioMix> mixes);
201
202 // Audio policy configuration file parsing (audio_policy.conf)
203 // TODO candidates to be moved to ConfigParsingUtils
204 void loadHwModule(cnode *root);
205 void loadHwModules(cnode *root);
206 void loadGlobalConfig(cnode *root, const sp<HwModule>& module);
207 status_t loadAudioPolicyConfig(const char *path);
208 void defaultAudioPolicyConfig(void);
209
210 // return the strategy corresponding to a given stream type
211 static routing_strategy getStrategy(audio_stream_type_t stream);
Jean-Michel Trivi56ec4ff2015-01-23 16:45:18 -0800212protected:
213
214 class EffectDescriptor : public RefBase
215 {
216 public:
217
218 status_t dump(int fd);
219
220 int mIo; // io the effect is attached to
221 routing_strategy mStrategy; // routing strategy the effect is associated to
222 int mSession; // audio session the effect is on
223 effect_descriptor_t mDesc; // effect descriptor
224 bool mEnabled; // enabled state: CPU load being used or not
225 };
226
227 void addOutput(audio_io_handle_t output, sp<AudioOutputDescriptor> outputDesc);
228 void addInput(audio_io_handle_t input, sp<AudioInputDescriptor> inputDesc);
229
230 // return appropriate device for streams handled by the specified strategy according to current
231 // phone state, connected devices...
232 // if fromCache is true, the device is returned from mDeviceForStrategy[],
233 // otherwise it is determine by current state
234 // (device connected,phone state, force use, a2dp output...)
235 // This allows to:
236 // 1 speed up process when the state is stable (when starting or stopping an output)
237 // 2 access to either current device selection (fromCache == true) or
238 // "future" device selection (fromCache == false) when called from a context
239 // where conditions are changing (setDeviceConnectionState(), setPhoneState()...) AND
240 // before updateDevicesAndOutputs() is called.
241 virtual audio_devices_t getDeviceForStrategy(routing_strategy strategy,
242 bool fromCache);
243
244 // change the route of the specified output. Returns the number of ms we have slept to
245 // allow new routing to take effect in certain cases.
246 virtual uint32_t setOutputDevice(audio_io_handle_t output,
247 audio_devices_t device,
248 bool force = false,
249 int delayMs = 0,
250 audio_patch_handle_t *patchHandle = NULL,
251 const char* address = NULL);
252 status_t resetOutputDevice(audio_io_handle_t output,
253 int delayMs = 0,
254 audio_patch_handle_t *patchHandle = NULL);
255 status_t setInputDevice(audio_io_handle_t input,
256 audio_devices_t device,
257 bool force = false,
258 audio_patch_handle_t *patchHandle = NULL);
259 status_t resetInputDevice(audio_io_handle_t input,
260 audio_patch_handle_t *patchHandle = NULL);
261
262 // select input device corresponding to requested audio source
263 virtual audio_devices_t getDeviceForInputSource(audio_source_t inputSource);
264
265 // return io handle of active input or 0 if no input is active
266 // Only considers inputs from physical devices (e.g. main mic, headset mic) when
267 // ignoreVirtualInputs is true.
268 audio_io_handle_t getActiveInput(bool ignoreVirtualInputs = true);
269
270 uint32_t activeInputsCount() const;
271
272 // initialize volume curves for each strategy and device category
273 void initializeVolumeCurves();
274
275 // compute the actual volume for a given stream according to the requested index and a particular
276 // device
277 virtual float computeVolume(audio_stream_type_t stream, int index,
278 audio_io_handle_t output, audio_devices_t device);
279
280 // check that volume change is permitted, compute and send new volume to audio hardware
281 virtual status_t checkAndSetVolume(audio_stream_type_t stream, int index,
282 audio_io_handle_t output,
283 audio_devices_t device,
284 int delayMs = 0, bool force = false);
285
286 // apply all stream volumes to the specified output and device
287 void applyStreamVolumes(audio_io_handle_t output, audio_devices_t device, int delayMs = 0, bool force = false);
288
289 // Mute or unmute all streams handled by the specified strategy on the specified output
290 void setStrategyMute(routing_strategy strategy,
291 bool on,
292 audio_io_handle_t output,
293 int delayMs = 0,
294 audio_devices_t device = (audio_devices_t)0);
295
296 // Mute or unmute the stream on the specified output
297 void setStreamMute(audio_stream_type_t stream,
298 bool on,
299 audio_io_handle_t output,
300 int delayMs = 0,
301 audio_devices_t device = (audio_devices_t)0);
302
303 // handle special cases for sonification strategy while in call: mute streams or replace by
304 // a special tone in the device used for communication
305 void handleIncallSonification(audio_stream_type_t stream, bool starting, bool stateChange);
306
307 // true if device is in a telephony or VoIP call
308 virtual bool isInCall();
309
310 // true if given state represents a device in a telephony or VoIP call
311 virtual bool isStateInCall(int state);
312
313 // when a device is connected, checks if an open output can be routed
314 // to this device. If none is open, tries to open one of the available outputs.
315 // Returns an output suitable to this device or 0.
316 // when a device is disconnected, checks if an output is not used any more and
317 // returns its handle if any.
318 // transfers the audio tracks and effects from one output thread to another accordingly.
319 status_t checkOutputsForDevice(const sp<DeviceDescriptor> devDesc,
320 audio_policy_dev_state_t state,
321 SortedVector<audio_io_handle_t>& outputs,
322 const String8 address);
323
324 status_t checkInputsForDevice(audio_devices_t device,
325 audio_policy_dev_state_t state,
326 SortedVector<audio_io_handle_t>& inputs,
327 const String8 address);
328
329 // close an output and its companion duplicating output.
330 void closeOutput(audio_io_handle_t output);
331
332 // close an input.
333 void closeInput(audio_io_handle_t input);
334
335 // checks and if necessary changes outputs used for all strategies.
336 // must be called every time a condition that affects the output choice for a given strategy
337 // changes: connected device, phone state, force use...
338 // Must be called before updateDevicesAndOutputs()
339 void checkOutputForStrategy(routing_strategy strategy);
340
341 // Same as checkOutputForStrategy() but for a all strategies in order of priority
342 void checkOutputForAllStrategies();
343
344 // manages A2DP output suspend/restore according to phone state and BT SCO usage
345 void checkA2dpSuspend();
346
347 // returns the A2DP output handle if it is open or 0 otherwise
348 audio_io_handle_t getA2dpOutput();
349
350 // selects the most appropriate device on output for current state
351 // must be called every time a condition that affects the device choice for a given output is
352 // changed: connected device, phone state, force use, output start, output stop..
353 // see getDeviceForStrategy() for the use of fromCache parameter
354 audio_devices_t getNewOutputDevice(audio_io_handle_t output, bool fromCache);
355
356 // updates cache of device used by all strategies (mDeviceForStrategy[])
357 // must be called every time a condition that affects the device choice for a given strategy is
358 // changed: connected device, phone state, force use...
359 // cached values are used by getDeviceForStrategy() if parameter fromCache is true.
360 // Must be called after checkOutputForAllStrategies()
361 void updateDevicesAndOutputs();
362
363 // selects the most appropriate device on input for current state
364 audio_devices_t getNewInputDevice(audio_io_handle_t input);
365
366 virtual uint32_t getMaxEffectsCpuLoad();
367 virtual uint32_t getMaxEffectsMemory();
368#ifdef AUDIO_POLICY_TEST
369 virtual bool threadLoop();
370 void exit();
371 int testOutputIndex(audio_io_handle_t output);
372#endif //AUDIO_POLICY_TEST
373
374 status_t setEffectEnabled(const sp<EffectDescriptor>& effectDesc, bool enabled);
375
376 SortedVector<audio_io_handle_t> getOutputsForDevice(audio_devices_t device,
377 DefaultKeyedVector<audio_io_handle_t, sp<AudioOutputDescriptor> > openOutputs);
378 bool vectorsEqual(SortedVector<audio_io_handle_t>& outputs1,
379 SortedVector<audio_io_handle_t>& outputs2);
380
381 // mute/unmute strategies using an incompatible device combination
382 // if muting, wait for the audio in pcm buffer to be drained before proceeding
383 // if unmuting, unmute only after the specified delay
384 // Returns the number of ms waited
385 virtual uint32_t checkDeviceMuteStrategies(sp<AudioOutputDescriptor> outputDesc,
386 audio_devices_t prevDevice,
387 uint32_t delayMs);
388
389 audio_io_handle_t selectOutput(const SortedVector<audio_io_handle_t>& outputs,
390 audio_output_flags_t flags,
391 audio_format_t format);
392 // samplingRate parameter is an in/out and so may be modified
393 sp<IOProfile> getInputProfile(audio_devices_t device,
394 String8 address,
395 uint32_t& samplingRate,
396 audio_format_t format,
397 audio_channel_mask_t channelMask,
398 audio_input_flags_t flags);
399 sp<IOProfile> getProfileForDirectOutput(audio_devices_t device,
400 uint32_t samplingRate,
401 audio_format_t format,
402 audio_channel_mask_t channelMask,
403 audio_output_flags_t flags);
404
405 audio_io_handle_t selectOutputForEffects(const SortedVector<audio_io_handle_t>& outputs);
406
407 bool isNonOffloadableEffectEnabled();
408
409 virtual status_t addAudioPatch(audio_patch_handle_t handle,
410 const sp<AudioPatch>& patch);
411 virtual status_t removeAudioPatch(audio_patch_handle_t handle);
412
413 sp<AudioOutputDescriptor> getOutputFromId(audio_port_handle_t id) const;
414 sp<AudioInputDescriptor> getInputFromId(audio_port_handle_t id) const;
415 sp<HwModule> getModuleForDevice(audio_devices_t device) const;
416 sp<HwModule> getModuleFromName(const char *name) const;
417 audio_devices_t availablePrimaryOutputDevices();
418 audio_devices_t availablePrimaryInputDevices();
419
420 void updateCallRouting(audio_devices_t rxDevice, int delayMs = 0);
421
422
423 uid_t mUidCached;
424 AudioPolicyClientInterface *mpClientInterface; // audio policy client interface
425 audio_io_handle_t mPrimaryOutput; // primary output handle
426 // list of descriptors for outputs currently opened
427 DefaultKeyedVector<audio_io_handle_t, sp<AudioOutputDescriptor> > mOutputs;
428 // copy of mOutputs before setDeviceConnectionState() opens new outputs
429 // reset to mOutputs when updateDevicesAndOutputs() is called.
430 DefaultKeyedVector<audio_io_handle_t, sp<AudioOutputDescriptor> > mPreviousOutputs;
431 DefaultKeyedVector<audio_io_handle_t, sp<AudioInputDescriptor> > mInputs; // list of input descriptors
432 DeviceVector mAvailableOutputDevices; // all available output devices
433 DeviceVector mAvailableInputDevices; // all available input devices
434 int mPhoneState; // current phone state
435 audio_policy_forced_cfg_t mForceUse[AUDIO_POLICY_FORCE_USE_CNT]; // current forced use configuration
436
437 StreamDescriptor mStreams[AUDIO_STREAM_CNT]; // stream descriptors for volume control
438 bool mLimitRingtoneVolume; // limit ringtone volume to music volume if headset connected
439 audio_devices_t mDeviceForStrategy[NUM_STRATEGIES];
440 float mLastVoiceVolume; // last voice volume value sent to audio HAL
441
442 // Maximum CPU load allocated to audio effects in 0.1 MIPS (ARMv5TE, 0 WS memory) units
443 static const uint32_t MAX_EFFECTS_CPU_LOAD = 1000;
444 // Maximum memory allocated to audio effects in KB
445 static const uint32_t MAX_EFFECTS_MEMORY = 512;
446 uint32_t mTotalEffectsCpuLoad; // current CPU load used by effects
447 uint32_t mTotalEffectsMemory; // current memory used by effects
448 KeyedVector<int, sp<EffectDescriptor> > mEffects; // list of registered audio effects
449 bool mA2dpSuspended; // true if A2DP output is suspended
450 sp<DeviceDescriptor> mDefaultOutputDevice; // output device selected by default at boot time
451 bool mSpeakerDrcEnabled;// true on devices that use DRC on the DEVICE_CATEGORY_SPEAKER path
452 // to boost soft sounds, used to adjust volume curves accordingly
453
454 Vector < sp<HwModule> > mHwModules;
Jean-Michel Trivi56ec4ff2015-01-23 16:45:18 -0800455 volatile int32_t mAudioPortGeneration;
456
457 DefaultKeyedVector<audio_patch_handle_t, sp<AudioPatch> > mAudioPatches;
458
459 DefaultKeyedVector<audio_session_t, audio_io_handle_t> mSoundTriggerSessions;
460
461 sp<AudioPatch> mCallTxPatch;
462 sp<AudioPatch> mCallRxPatch;
463
464 // for supporting "beacon" streams, i.e. streams that only play on speaker, and never
465 // when something other than STREAM_TTS (a.k.a. "Transmitted Through Speaker") is playing
466 enum {
467 STARTING_OUTPUT,
468 STARTING_BEACON,
469 STOPPING_OUTPUT,
470 STOPPING_BEACON
471 };
472 uint32_t mBeaconMuteRefCount; // ref count for stream that would mute beacon
473 uint32_t mBeaconPlayingRefCount;// ref count for the playing beacon streams
474 bool mBeaconMuted; // has STREAM_TTS been muted
475
476 // custom mix entry in mPolicyMixes
477 class AudioPolicyMix : public RefBase {
478 public:
479 AudioPolicyMix() {}
480
481 AudioMix mMix; // Audio policy mix descriptor
482 sp<AudioOutputDescriptor> mOutput; // Corresponding output stream
483 };
484 DefaultKeyedVector<String8, sp<AudioPolicyMix> > mPolicyMixes; // list of registered mixes
485
486
487#ifdef AUDIO_POLICY_TEST
488 Mutex mLock;
489 Condition mWaitWorkCV;
490
491 int mCurOutput;
492 bool mDirectOutput;
493 audio_io_handle_t mTestOutputs[NUM_TEST_OUTPUTS];
494 int mTestInput;
495 uint32_t mTestDevice;
496 uint32_t mTestSamplingRate;
497 uint32_t mTestFormat;
498 uint32_t mTestChannels;
499 uint32_t mTestLatencyMs;
500#endif //AUDIO_POLICY_TEST
501
502 static bool isVirtualInputDevice(audio_devices_t device);
503
504 uint32_t nextAudioPortGeneration();
505private:
506 // updates device caching and output for streams that can influence the
507 // routing of notifications
508 void handleNotificationRoutingForStream(audio_stream_type_t stream);
509 static bool deviceDistinguishesOnAddress(audio_devices_t device);
510 // find the outputs on a given output descriptor that have the given address.
511 // to be called on an AudioOutputDescriptor whose supported devices (as defined
512 // in mProfile->mSupportedDevices) matches the device whose address is to be matched.
513 // see deviceDistinguishesOnAddress(audio_devices_t) for whether the device type is one
514 // where addresses are used to distinguish between one connected device and another.
515 void findIoHandlesByAddress(sp<AudioOutputDescriptor> desc /*in*/,
516 const audio_devices_t device /*in*/,
517 const String8 address /*in*/,
518 SortedVector<audio_io_handle_t>& outputs /*out*/);
519 uint32_t curAudioPortGeneration() const { return mAudioPortGeneration; }
520 // internal method to return the output handle for the given device and format
521 audio_io_handle_t getOutputForDevice(
522 audio_devices_t device,
523 audio_session_t session,
524 audio_stream_type_t stream,
525 uint32_t samplingRate,
526 audio_format_t format,
527 audio_channel_mask_t channelMask,
528 audio_output_flags_t flags,
529 const audio_offload_info_t *offloadInfo);
530 // internal function to derive a stream type value from audio attributes
531 audio_stream_type_t streamTypefromAttributesInt(const audio_attributes_t *attr);
532 // return true if any output is playing anything besides the stream to ignore
533 bool isAnyOutputActive(audio_stream_type_t streamToIgnore);
534 // event is one of STARTING_OUTPUT, STARTING_BEACON, STOPPING_OUTPUT, STOPPING_BEACON
535 // returns 0 if no mute/unmute event happened, the largest latency of the device where
536 // the mute/unmute happened
537 uint32_t handleEventForBeacon(int event);
538 uint32_t setBeaconMute(bool mute);
539 bool isValidAttributes(const audio_attributes_t *paa);
540
541 // select input device corresponding to requested audio source and return associated policy
542 // mix if any. Calls getDeviceForInputSource().
543 audio_devices_t getDeviceAndMixForInputSource(audio_source_t inputSource,
544 AudioMix **policyMix = NULL);
545
546 // Called by setDeviceConnectionState().
547 status_t setDeviceConnectionStateInt(audio_devices_t device,
548 audio_policy_dev_state_t state,
549 const char *device_address,
550 const char *device_name);
551 sp<DeviceDescriptor> getDeviceDescriptor(const audio_devices_t device,
552 const char *device_address,
553 const char *device_name);
François Gaffiead3183e2015-03-18 16:55:35 +0100554
555 bool isStrategyActive(const sp<AudioOutputDescriptor> outputDesc, routing_strategy strategy,
556 uint32_t inPastMs = 0, nsecs_t sysTime = 0) const;
Jean-Michel Trivi56ec4ff2015-01-23 16:45:18 -0800557};
558
559};