changeset 635:c5ff8f88c4a0

did: fix default sample rate, correct waiting for windows waveout processing
author Sam <sam@basx.dev>
date Tue, 02 May 2023 00:49:23 +0700
parents f3b723eb89d5
children 77358570f33b
files src/semicongine/audiotypes.nim src/semicongine/platform/windows/audio.nim
diffstat 2 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/semicongine/audiotypes.nim	Tue May 02 00:34:10 2023 +0700
+++ b/src/semicongine/audiotypes.nim	Tue May 02 00:49:23 2023 +0700
@@ -5,7 +5,7 @@
 #
 # ffmpeg -i <infile> -f s16le -ac 2 -ar 48000 -acodec pcm_s16le <outfile>
 
-const SAMPLERATE* = 48000
+const SAMPLERATE* = 44100
 const BUFFERSIZE* = 512
 
 type
--- a/src/semicongine/platform/windows/audio.nim	Tue May 02 00:34:10 2023 +0700
+++ b/src/semicongine/platform/windows/audio.nim	Tue May 02 00:49:23 2023 +0700
@@ -38,6 +38,9 @@
   )
   checkWinMMResult waveOutPrepareHeader(soundDevice.handle, addr data, UINT(sizeof(WAVEHDR)))
   checkWinMMResult waveOutWrite(soundDevice.handle, addr data, UINT(sizeof(WAVEHDR)))
+  while (data.dwFlags and WHDR_DONE) != 1:
+    discard
+  checkWinMMResult waveOutUnprepareHeader(soundDevice.handle, addr data, UINT(sizeof(WAVEHDR)))
 
 proc closeSoundDevice*(soundDevice: NativeSoundDevice) =
   waveOutClose(soundDevice.handle)