summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2017-06-06 14:41:13 -0700
committerDan Pasanen <dan.pasanen@gmail.com>2017-09-15 10:28:51 -0500
commitafc7e48d9ca4019d8e106732d2500fa33b4035ff (patch)
tree0d0e8e8baa47ac79dac25b0c8b6a591930333a3f
parent2b8b07da239ec5cec2583f0b8cdecf296c920f33 (diff)
downloadandroid_external_sonivox-afc7e48d9ca4019d8e106732d2500fa33b4035ff.tar.gz
android_external_sonivox-afc7e48d9ca4019d8e106732d2500fa33b4035ff.tar.bz2
android_external_sonivox-afc7e48d9ca4019d8e106732d2500fa33b4035ff.zip
Fix interpolator
If the phase increment was larger than the loop size, the interpolator would read further and further outside the sample, eventually segfaulting. Bug: 38342499 Test: manual Change-Id: I0e70d037e61fdeffdbd49460caa692e9781cc511 (cherry picked from commit d19edc9c090d64926469463991ca7e86c73368fa)
-rw-r--r--arm-wt-22k/lib_src/eas_wtsynth.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/arm-wt-22k/lib_src/eas_wtsynth.c b/arm-wt-22k/lib_src/eas_wtsynth.c
index 9fcda7b..8488fe2 100644
--- a/arm-wt-22k/lib_src/eas_wtsynth.c
+++ b/arm-wt-22k/lib_src/eas_wtsynth.c
@@ -28,6 +28,7 @@
*/
// includes
+#define LOG_TAG "SYNTH"
#include "log/log.h"
#include <cutils/log.h>
@@ -557,6 +558,14 @@ static EAS_BOOL WT_UpdateVoice (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, S_SYNTH
else
temp += (pVoice->note + pSynth->globalTranspose) * 100;
intFrame.frame.phaseIncrement = WT_UpdatePhaseInc(pWTVoice, pArt, pChannel, temp);
+ temp = pWTVoice->loopEnd - pWTVoice->loopStart;
+ if (temp != 0) {
+ temp = temp << NUM_PHASE_FRAC_BITS;
+ if (intFrame.frame.phaseIncrement > temp) {
+ ALOGW("%p phaseIncrement=%d", pWTVoice, (int)intFrame.frame.phaseIncrement);
+ intFrame.frame.phaseIncrement %= temp;
+ }
+ }
/* call into engine to generate samples */
intFrame.pAudioBuffer = pVoiceMgr->voiceBuffer;