Revert "APM: Avoid route change mute of isolated sounds"
This reverts commit 7c7124e693b20eafb4e0e86f996419c5597e0fbf.
Reason for revert: suspect for b/70332110
Change-Id: Ia19a59018c705faa9ac521353da3d417dbbfe2ef
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 89e5d77..906e05a 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -1224,12 +1224,6 @@
bool force = !outputDesc->isActive() &&
(outputDesc->getPatchHandle() == AUDIO_PATCH_HANDLE_NONE);
- // requiresMuteCheck is false when we can bypass mute strategy.
- // It covers a common case when there is no materially active audio
- // and muting would result in unnecessary delay and dropped audio.
- const uint32_t outputLatencyMs = outputDesc->latency();
- bool requiresMuteCheck = outputDesc->isActive(outputLatencyMs * 2); // account for drain
-
// increment usage count for this stream on the requested output:
// NOTE that the usage count is the same for duplicated output and hardware output which is
// necessary for a correct control of hardware output routing by startOutput() and stopOutput()
@@ -1253,44 +1247,29 @@
for (size_t i = 0; i < mOutputs.size(); i++) {
sp<AudioOutputDescriptor> desc = mOutputs.valueAt(i);
if (desc != outputDesc) {
- // An output has a shared device if
- // - managed by the same hw module
- // - supports the currently selected device
- const bool sharedDevice = outputDesc->sharesHwModuleWith(desc)
- && (desc->supportedDevices() & device) != AUDIO_DEVICE_NONE;
-
// force a device change if any other output is:
// - managed by the same hw module
- // - supports currently selected device
// - has a current device selection that differs from selected device.
+ // - supports currently selected device
// - has an active audio patch
// In this case, the audio HAL must receive the new device selection so that it can
- // change the device currently selected by the other output.
- if (sharedDevice &&
+ // change the device currently selected by the other active output.
+ if (outputDesc->sharesHwModuleWith(desc) &&
desc->device() != device &&
+ desc->supportedDevices() & device &&
desc->getPatchHandle() != AUDIO_PATCH_HANDLE_NONE) {
force = true;
}
// wait for audio on other active outputs to be presented when starting
// a notification so that audio focus effect can propagate, or that a mute/unmute
// event occurred for beacon
- const uint32_t latencyMs = desc->latency();
- const bool isActive = desc->isActive(latencyMs * 2); // account for drain
-
- if (shouldWait && isActive && (waitMs < latencyMs)) {
- waitMs = latencyMs;
+ uint32_t latency = desc->latency();
+ if (shouldWait && desc->isActive(latency * 2) && (waitMs < latency)) {
+ waitMs = latency;
}
-
- // Require mute check if another output is on a shared device
- // and currently active to have proper drain and avoid pops.
- // Note restoring AudioTracks onto this output needs to invoke
- // a volume ramp if there is no mute.
- requiresMuteCheck |= sharedDevice && isActive;
}
}
-
- const uint32_t muteWaitMs =
- setOutputDevice(outputDesc, device, force, 0, NULL, address, requiresMuteCheck);
+ uint32_t muteWaitMs = setOutputDevice(outputDesc, device, force, 0, NULL, address);
// handle special case for sonification while in call
if (isInCall()) {
@@ -1315,14 +1294,6 @@
if (waitMs > muteWaitMs) {
*delayMs = waitMs - muteWaitMs;
}
-
- // FIXME: A device change (muteWaitMs > 0) likely introduces a volume change.
- // A volume change enacted by APM with 0 delay is not synchronous, as it goes
- // via AudioCommandThread to AudioFlinger. Hence it is possible that the volume
- // change occurs after the MixerThread starts and causes a stream volume
- // glitch.
- //
- // We do not introduce additional delay here.
}
return NO_ERROR;
@@ -4841,24 +4812,21 @@
bool force,
int delayMs,
audio_patch_handle_t *patchHandle,
- const char *address,
- bool requiresMuteCheck)
+ const char* address)
{
ALOGV("setOutputDevice() device %04x delayMs %d", device, delayMs);
AudioParameter param;
uint32_t muteWaitMs;
if (outputDesc->isDuplicated()) {
- muteWaitMs = setOutputDevice(outputDesc->subOutput1(), device, force, delayMs,
- nullptr /* patchHandle */, nullptr /* address */, requiresMuteCheck);
- muteWaitMs += setOutputDevice(outputDesc->subOutput2(), device, force, delayMs,
- nullptr /* patchHandle */, nullptr /* address */, requiresMuteCheck);
+ muteWaitMs = setOutputDevice(outputDesc->subOutput1(), device, force, delayMs);
+ muteWaitMs += setOutputDevice(outputDesc->subOutput2(), device, force, delayMs);
return muteWaitMs;
}
// no need to proceed if new device is not AUDIO_DEVICE_NONE and not supported by current
// output profile
if ((device != AUDIO_DEVICE_NONE) &&
- ((device & outputDesc->supportedDevices()) == AUDIO_DEVICE_NONE)) {
+ ((device & outputDesc->supportedDevices()) == 0)) {
return 0;
}
@@ -4872,14 +4840,7 @@
if (device != AUDIO_DEVICE_NONE) {
outputDesc->mDevice = device;
}
-
- // if the outputs are not materially active, there is no need to mute.
- if (requiresMuteCheck) {
- muteWaitMs = checkDeviceMuteStrategies(outputDesc, prevDevice, delayMs);
- } else {
- ALOGV("%s: suppressing checkDeviceMuteStrategies", __func__);
- muteWaitMs = 0;
- }
+ muteWaitMs = checkDeviceMuteStrategies(outputDesc, prevDevice, delayMs);
// Do not change the routing if:
// the requested device is AUDIO_DEVICE_NONE