Audio HAL: A volume/gain outside of [0,1] is an error

Hals are supposed to received normalized volumes, between 0 and 1.
Previously volumes outside [0,1] were clamp to this range.
This clamping has the capability to hide bugs thus return an error if
such volume is received.

Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: Ia4880bdff6111cbcdae6a4ebee921eddae141ee4
Signed-off-by: Kevin Rocard <krocard@google.com>
diff --git a/audio/2.0/default/StreamIn.cpp b/audio/2.0/default/StreamIn.cpp
index 9feef15..abd0497 100644
--- a/audio/2.0/default/StreamIn.cpp
+++ b/audio/2.0/default/StreamIn.cpp
@@ -24,6 +24,7 @@
 #include <memory>
 
 #include "StreamIn.h"
+#include "Util.h"
 
 using ::android::hardware::audio::V2_0::MessageQueueFlagBits;
 
@@ -311,6 +312,10 @@
 }
 
 Return<Result> StreamIn::setGain(float gain) {
+    if (!isGainNormalized(gain)) {
+        ALOGW("Can not set a stream input gain (%f) outside [0,1]", gain);
+        return Result::INVALID_ARGUMENTS;
+    }
     return Stream::analyzeStatus("set_gain", mStream->set_gain(mStream, gain));
 }