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