From da047b8b18781106119164a487752931eb6d6d91 Mon Sep 17 00:00:00 2001 From: spacy51 Date: Sat, 8 Dec 2007 14:48:14 +0000 Subject: [PATCH] optimized timing formula a little increases buffer size a little --- src/win32/OpenAL.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/win32/OpenAL.cpp b/src/win32/OpenAL.cpp index 92b332ee..a866fe34 100644 --- a/src/win32/OpenAL.cpp +++ b/src/win32/OpenAL.cpp @@ -38,7 +38,7 @@ #include -#define NBUFFERS 5 +#define NBUFFERS 8 //#define LOGALL // LOGALL writes very detailed informations to vba-trace.log @@ -278,8 +278,9 @@ void OpenAL::write() // wait until at least one buffer has finished while( nBuffersProcessed == 0 ) { winlog( " waiting...\n" ); - // wait for 1/10 of the time one buffer needs to have finished - Sleep( soundBufferLen * 1000 / ( freq * 2 * 2 * 10 ) ); + // wait for about half the time one buffer needs to finish + // unoptimized: ( sourceBufferLen * 1000 ) / ( freq * 2 * 2 ) * 1/2 + Sleep( soundBufferLen / ( freq >> 7 ) ); alGetSourcei( source, AL_BUFFERS_PROCESSED, &nBuffersProcessed ); assert( AL_NO_ERROR == alGetError() ); }