policy: fix voice volume is mismatch after headset remove
During voice call, when headset remove, new device of primary
output is first set to handset, and voice volume is also
calculated in handset. Later other outputs loop to select new
device and caculate volume in new device. Due to inactive output
selectes AUDIO_DEVICE_NONE, it uses previous device and set wrong
voice volume.
Fix it by add check to avoid applying volume for inactive output.
Change-Id: Icc0dd9e1f00cafd6548d20c678c882e770effc0d
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index 5483b5e..4660e12 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -322,7 +322,8 @@
const DeviceVector msdOutDevices = getMsdAudioOutDevices();
for (size_t i = 0; i < mOutputs.size(); i++) {
sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i);
- if ((mEngine->getPhoneState() != AUDIO_MODE_IN_CALL) || (desc != mPrimaryOutput)) {
+ if (desc->isActive() && ((mEngine->getPhoneState() != AUDIO_MODE_IN_CALL) ||
+ (desc != mPrimaryOutput))) {
DeviceVector newDevices = getNewOutputDevices(desc, true /*fromCache*/);
// 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