shithub: dumb

Download patch

ref: 292a32823ddb0b3667e6db878c755cf41893cc51
parent: 62536e7f959a634d0dcde0b765f91e5d8f1dbe71
parent: 0858e22451177197ef0eada104c75f982f853e79
author: Christopher Snowhill <kode54@gmail.com>
date: Sat Jan 28 07:11:30 EST 2017

Merge branch 'master' of github.com:kode54/dumb

--- a/examples/dumbout.c
+++ b/examples/dumbout.c
@@ -16,6 +16,8 @@
 typedef struct {
     DUH_SIGRENDERER *renderer;
     DUH *src;
+    sample_t **sig_samples;
+    long sig_samples_size;
     FILE *dst;
     float delta;
     int bufsize;
@@ -226,12 +228,14 @@
 
     // Loop until we have nothing to loop through. Dumb will stop giving out bytes when the file is done.
     while(run) {
-        read_samples = duh_render(streamer.renderer,
-                                  settings.bits,
-                                  (int)settings.is_unsigned,
-                                  settings.volume,
-                                  streamer.delta,
-                                  4096, buffer);
+        read_samples = duh_render_int(streamer.renderer,
+                                      &streamer.sig_samples,
+                                      &streamer.sig_samples_size,
+                                      settings.bits,
+                                      (int)settings.is_unsigned,
+                                      settings.volume,
+                                      streamer.delta,
+                                      4096, buffer);
         read_bytes = read_samples * (settings.bits / 8) * settings.n_channels;
 
         // switch endianness if required
@@ -258,6 +262,10 @@
 
     if(!streamer.is_stdout && streamer.dst) {
         fclose(streamer.dst);
+    }
+
+    if(streamer.sig_samples) {
+        destroy_sample_buffer(streamer.sig_samples);
     }
 
 exit_1:
--- a/examples/dumbplay.c
+++ b/examples/dumbplay.c
@@ -17,6 +17,8 @@
     DUH_SIGRENDERER *renderer;
     DUH *src;
     SDL_AudioDeviceID dev;
+    sample_t **sig_samples;
+    long sig_samples_size;
 
     // Runtime vars
     float delta;
@@ -49,7 +51,16 @@
 
     // Read samples from libdumb save them to the SDL buffer. Note that we are reading SAMPLES, not bytes!
     int r_samples = len / streamer->sbytes;
-    int got = duh_render(streamer->renderer, streamer->bits, 0, streamer->volume, streamer->delta, r_samples, stream);
+    int got = duh_render_int(
+        streamer->renderer,
+        &streamer->sig_samples,
+        &streamer->sig_samples_size,
+        streamer->bits,
+        0,
+        streamer->volume,
+        streamer->delta,
+        r_samples,
+        stream);
     if(got == 0) {
         streamer->ended = true;
     }
@@ -266,6 +277,10 @@
     retcode = 0;
 
     // Free up resources and exit.
+    if(streamer.sig_samples) {
+        destroy_sample_buffer(streamer.sig_samples);
+    }
+
 exit_2:
     SDL_CloseAudioDevice(streamer.dev);