Fix clamp issue with AudioMixer with float input and int16 output
Bug: 20706338
Change-Id: I7e3ab0da96901870cc57fbe2e79163bc81157465
diff --git a/services/audioflinger/AudioMixerOps.h b/services/audioflinger/AudioMixerOps.h
index 2678857..8d74024 100644
--- a/services/audioflinger/AudioMixerOps.h
+++ b/services/audioflinger/AudioMixerOps.h
@@ -164,13 +164,12 @@
template <>
inline int16_t MixMul<int16_t, int16_t, float>(int16_t value, float volume) {
LOG_ALWAYS_FATAL("MixMul<int16_t, int16_t, float> Runtime Should not be here");
- return value * volume;
+ return clamp16_from_float(MixMul<float, int16_t, float>(value, volume));
}
template <>
inline int16_t MixMul<int16_t, float, float>(float value, float volume) {
- static const float q_15_from_float = (1 << 15);
- return value * volume * q_15_from_float;
+ return clamp16_from_float(value * volume);
}
/*