From 39dd0d716f336e13eb46ec9e1324a9271002abf6 Mon Sep 17 00:00:00 2001 From: bwmott Date: Wed, 13 Nov 2002 05:01:31 +0000 Subject: [PATCH] Changed the upper and lower bounds on the sample queue so that there's a little more room for error. Also added a call to SDL_Delay in the blocking section of the updateSound method so that it doesn't hog the CPU. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@143 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/ui/sdl/SoundSDL.cxx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/stella/src/ui/sdl/SoundSDL.cxx b/stella/src/ui/sdl/SoundSDL.cxx index 4709e7398..fa45c1ca7 100644 --- a/stella/src/ui/sdl/SoundSDL.cxx +++ b/stella/src/ui/sdl/SoundSDL.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: SoundSDL.cxx,v 1.4 2002-11-11 22:07:35 stephena Exp $ +// $Id: SoundSDL.cxx,v 1.5 2002-11-13 05:01:31 bwmott Exp $ //============================================================================ #include @@ -175,9 +175,9 @@ void SoundSDL::updateSound(MediaSource& mediaSource) // Release lock on the sample queue SDL_UnlockAudio(); - // Block until the sound thread has consumed all but 100 milliseconds + // Block until the sound thread has consumed all but 142 milliseconds // of the available audio samples - uInt32 leave = mySampleRate / 10; + uInt32 leave = mySampleRate / 7; for(;;) { uInt32 size = 0; @@ -190,6 +190,8 @@ void SoundSDL::updateSound(MediaSource& mediaSource) { break; } + + SDL_Delay(5); } } } @@ -204,8 +206,8 @@ void SoundSDL::callback(void* udata, uInt8* stream, int len) return; } - // Don't use samples unless there's at least 50 milliseconds worth of data - if(sound->mySampleQueue.size() < (sound->mySampleRate / 20)) + // Don't use samples unless there's at least 76 milliseconds worth of data + if(sound->mySampleQueue.size() < (sound->mySampleRate / 13)) { return; }