audio: don't cast to double in SDL_ConvertStereoToMono().
authorRyan C. Gordon <icculus@icculus.org>
Sun, 22 Jan 2017 20:18:59 -0500
changeset 10831fcbb4d7f2344
parent 10830 92013fad89d1
child 10832 189266031c6f
audio: don't cast to double in SDL_ConvertStereoToMono().

It's expensive and (hopefully) unnecessary. If this becomes an overflow
problem, we could multiply both values by 0.5f before adding them, but let's
see if we can get by without the extra multiplication first.
src/audio/SDL_audiocvt.c
     1.1 --- a/src/audio/SDL_audiocvt.c	Fri Jan 20 16:26:24 2017 -0500
     1.2 +++ b/src/audio/SDL_audiocvt.c	Sun Jan 22 20:18:59 2017 -0500
     1.3 @@ -41,7 +41,7 @@
     1.4      SDL_assert(format == AUDIO_F32SYS);
     1.5  
     1.6      for (i = cvt->len_cvt / 8; i; --i, src += 2) {
     1.7 -        *(dst++) = (float) ((((double) src[0]) + ((double) src[1])) * 0.5);
     1.8 +        *(dst++) = (src[0] + src[1]) * 0.5f;
     1.9      }
    1.10  
    1.11      cvt->len_cvt /= 2;