audiopolicy: fix voice volume mismatch after headset removal.

During voice call, when headset is removed, 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 calculate volume in new device, due to inactive output
selects AUDIO_DEVICE_NONE, it uses previous device and set wrong
voice volume.

Fix it by add check to avoid applying volume for inactive output.

Bug: 111196161
Test: manual audio smoke tests.

Change-Id: I4dcc9f6d3442ce5a0a8235c04b4156ad17d373db
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index e721a78..8d11c16 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -272,7 +272,8 @@
                 mEngine->getActiveMediaDevices(mAvailableOutputDevices);
         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