Extend downsampling ratios greater than 2:1
Also improve robustness to choice of sampling rate or buffer size
such that increasing either by 10x does not cause overflow.
Bug: 12979141
Bug: 15933066
Change-Id: If7989bd745d1bee3bdf811b8b7c978543ccafb65
diff --git a/services/audioflinger/AudioResamplerDyn.cpp b/services/audioflinger/AudioResamplerDyn.cpp
index 159ab70..0eeb201 100644
--- a/services/audioflinger/AudioResamplerDyn.cpp
+++ b/services/audioflinger/AudioResamplerDyn.cpp
@@ -393,7 +393,7 @@
mPhaseFraction = static_cast<unsigned long long>(mPhaseFraction)
* phaseWrapLimit / oldPhaseWrapLimit;
mPhaseFraction %= phaseWrapLimit; // should not do anything, but just in case.
- mPhaseIncrement = static_cast<uint32_t>(static_cast<double>(phaseWrapLimit)
+ mPhaseIncrement = static_cast<uint32_t>(static_cast<uint64_t>(phaseWrapLimit)
* inSampleRate / mSampleRate);
// determine which resampler to use