From 8d546e2f07d6cd3bccb7a5ea4ea5bf1375032368 Mon Sep 17 00:00:00 2001 From: spacy51 Date: Thu, 6 Dec 2007 17:30:43 +0000 Subject: [PATCH] fixed buffer size calculation every sample rate works now git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@174 a31d4220-a93d-0410-bf67-fe4944624d44 --- src/win32/DirectSound.cpp | 4 +++- src/win32/OpenAL.cpp | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/win32/DirectSound.cpp b/src/win32/DirectSound.cpp index 2fe9da60..80812ee5 100644 --- a/src/win32/DirectSound.cpp +++ b/src/win32/DirectSound.cpp @@ -156,7 +156,9 @@ bool DirectSound::init() } freq = 44100 / soundQuality; - soundBufferLen = freq*2*2/60; + // calculate the number of samples per frame first + // then multiply it with the size of a sample frame (16 bit * stereo) + soundBufferLen = ( freq / 60 ) * 4; soundBufferTotalLen = soundBufferLen * 10; ZeroMemory( &wfx, sizeof(WAVEFORMATEX) ); diff --git a/src/win32/OpenAL.cpp b/src/win32/OpenAL.cpp index 8ba592d0..825f4837 100644 --- a/src/win32/OpenAL.cpp +++ b/src/win32/OpenAL.cpp @@ -178,9 +178,9 @@ bool OpenAL::init() assert( AL_NO_ERROR == alGetError() ); freq = 44100 / soundQuality; - - soundBufferLen = freq * 2 * 2 / 60; - // 16bit stereo, buffer can store the sound for 1 frame in 60Hz + // calculate the number of samples per frame first + // then multiply it with the size of a sample frame (16 bit * stereo) + soundBufferLen = ( freq / 60 ) * 4; setsystemSoundOn( true );