hal: Fix teardown during back to back pause/play of WFD session
- When an active WFD session is paused/played continuously from
the WFDClient app, the session tears down after a few iterations
if touch tones are enabled.
- The output device is switched back and forth between speaker and
proxy when the session is paused and played continuously.
When this happens, sometimes, there is no backend to write the
low latency output which results in pcm_write getting blocked.
- Fix the issue by not routing the low latency output to speaker
if the previous device is proxy.
CRs-Fixed: 630234
Change-Id: I6bbe82badd3d5ee857e920430304c3a45c5b44c7
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index 303540c..b679fdb 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -233,8 +233,16 @@
// do not force device change on duplicated output because if device is 0, it will
// also force a device 0 for the two outputs it is duplicated to which may override
// a valid device selection on those outputs.
+ audio_devices_t cachedDevice = getNewDevice(mOutputs.keyAt(i), true /*fromCache*/);
+ AudioOutputDescriptor *desc = mOutputs.valueFor(mOutputs.keyAt(i));
+ if (cachedDevice == AUDIO_DEVICE_OUT_SPEAKER &&
+ device == AUDIO_DEVICE_OUT_PROXY &&
+ (desc->mFlags & AUDIO_OUTPUT_FLAG_FAST)) {
+ ALOGI("Avoid routing touch tone to spkr as proxy is being disconnected");
+ break;
+ }
setOutputDevice(mOutputs.keyAt(i),
- getNewDevice(mOutputs.keyAt(i), true /*fromCache*/),
+ cachedDevice,
!mOutputs.valueAt(i)->isDuplicated(),
0);
}