1.1 --- a/src/audio/SDL_audiocvt.c Tue Jan 17 21:18:31 2017 -0800
1.2 +++ b/src/audio/SDL_audiocvt.c Wed Jan 18 02:11:56 2017 -0500
1.3 @@ -196,31 +196,31 @@
1.4 float *last_sample, const float *inbuf,
1.5 const int inbuflen, float *outbuf, const int outbuflen)
1.6 {
1.7 - const int framelen = chans * sizeof (float);
1.8 + const int framelen = chans * (int)sizeof (float);
1.9 const int total = (inbuflen / framelen);
1.10 - const int finalpos = total - chans;
1.11 + const int finalpos = (total * chans) - chans;
1.12 + const int dest_samples = (int)(((double)total) * rate_incr);
1.13 const double src_incr = 1.0 / rate_incr;
1.14 + float *dst = outbuf;
1.15 + float *target = (dst + (dest_samples * chans));
1.16 double idx = 0.0;
1.17 - float *dst = outbuf;
1.18 - int consumed = 0;
1.19 int i;
1.20
1.21 + SDL_assert((dest_samples * framelen) <= outbuflen);
1.22 SDL_assert((inbuflen % framelen) == 0);
1.23
1.24 - while (consumed < total) {
1.25 + while(dst < target) {
1.26 const int pos = ((int)idx) * chans;
1.27 const float *src = &inbuf[(pos >= finalpos) ? finalpos : pos];
1.28 - SDL_assert(dst < (outbuf + (outbuflen / framelen)));
1.29 for (i = 0; i < chans; i++) {
1.30 const float val = *(src++);
1.31 *(dst++) = (val + last_sample[i]) * 0.5f;
1.32 last_sample[i] = val;
1.33 }
1.34 - consumed = pos + chans;
1.35 idx += src_incr;
1.36 }
1.37
1.38 - return (int) ((dst - outbuf) * sizeof (float));
1.39 + return (int) ((dst - outbuf) * (int)sizeof(float));
1.40 }
1.41
1.42