Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixed S32 audio mixing, but I'm a bit nervous about the use of 64-bit

 datatypes here...
  • Loading branch information
icculus committed Sep 1, 2006
1 parent 40ccd5c commit 01b8dba8432a772318d35507d81e902a90967627
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/audio/SDL_mixer.c
@@ -261,17 +261,17 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
{
const Uint32 *src32 = (Uint32 *) src;
Uint32 *dst32 = (Uint32 *) dst;
Sint32 src1, src2;
Sint64 src1, src2;
Sint64 dst_sample;
const Sint64 max_audioval = ((((Sint64) 1) << (32 - 1)) - 1);
const Sint64 min_audioval = -(((Sint64) 1) << (32 - 1));

len /= 4;
while (len--) {
src1 = (Sint32) SDL_SwapLE32(*src32);
src1 = (Sint64) ((Sint32) SDL_SwapLE32(*src32));
src32++;
ADJUST_VOLUME(src1, volume);
src2 = (Sint32) SDL_SwapLE32(*dst32);
src2 = (Sint64) ((Sint32) SDL_SwapLE32(*dst32));
dst_sample = src1 + src2;
if (dst_sample > max_audioval) {
dst_sample = max_audioval;
@@ -287,17 +287,17 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
{
const Uint32 *src32 = (Uint32 *) src;
Uint32 *dst32 = (Uint32 *) dst;
Sint32 src1, src2;
Sint64 src1, src2;
Sint64 dst_sample;
const Sint64 max_audioval = ((((Sint64) 1) << (32 - 1)) - 1);
const Sint64 min_audioval = -(((Sint64) 1) << (32 - 1));

len /= 4;
while (len--) {
src1 = (Sint32) SDL_SwapBE32(*src32);
src1 = (Sint64) ((Sint32) SDL_SwapBE32(*src32));
src32++;
ADJUST_VOLUME(src1, volume);
src2 = (Sint32) SDL_SwapBE32(*dst32);
src2 = (Sint64) ((Sint32) SDL_SwapBE32(*dst32));
dst_sample = src1 + src2;
if (dst_sample > max_audioval) {
dst_sample = max_audioval;

0 comments on commit 01b8dba

Please sign in to comment.