summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2012-11-07 12:09:54 -0800
committerEric Laurent <elaurent@google.com>2012-11-08 09:46:10 -0800
commita7c17deb32fe28230b77b0dff17bb113088a5c16 (patch)
tree257e3dcf4801f649618a44c453253c016d953903
parentfe43d163d6646a175934f0752fa05e3e53e89da4 (diff)
downloadhardware_libhardware_legacy-a7c17deb32fe28230b77b0dff17bb113088a5c16.zip
hardware_libhardware_legacy-a7c17deb32fe28230b77b0dff17bb113088a5c16.tar.gz
hardware_libhardware_legacy-a7c17deb32fe28230b77b0dff17bb113088a5c16.tar.bz2
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
-rw-r--r--audio/AudioPolicyManagerBase.cpp19
-rw-r--r--include/hardware_legacy/AudioPolicyManagerBase.h1
2 files changed, 17 insertions, 3 deletions
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;
diff --git a/include/hardware_legacy/AudioPolicyManagerBase.h b/include/hardware_legacy/AudioPolicyManagerBase.h
index 451fe8a..b175670 100644
--- a/include/hardware_legacy/AudioPolicyManagerBase.h
+++ b/include/hardware_legacy/AudioPolicyManagerBase.h
@@ -250,6 +250,7 @@ protected:
audio_devices_t supportedDevices();
uint32_t latency();
bool sharesHwModuleWith(const AudioOutputDescriptor *outputDesc);
+ bool isActive(uint32_t inPastMs) const;
audio_io_handle_t mId; // output handle
uint32_t mSamplingRate; //