Skip to content

Commit

Permalink
audio: removed conditional from simple resampler's inner loop.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
icculus committed Jan 20, 2017
1 parent 4f981df commit 83454c8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/audio/SDL_audiocvt.c
Expand Up @@ -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;
Expand Down

0 comments on commit 83454c8

Please sign in to comment.