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 );