libaudioprocessing: clamp application provided float audio

For security reason, float buffers provided by application must be
clamped to FLOAT_NOMINAL_RANGE_HEADROOM.
With the new all float pipeline, float are no longer clamped by their
conversion to fixed point.

This patch adds a float buffer provider that clamps float samples
as they are copied to audio pipeline.

Test: Play music, play video in chrome (opensles format float),
      play float pcm audio file specially crafter with >> 1 samples.
Bug: 68099072
Change-Id: I220b436d9982bc43a75715a030efd0e6a0c79fa3
Signed-off-by: Kevin Rocard <krocard@google.com>
diff --git a/media/libaudioprocessing/AudioMixer.cpp b/media/libaudioprocessing/AudioMixer.cpp
index 93ed5f2..852252d 100644
--- a/media/libaudioprocessing/AudioMixer.cpp
+++ b/media/libaudioprocessing/AudioMixer.cpp
@@ -314,6 +314,14 @@
                 targetFormat,
                 kCopyBufferFrameCount));
         requiresReconfigure = true;
+    } else if (mFormat == AUDIO_FORMAT_PCM_FLOAT) {
+        // Input and output are floats, make sure application did not provide > 3db samples
+        // that would break volume application (b/68099072)
+        // TODO: add a trusted source flag to avoid the overhead
+        mReformatBufferProvider.reset(new ClampFloatBufferProvider(
+                audio_channel_count_from_out_mask(channelMask),
+                kCopyBufferFrameCount));
+        requiresReconfigure = true;
     }
     if (targetFormat != mMixerInFormat) {
         mPostDownmixReformatBufferProvider.reset(new ReformatBufferProvider(