diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2013-02-04 16:28:31 -0800 |
---|---|---|
committer | Jean-Michel Trivi <jmtrivi@google.com> | 2013-02-11 10:23:13 -0800 |
commit | dc3bf1a37425697277f6ed04fc8cfe4a52fd678a (patch) | |
tree | 334f0eaf23e510915f96287063240dd418de977b /audio/AudioPolicyManagerBase.cpp | |
parent | 60758e27a4be8fc9ac1180f8a4055234e1702cc9 (diff) | |
download | hardware_libhardware_legacy-dc3bf1a37425697277f6ed04fc8cfe4a52fd678a.zip hardware_libhardware_legacy-dc3bf1a37425697277f6ed04fc8cfe4a52fd678a.tar.gz hardware_libhardware_legacy-dc3bf1a37425697277f6ed04fc8cfe4a52fd678a.tar.bz2 |
Identify remote stream activity, used for notification routing
Add support for checking remote stream activity.
Don't route notifications like media when media active remotely.
Add remote stream activity query in audio policy HAL.
Bug 7485803
Change-Id: Ifb722c7f9ffbfbdc877fec5156bcfc09bec40651
Diffstat (limited to 'audio/AudioPolicyManagerBase.cpp')
-rw-r--r-- | audio/AudioPolicyManagerBase.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/audio/AudioPolicyManagerBase.cpp b/audio/AudioPolicyManagerBase.cpp index 2b37883..7fc1c1a 100644 --- a/audio/AudioPolicyManagerBase.cpp +++ b/audio/AudioPolicyManagerBase.cpp @@ -27,6 +27,9 @@ // A device mask for all audio input devices that are considered "virtual" when evaluating // active inputs in getActiveInput() #define APM_AUDIO_IN_DEVICE_VIRTUAL_ALL AUDIO_DEVICE_IN_REMOTE_SUBMIX +// A device mask for all audio output devices that are considered "remote" when evaluating +// active output devices in isStreamActiveRemotely() +#define APM_AUDIO_OUT_DEVICE_REMOTE_ALL AUDIO_DEVICE_OUT_REMOTE_SUBMIX #include <utils/Log.h> #include <hardware_legacy/AudioPolicyManagerBase.h> @@ -1178,6 +1181,20 @@ bool AudioPolicyManagerBase::isStreamActive(int stream, uint32_t inPastMs) const return false; } +bool AudioPolicyManagerBase::isStreamActiveRemotely(int stream, uint32_t inPastMs) const +{ + nsecs_t sysTime = systemTime(); + for (size_t i = 0; i < mOutputs.size(); i++) { + const AudioOutputDescriptor *outputDesc = mOutputs.valueAt(i); + if ((outputDesc->mRefCount[stream] != 0 || + ns2ms(sysTime - outputDesc->mStopTime[stream]) < inPastMs) + && ((outputDesc->device() & APM_AUDIO_OUT_DEVICE_REMOTE_ALL) != 0) ) { + return true; + } + } + return false; +} + bool AudioPolicyManagerBase::isSourceActive(audio_source_t source) const { for (size_t i = 0; i < mInputs.size(); i++) { @@ -2083,6 +2100,13 @@ audio_devices_t AudioPolicyManagerBase::getDeviceForStrategy(routing_strategy st case STRATEGY_SONIFICATION_RESPECTFUL: if (isInCall()) { device = getDeviceForStrategy(STRATEGY_SONIFICATION, false /*fromCache*/); + } else if (isStreamActiveRemotely(AudioSystem::MUSIC, + SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY)) { + // while media is playing on a remote device, use the the sonification behavior. + // Note that we test this usecase before testing if media is playing because + // the isStreamActive() method only informs about the activity of a stream, not + // if it's for local playback. Note also that we use the same delay between both tests + device = getDeviceForStrategy(STRATEGY_SONIFICATION, false /*fromCache*/); } else if (isStreamActive(AudioSystem::MUSIC, SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY)) { // while media is playing (or has recently played), use the same device device = getDeviceForStrategy(STRATEGY_MEDIA, false /*fromCache*/); @@ -2991,7 +3015,7 @@ AudioPolicyManagerBase::AudioOutputDescriptor::AudioOutputDescriptor( } } -audio_devices_t AudioPolicyManagerBase::AudioOutputDescriptor::device() +audio_devices_t AudioPolicyManagerBase::AudioOutputDescriptor::device() const { if (isDuplicated()) { return (audio_devices_t)(mOutput1->mDevice | mOutput2->mDevice); |