diff options
author | Eric Laurent <elaurent@google.com> | 2012-11-07 12:09:54 -0800 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2012-11-07 13:48:47 -0800 |
commit | 42fa8215a763822c0d03fc936e4cac1eb864c9cc (patch) | |
tree | 331cffff444ef07fcffc4fed1d45364511aacd48 /audio | |
parent | 6062eb0756cb94cd164223f5961091b78fcc43d4 (diff) | |
download | hardware_libhardware_legacy-42fa8215a763822c0d03fc936e4cac1eb864c9cc.zip hardware_libhardware_legacy-42fa8215a763822c0d03fc936e4cac1eb864c9cc.tar.gz hardware_libhardware_legacy-42fa8215a763822c0d03fc936e4cac1eb864c9cc.tar.bz2 |
audio policy: fix notification start delay
The mechanism delaying notifications in case of
muliple active outputs with long latencies must
take into account recently paused audio tracks.
Bug 7400428.
Change-Id: I4ac9dfac81336e33f475b4f28df82713707d0c46
Diffstat (limited to 'audio')
-rw-r--r-- | audio/AudioPolicyManagerBase.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/audio/AudioPolicyManagerBase.cpp b/audio/AudioPolicyManagerBase.cpp index 4849041..4d63cbc 100644 --- a/audio/AudioPolicyManagerBase.cpp +++ b/audio/AudioPolicyManagerBase.cpp @@ -348,7 +348,7 @@ void AudioPolicyManagerBase::setPhoneState(int state) for (size_t i = 0; i < mOutputs.size(); i++) { AudioOutputDescriptor *desc = mOutputs.valueAt(i); //take the biggest latency for all outputs - if (delayMs < desc->mLatency*2) { + if (delayMs < (int)desc->mLatency*2) { delayMs = desc->mLatency*2; } //mute STRATEGY_MEDIA on all outputs @@ -702,8 +702,9 @@ status_t AudioPolicyManagerBase::startOutput(audio_io_handle_t output, } // wait for audio on other active outputs to be presented when starting // a notification so that audio focus effect can propagate. - if (shouldWait && (desc->refCount() != 0) && (waitMs < desc->latency())) { - waitMs = desc->latency(); + uint32_t latency = desc->latency(); + if (shouldWait && desc->isActive(latency * 2) && (waitMs < latency)) { + waitMs = latency; } } } @@ -3064,6 +3065,18 @@ audio_devices_t AudioPolicyManagerBase::AudioOutputDescriptor::supportedDevices( } } +bool AudioPolicyManagerBase::AudioOutputDescriptor::isActive(uint32_t inPastMs) const +{ + nsecs_t sysTime = systemTime(); + for (int i = 0; i < AudioSystem::NUM_STREAM_TYPES; i++) { + if (mRefCount[i] != 0 || + ns2ms(sysTime - mStopTime[i]) < inPastMs) { + return true; + } + } + return false; +} + status_t AudioPolicyManagerBase::AudioOutputDescriptor::dump(int fd) { const size_t SIZE = 256; |