audiopolicy: update correct device for primary output when FM resumed
When FM resumed after notification tone played, device updated for
primary output is still headset and speaker. This makes the device
to be switched back to headset and speaker after FM started on headset,
and temp mute can be applied for FM as new device changed from combo
device to headset when stopOutput() called for notificaton tone playback.
Update device for all outputs after FM started, and update the current
device of FM playback for primary output to avoid unnecessary temp mute.
Change-Id: I41badee6fb11e8c4574daa8042e38262a41b7735
CRs-Fixed: 1008864
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index 2299e3f..b89c82c 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -297,17 +297,6 @@
checkA2dpSuspend();
}
- updateDevicesAndOutputs();
-#ifdef DOLBY_ENABLE
- // Before closing the opened outputs, update endpoint property with device capabilities
- audio_devices_t audioOutputDevice = getDeviceForStrategy(getStrategy(AUDIO_STREAM_MUSIC), true);
- mDolbyAudioPolicy.setEndpointSystemProperty(audioOutputDevice, mHwModules);
-#endif // DOLBY_END
- if (mEngine->getPhoneState() == AUDIO_MODE_IN_CALL && hasPrimaryOutput()) {
- audio_devices_t newDevice = getNewOutputDevice(mPrimaryOutput, false /*fromCache*/);
- updateCallRouting(newDevice);
- }
-
#ifdef FM_POWER_OPT
// handle FM device connection state to trigger FM AFE loopback
if (device == AUDIO_DEVICE_OUT_FM && hasPrimaryOutput()) {
@@ -316,6 +305,7 @@
mPrimaryOutput->changeRefCount(AUDIO_STREAM_MUSIC, 1);
newDevice = (audio_devices_t)(getNewOutputDevice(mPrimaryOutput, false)|AUDIO_DEVICE_OUT_FM);
mFMIsActive = true;
+ mPrimaryOutput->mDevice = newDevice & ~AUDIO_DEVICE_OUT_FM;
} else {
newDevice = (audio_devices_t)(getNewOutputDevice(mPrimaryOutput, false));
mFMIsActive = false;
@@ -327,6 +317,17 @@
}
#endif /* FM_POWER_OPT end */
+ updateDevicesAndOutputs();
+#ifdef DOLBY_ENABLE
+ // Before closing the opened outputs, update endpoint property with device capabilities
+ audio_devices_t audioOutputDevice = getDeviceForStrategy(getStrategy(AUDIO_STREAM_MUSIC), true);
+ mDolbyAudioPolicy.setEndpointSystemProperty(audioOutputDevice, mHwModules);
+#endif // DOLBY_END
+ if (mEngine->getPhoneState() == AUDIO_MODE_IN_CALL && hasPrimaryOutput()) {
+ audio_devices_t newDevice = getNewOutputDevice(mPrimaryOutput, false /*fromCache*/);
+ updateCallRouting(newDevice);
+ }
+
for (size_t i = 0; i < mOutputs.size(); i++) {
sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i);
if ((mEngine->getPhoneState() != AUDIO_MODE_IN_CALL) || (desc != mPrimaryOutput)) {