# HG changeset patch # User Sam # Date 1683019727 25200 # Node ID 42e99cb20da29aac8d3ff250a73d7df39d173a37 # Parent 36e10cc04a33824611313a042b841f87c4a3149c fix: remove potential raise diff -r 36e10cc04a33 -r 42e99cb20da2 src/semicongine/platform/windows/audio.nim --- a/src/semicongine/platform/windows/audio.nim Tue May 02 02:13:46 2023 +0700 +++ b/src/semicongine/platform/windows/audio.nim Tue May 02 02:28:47 2023 -0700 @@ -36,12 +36,13 @@ reserved: DWORD_PTR(0) ) checkWinMMResult waveOutPrepareHeader(result.handle, addr result.buffer, UINT(sizeof(WAVEHDR))) - + +# add double buffering: https://stackoverflow.com/questions/49605552/double-buffered-waveoutwrite-stuttering-like-hell proc writeSoundData*(soundDevice: var NativeSoundDevice) = checkWinMMResult waveOutWrite(soundDevice.handle, addr soundDevice.buffer, UINT(sizeof(WAVEHDR))) while (soundDevice.buffer.dwFlags and WHDR_DONE) != 1: discard proc closeSoundDevice*(soundDevice: var NativeSoundDevice) = - checkWinMMResult waveOutUnprepareHeader(soundDevice.handle, addr soundDevice.buffer, UINT(sizeof(WAVEHDR))) + discard waveOutUnprepareHeader(soundDevice.handle, addr soundDevice.buffer, UINT(sizeof(WAVEHDR))) waveOutClose(soundDevice.handle)