From a76837a4f22f2ba2857e2b1fa9b1a3664942baae Mon Sep 17 00:00:00 2001 From: OV2 Date: Sun, 6 Nov 2016 22:05:10 +0100 Subject: [PATCH] win32: make sure sample count is even --- win32/CDirectSound.cpp | 3 ++- win32/CXAudio2.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/win32/CDirectSound.cpp b/win32/CDirectSound.cpp index 192f348e..01f19b06 100644 --- a/win32/CDirectSound.cpp +++ b/win32/CDirectSound.cpp @@ -314,7 +314,8 @@ bool CDirectSound::InitSoundBuffer() blockCount = 4; blockTime = GUI.SoundBufferSize / blockCount; - blockSamples = (Settings.SoundPlaybackRate * blockTime * (Settings.Stereo ? 2 : 1)) / 1000; + blockSamples = (Settings.SoundPlaybackRate * blockTime) / 1000; + blockSamples *= (Settings.Stereo ? 2 : 1); blockSize = blockSamples * (Settings.SixteenBitSound ? 2 : 1); bufferSize = blockSize * blockCount; diff --git a/win32/CXAudio2.cpp b/win32/CXAudio2.cpp index fa54ae00..84fa533f 100644 --- a/win32/CXAudio2.cpp +++ b/win32/CXAudio2.cpp @@ -355,7 +355,8 @@ bool CXAudio2::SetupSound() blockCount = 8; UINT32 blockTime = GUI.SoundBufferSize / blockCount; - singleBufferSamples = (Settings.SoundPlaybackRate * blockTime * (Settings.Stereo ? 2 : 1)) / 1000; + singleBufferSamples = (Settings.SoundPlaybackRate * blockTime) / 1000; + singleBufferSamples *= (Settings.Stereo ? 2 : 1); singleBufferBytes = singleBufferSamples * (Settings.SixteenBitSound ? 2 : 1); sum_bufferSize = singleBufferBytes * blockCount;