summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhou Song <zhous@codeaurora.org>2015-09-21 14:36:57 +0800
committerZhou Song <zhous@codeaurora.org>2015-10-21 13:41:04 +0800
commit16571b01a505b68f2b2e22af278cb4ef717d244c (patch)
treeb550de6a14776a627e64931e44f1c28f0abd874b
parentd86aedabfee4235c02a1e2c477532b809847d43c (diff)
downloadhardware_qcom_audio-16571b01a505b68f2b2e22af278cb4ef717d244c.tar.gz
hardware_qcom_audio-16571b01a505b68f2b2e22af278cb4ef717d244c.tar.bz2
hardware_qcom_audio-16571b01a505b68f2b2e22af278cb4ef717d244c.zip
audio_policy: Add extra check before restoring device in stopOutput
When certain game apks run with sound enabled, UI lag will be observed. This is due to device to be restored with double HAL latency even when it's the same with the previous device, since setOutputDevice is synchronous call now, then it will block the subsequent calling to APM until the latency time elapsed. When the device to be restored is the same as previous device, set the latency to 0. Ported from Change-Id: I2c92675cedd8930430f81147c7f733d8dd70798c Conflicts: policy_hal/AudioPolicyManager.cpp Change-Id: I4582cdc98f4cf8189d89b648e5c3f6e0ce8089ab
-rw-r--r--policy_hal/AudioPolicyManager.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index be41bd97..c5b2e8e2 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -928,6 +928,7 @@ status_t AudioPolicyManagerCustom::stopSource(sp<SwAudioOutputDescriptor> output
// store time at which the stream was stopped - see isStreamActive()
if (outputDesc->mRefCount[stream] == 0 || forceDeviceUpdate) {
outputDesc->mStopTime[stream] = systemTime();
+ audio_devices_t prevDevice = outputDesc->device();
audio_devices_t newDevice = getNewOutputDevice(outputDesc, false /*fromCache*/);
// delay the device switch by twice the latency because stopOutput() is executed when
// the track stop() command is received and at that time the audio track buffer can
@@ -946,10 +947,16 @@ status_t AudioPolicyManagerCustom::stopSource(sp<SwAudioOutputDescriptor> output
outputDesc->sharesHwModuleWith(desc) &&
(newDevice != desc->device())) {
audio_devices_t dev = getNewOutputDevice(mOutputs.valueFor(curOutput), false /*fromCache*/);
+ uint32_t delayMs;
+ if (dev == prevDevice) {
+ delayMs = 0;
+ } else {
+ delayMs = outputDesc->mLatency*2;
+ }
setOutputDevice(desc,
dev,
true,
- outputDesc->latency()*2);
+ delayMs);
}
}
// update the outputs if stopping one with a stream that can affect notification routing