From: S?bastien G. <kx...@us...> - 2004-04-25 19:05:47
|
Update of /cvsroot/vba/VisualBoyAdvance/src/gtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27620 Modified Files: system.cpp Log Message: Fixed a bug with sound. Index: system.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/gtk/system.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** system.cpp 22 Apr 2004 20:42:39 -0000 1.4 --- system.cpp 25 Apr 2004 19:02:44 -0000 1.5 *************** *** 58,65 **** // Sound stuff // ! static SDL_cond * pstSoundCond = NULL; ! static SDL_mutex * pstSoundMutex = NULL; ! static u8 auiSoundBuffer[4096]; ! static int iSoundLen = 0; inline VBA::Window * GUI() --- 58,67 ---- // Sound stuff // ! const int iSoundSamples = 2048; ! const int iSoundTotalLen = iSoundSamples * 4; ! static u8 auiSoundBuffer[iSoundTotalLen]; ! static int iSoundLen; ! static SDL_cond * pstSoundCond; ! static SDL_mutex * pstSoundMutex; inline VBA::Window * GUI() *************** *** 78,83 **** Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK); - oDialog.show(); // TEST - oDialog.grab_focus(); // TEST oDialog.run(); free(csMsg); --- 80,83 ---- *************** *** 137,141 **** { SDL_mutexP(pstSoundMutex); ! if (iSoundLen < 2048 * 2) { bWait = false; --- 137,141 ---- { SDL_mutexP(pstSoundMutex); ! if (iSoundLen < iSoundTotalLen) { bWait = false; *************** *** 146,155 **** int iLen = soundBufferLen; int iCopied = 0; ! if (iSoundLen + iLen >= 2048 * 2) { ! iCopied = 2048 * 2 - iSoundLen; memcpy(&auiSoundBuffer[iSoundLen], soundFinalWave, iCopied); ! iSoundLen = 2048 * 2; SDL_CondSignal(pstSoundCond); --- 146,155 ---- int iLen = soundBufferLen; int iCopied = 0; ! if (iSoundLen + iLen >= iSoundTotalLen) { ! iCopied = iSoundTotalLen - iSoundLen; memcpy(&auiSoundBuffer[iSoundLen], soundFinalWave, iCopied); ! iSoundLen = iSoundTotalLen; SDL_CondSignal(pstSoundCond); *************** *** 160,164 **** { SDL_mutexP(pstSoundMutex); ! if (iSoundLen < 2048 * 2) { bWait = false; --- 160,164 ---- { SDL_mutexP(pstSoundMutex); ! if (iSoundLen < iSoundTotalLen) { bWait = false; *************** *** 195,199 **** if (! speedup && GUI()->iGetThrottle() == 0) { ! while (iSoundLen < 2048 * 2 && emulating) { SDL_CondWait(pstSoundCond, pstSoundMutex); --- 195,199 ---- if (! speedup && GUI()->iGetThrottle() == 0) { ! while (iSoundLen < iSoundTotalLen && emulating) { SDL_CondWait(pstSoundCond, pstSoundMutex); *************** *** 230,234 **** stAudio.format = AUDIO_S16SYS; stAudio.channels = 2; ! stAudio.samples = 1024; stAudio.callback = vSoundCallback; stAudio.userdata = NULL; --- 230,234 ---- stAudio.format = AUDIO_S16SYS; stAudio.channels = 2; ! stAudio.samples = iSoundSamples; stAudio.callback = vSoundCallback; stAudio.userdata = NULL; |