audio: removed conditional from simple resampler's inner loop.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 20 Jan 2017 16:26:24 -0500
changeset 1083092013fad89d1
parent 10829 79e882826ed4
child 10831 fcbb4d7f2344
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
     1.1 --- a/src/audio/SDL_audiocvt.c	Sun Jan 22 22:15:36 2017 +0100
     1.2 +++ b/src/audio/SDL_audiocvt.c	Fri Jan 20 16:26:24 2017 -0500
     1.3 @@ -209,9 +209,10 @@
     1.4      SDL_assert((dest_samples * framelen) <= outbuflen);
     1.5      SDL_assert((inbuflen % framelen) == 0);
     1.6  
     1.7 -    while(dst < target) {
     1.8 +    while (dst < target) {
     1.9          const int pos = ((int)idx) * chans;
    1.10 -        const float *src = &inbuf[(pos >= finalpos) ? finalpos : pos];
    1.11 +        const float *src = &inbuf[pos];
    1.12 +        SDL_assert(pos <= finalpos);
    1.13          for (i = 0; i < chans; i++) {
    1.14              const float val = *(src++);
    1.15              *(dst++) = (val + last_sample[i]) * 0.5f;