diff --git a/src/audio/SDL_audiotypecvt.c b/src/audio/SDL_audiotypecvt.c index fe8a89f7a..264ce9828 100644 --- a/src/audio/SDL_audiotypecvt.c +++ b/src/audio/SDL_audiotypecvt.c @@ -171,9 +171,9 @@ SDL_Convert_F32_to_S8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) { const float sample = *src; - if (sample > 1.0f) { + if (sample >= 1.0f) { *dst = 127; - } else if (sample < -1.0f) { + } else if (sample <= -1.0f) { *dst = -127; } else { *dst = (Sint8)(sample * 127.0f); @@ -197,9 +197,9 @@ SDL_Convert_F32_to_U8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) { const float sample = *src; - if (sample > 1.0f) { + if (sample >= 1.0f) { *dst = 255; - } else if (sample < -1.0f) { + } else if (sample <= -1.0f) { *dst = 0; } else { *dst = (Uint8)((sample + 1.0f) * 127.0f); @@ -223,9 +223,9 @@ SDL_Convert_F32_to_S16_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) { const float sample = *src; - if (sample > 1.0f) { + if (sample >= 1.0f) { *dst = 32767; - } else if (sample < -1.0f) { + } else if (sample <= -1.0f) { *dst = -32767; } else { *dst = (Sint16)(sample * 32767.0f); @@ -249,9 +249,9 @@ SDL_Convert_F32_to_U16_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) { const float sample = *src; - if (sample > 1.0f) { + if (sample >= 1.0f) { *dst = 65534; - } else if (sample < -1.0f) { + } else if (sample <= -1.0f) { *dst = 0; } else { *dst = (Uint16)((sample + 1.0f) * 32767.0f); @@ -275,9 +275,9 @@ SDL_Convert_F32_to_S32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) { const float sample = *src; - if (sample > 1.0f) { + if (sample >= 1.0f) { *dst = 2147483647; - } else if (sample < -1.0f) { + } else if (sample <= -1.0f) { *dst = -2147483647; } else { *dst = ((Sint32)(sample * 8388607.0f)) << 8;