ref: 9b83a2cc0a5ff96edef5e1a34aa485516534b915
parent: 478feff9f20614e5205a7486feb5ed32ceca019b
author: Tuomas Virtanen <katajakasa@gmail.com>
date: Tue Nov 1 16:58:07 EDT 2016
Update examples to use the new api
--- 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);