audio policy: fix beacon mute delay
Only take output latency into account when the output is active
when muting TTS stream. This avoid a systematic long delay the
first time we play audio due to first beacon mute state change.
Bug: 37923452
Test: repro steps in bug
Change-Id: I10b21a55c0fad28344108b67756f600a29e41fea
(cherry picked from commit cdb2b35c0f159a1a244599010ee9210d1e34c71d)
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index c5c13e9..14c5a5c 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -5648,7 +5648,7 @@
sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i);
setVolumeSourceMute(ttsVolumeSource, mute/*on*/, desc, 0 /*delay*/, DeviceTypeSet());
const uint32_t latency = desc->latency() * 2;
- if (latency > maxLatency) {
+ if (desc->isActive(latency * 2) && latency > maxLatency) {
maxLatency = latency;
}
}