From 83454c821f591d26afd8f478313dbce64e776d6c Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 20 Jan 2017 16:26:24 -0500 Subject: [PATCH] audio: removed conditional from simple resampler's inner loop. We never seem to overflow the source buffer now; this might have been a leftover from a bug that was covered by Vitaly's fixes? Removing this conditional makes the resampler 10-20% faster. Left an assert in there for debug builds, in case this still happens. --- src/audio/SDL_audiocvt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c index 72fe2b59a59bb..a922fd3e1dbaa 100644 --- a/src/audio/SDL_audiocvt.c +++ b/src/audio/SDL_audiocvt.c @@ -209,9 +209,10 @@ SDL_ResampleAudioSimple(const int chans, const double rate_incr, SDL_assert((dest_samples * framelen) <= outbuflen); SDL_assert((inbuflen % framelen) == 0); - while(dst < target) { + while (dst < target) { const int pos = ((int)idx) * chans; - const float *src = &inbuf[(pos >= finalpos) ? finalpos : pos]; + const float *src = &inbuf[pos]; + SDL_assert(pos <= finalpos); for (i = 0; i < chans; i++) { const float val = *(src++); *(dst++) = (val + last_sample[i]) * 0.5f;