audio: Exported recommendedMuteDurationMs for output profiles
- Added muteDuration to customize mute duration while switching device's
path to avoid truncated sound at beginning.
- Muted duration will be replaced only when there are defined duration
in audio_policy_configuration.xml.
Bug: 183344508
Test: manual audio test with different audio_policy_configuration.xml,
which is with/without muteDuration definition.
Signed-off-by: Jasmine Cha <chajasmine@google.com>
Change-Id: Idced0e256a6b8e91ba2704c5ad89fbf8aba62bf5
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 6f87bf0..87f4694 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -6294,11 +6294,18 @@
// different per device volumes
if (outputDesc->isActive() && (devices != prevDevices)) {
uint32_t tempMuteWaitMs = outputDesc->latency() * 2;
- // temporary mute duration is conservatively set to 4 times the reported latency
- uint32_t tempMuteDurationMs = outputDesc->latency() * 4;
+
if (muteWaitMs < tempMuteWaitMs) {
muteWaitMs = tempMuteWaitMs;
}
+
+ // If recommended duration is defined, replace temporary mute duration to avoid
+ // truncated notifications at beginning, which depends on duration of changing path in HAL.
+ // Otherwise, temporary mute duration is conservatively set to 4 times the reported latency.
+ uint32_t tempRecommendedMuteDuration = outputDesc->getRecommendedMuteDurationMs();
+ uint32_t tempMuteDurationMs = tempRecommendedMuteDuration > 0 ?
+ tempRecommendedMuteDuration : outputDesc->latency() * 4;
+
for (const auto &activeVs : outputDesc->getActiveVolumeSources()) {
// make sure that we do not start the temporary mute period too early in case of
// delayed device change