From a7c17deb32fe28230b77b0dff17bb113088a5c16 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Wed, 7 Nov 2012 12:09:54 -0800 Subject: audio policy: notification delay - DO NOT MERGE merge from master: "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 --- audio/AudioPolicyManagerBase.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'audio') diff --git a/audio/AudioPolicyManagerBase.cpp b/audio/AudioPolicyManagerBase.cpp index 19fff57..134fb3b 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; } } } @@ -3065,6 +3066,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; -- cgit v1.2.3