diff options
author | Antti S. Lankila <alankila@gmail.com> | 2010-08-03 20:08:35 +0300 |
---|---|---|
committer | Antti S. Lankila <alankila@gmail.com> | 2010-08-03 20:08:35 +0300 |
commit | 0468ca9d7f0f01767ab0d3d4557ddac93b6b2c7e (patch) | |
tree | d762291d48d076fcfe7c1905450265c7b6334d14 /libs | |
parent | 7b2fdfb5988194ee516c5a867a1106ca4d908970 (diff) | |
download | frameworks_base-0468ca9d7f0f01767ab0d3d4557ddac93b6b2c7e.zip frameworks_base-0468ca9d7f0f01767ab0d3d4557ddac93b6b2c7e.tar.gz frameworks_base-0468ca9d7f0f01767ab0d3d4557ddac93b6b2c7e.tar.bz2 |
Fix rattling of very quiet sounds
An integer truncation issue resulted in discontinuous estimates of sound
level when the audio stream sound level was very quiet.
Diffstat (limited to 'libs')
-rw-r--r-- | libs/audioflinger/AudioDSP.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libs/audioflinger/AudioDSP.cpp b/libs/audioflinger/AudioDSP.cpp index 24f99fc..639736f 100644 --- a/libs/audioflinger/AudioDSP.cpp +++ b/libs/audioflinger/AudioDSP.cpp @@ -266,12 +266,15 @@ int32_t EffectCompression::estimateLevel(const int16_t *audioData, int32_t frame { mWeighter.reset(); uint32_t power = 0; + uint32_t powerFraction = 0; for (int32_t i = 0; i < frames; i ++) { int16_t tmp = *audioData; audioData += samplesPerFrame; int32_t out = mWeighter.process(tmp) >> 12; - power += out * out >> 16; + powerFraction += out * out; + power += powerFraction >> 16; + powerFraction &= 0xffff; } return power; |