Skip to content

Commit

Permalink
audio: don't cast to double in SDL_ConvertStereoToMono().
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
icculus committed Jan 23, 2017
1 parent 83454c8 commit a7f86f2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/audio/SDL_audiocvt.c
Expand Up @@ -41,7 +41,7 @@ SDL_ConvertStereoToMono(SDL_AudioCVT * cvt, SDL_AudioFormat format)
SDL_assert(format == AUDIO_F32SYS);

for (i = cvt->len_cvt / 8; i; --i, src += 2) {
*(dst++) = (float) ((((double) src[0]) + ((double) src[1])) * 0.5);
*(dst++) = (src[0] + src[1]) * 0.5f;
}

cvt->len_cvt /= 2;
Expand Down

0 comments on commit a7f86f2

Please sign in to comment.