audio policy: fix media volume after ringtone

Fix regression introduced by commit 11c499a5 causing
music volume not to be restored after ringtone playback
over duplicated output (speaker + A2DP).

Bug: 31539910

Change-Id: I1c4eebea1f1a8f82ae2acfeecb9a61c437a74e25
(cherry picked from commit 57de36ccd1f524d602d267884bdcfae8559a6e6a)
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index cc76ce1..ac4ea87 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -1315,6 +1315,7 @@
 
             // force restoring the device selection on other active outputs if it differs from the
             // one being selected for this output
+            uint32_t delayMs = outputDesc->latency()*2;
             for (size_t i = 0; i < mOutputs.size(); i++) {
                 sp<AudioOutputDescriptor> desc = mOutputs.valueAt(i);
                 if (desc != outputDesc &&
@@ -1326,7 +1327,11 @@
                     setOutputDevice(desc,
                                     newDevice2,
                                     force,
-                                    outputDesc->latency()*2);
+                                    delayMs);
+                    // re-apply device specific volume if not done by setOutputDevice()
+                    if (!force) {
+                        applyStreamVolumes(desc, newDevice2, delayMs);
+                    }
                 }
             }
             // update the outputs if stopping one with a stream that can affect notification routing