From 47f6ae74698065de2df018036d9ab4208058da56 Mon Sep 17 00:00:00 2001 From: cyberwarriorx Date: Sun, 12 Nov 2006 21:34:54 +0000 Subject: [PATCH] -Doh! Fixed another sound buffering bug, this time in the linux port --- trunk/desmume/src/sndsdl.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/trunk/desmume/src/sndsdl.c b/trunk/desmume/src/sndsdl.c index 48611344a..815045f94 100644 --- a/trunk/desmume/src/sndsdl.c +++ b/trunk/desmume/src/sndsdl.c @@ -25,7 +25,7 @@ #include "sndsdl.h" #include "debug.h" -int SNDSDLInit(); +int SNDSDLInit(int buffersize); void SNDSDLDeInit(); void SNDSDLUpdateAudio(s16 *buffer, u32 num_samples); u32 SNDSDLGetAudioSpace(); @@ -45,8 +45,6 @@ SNDSDLUnMuteAudio, SNDSDLSetVolume }; -#define NUMSOUNDBLOCKS 4 - static u16 *stereodata16; static u32 soundoffset; static volatile u32 soundpos; @@ -72,7 +70,7 @@ void MixAudio(void *userdata, Uint8 *stream, int len) { ////////////////////////////////////////////////////////////////////////////// -int SNDSDLInit() +int SNDSDLInit(int buffersize) { SDL_InitSubSystem(SDL_INIT_AUDIO); // if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0); @@ -94,7 +92,7 @@ int SNDSDLInit() audiofmt.samples = normSamples; soundlen = audiofmt.freq / 60; // 60 for NTSC - soundbufsize = soundlen * NUMSOUNDBLOCKS * 2 * 2; + soundbufsize = buffersize * sizeof(s16) * 2; if (SDL_OpenAudio(&audiofmt, NULL) != 0) { @@ -152,7 +150,7 @@ void SNDSDLUpdateAudio(s16 *buffer, u32 num_samples) // ScspConvert32uto16s((s32 *)leftchanbuffer, (s32 *)rightchanbuffer, (s16 *)(((u8 *)stereodata16)+soundoffset), copy1size / sizeof(s16) / 2); if (copy2size) - memcpy(stereodata16, buffer+copy1size, copy2size); + memcpy(stereodata16, ((u8 *)buffer)+copy1size, copy2size); // ScspConvert32uto16s((s32 *)leftchanbuffer, (s32 *)rightchanbuffer, (s16 *)stereodata16, copy2size / sizeof(s16) / 2); soundoffset += copy1size + copy2size;