changeset 638:bae5b7b884bb

fix: remove potential raise
author Sam <sam@basx.dev>
date Tue, 02 May 2023 02:28:47 -0700
parents bb6857da8113
children 977392dc055f 232290881c87
files src/semicongine/platform/windows/audio.nim
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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)