# HG changeset patch # User Sam # Date 1683019727 25200 # Node ID bae5b7b884bb6af4fed4c2d34d68708bace9ce66 # Parent bb6857da811340cf84dfb5292e0776bb72a5882c fix: remove potential raise diff -r bb6857da8113 -r bae5b7b884bb 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)