diff semiconginev2/audio/resources.nim @ 1234:841e12f33c47

add: text & font rendering, not tested yet
author sam <sam@basx.dev>
date Sat, 20 Jul 2024 00:03:57 +0700
parents 27cd1c21290e
children
line wrap: on
line diff
--- a/semiconginev2/audio/resources.nim	Fri Jul 19 21:25:42 2024 +0700
+++ b/semiconginev2/audio/resources.nim	Sat Jul 20 00:03:57 2024 +0700
@@ -54,7 +54,6 @@
 {.compile: currentSourcePath.parentDir() & "/stb_vorbis.c".}
 
 proc stb_vorbis_decode_memory(mem: pointer, len: cint, channels: ptr cint, sample_rate: ptr cint, output: ptr ptr cshort): cint {.importc.}
-proc free(p: pointer) {.importc.}
 
 proc ReadVorbis*(stream: Stream): SoundData =
   var
@@ -73,14 +72,14 @@
   if channels == 2:
     result.setLen(int(nSamples))
     copyMem(addr result[0], output, nSamples * sizeof(Sample))
-    free(output)
+    nativeFree(output)
   elif channels == 1:
     for i in 0 ..< nSamples:
       let value = cast[ptr UncheckedArray[int16]](output)[i]
       result.add [value, value]
-    free(output)
+    nativeFree(output)
   else:
-    free(output)
+    nativeFree(output)
     raise newException(Exception, "Only support mono and stereo audio at the moment (1 or 2 channels), but found " & $channels)
 
 proc LoadAudio*(path: string, package = DEFAULT_PACKAGE): SoundData =