Add floating point volume handling to AudioMixer

Use floating point volume in AudioMixer mixing when floating
point input is used with the new mixer engine.
AudioResampler is updated to take floating point volume to match.
Both legacy integer and floating point mixer engines work.

For now, integer volume is used when the new mixer engine
runs in integer input mode, for backward compatibility with
the legacy mixer.  The new mixer engine will generally run in
floating point input mode. When the legacy path is removed,
the integer volumes will be removed.

Change-Id: I79e80c292ae7c8b8bdd0aa371a1b2c3a1b618290
diff --git a/services/audioflinger/AudioResamplerSinc.cpp b/services/audioflinger/AudioResamplerSinc.cpp
index 60ff88e..d03e578 100644
--- a/services/audioflinger/AudioResamplerSinc.cpp
+++ b/services/audioflinger/AudioResamplerSinc.cpp
@@ -27,6 +27,7 @@
 #include <cutils/properties.h>
 
 #include <utils/Log.h>
+#include <audio_utils/primitives.h>
 
 #include "AudioResamplerSinc.h"
 
@@ -500,10 +501,12 @@
     mRingFull = mImpulse + (numCoefs+1)*mChannelCount;
 }
 
-void AudioResamplerSinc::setVolume(int16_t left, int16_t right) {
+void AudioResamplerSinc::setVolume(float left, float right) {
     AudioResampler::setVolume(left, right);
-    mVolumeSIMD[0] = int32_t(left)<<16;
-    mVolumeSIMD[1] = int32_t(right)<<16;
+    // convert to U4_28 (rounding down).
+    // integer volume values are clamped to 0 to UNITY_GAIN.
+    mVolumeSIMD[0] = u4_28_from_float(clampFloatVol(left));
+    mVolumeSIMD[1] = u4_28_from_float(clampFloatVol(right));
 }
 
 void AudioResamplerSinc::resample(int32_t* out, size_t outFrameCount,