shithub: dumb

Download patch

ref: fbd0eed489f59a6fbca4eee56eef7e3f8ad52e29
parent: 52c579491bf9c0e188a1713fdc17155bcd53c997
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Fri Mar 5 08:03:01 EST 2021

moddec: do not play anything if seeking past the end

--- a/examples/moddec.c
+++ b/examples/moddec.c
@@ -20,10 +20,10 @@
 void
 main(int argc, char **argv)
 {
+	double pos, freq, ratio, dur;
 	DUMB_IT_SIGRENDERER *itren;
 	DUH_SIGRENDERER *ren;
 	int n, sz, r, resamp;
-	double pos, freq, ratio;
 	sample_t **samp;
 	char *data, *t;
 	long nsamp;
@@ -75,7 +75,10 @@
 		sysfatal("unknown/invalid mod");
 	if((t = (char*)duh_get_tag(f, "TITLE")) != nil && *t)
 		fprint(2, "%s\n", t);
-	fprint(2, "duration: %g\n", duh_get_length(f)*ratio/100000.0);
+	dur = duh_get_length(f)*ratio/100000.0;
+	fprint(2, "duration: %g\n", dur);
+	if(pos > dur)
+		exits(nil);
 	ren = duh_start_sigrenderer(f, 0, 2, pos*100000.0/ratio);
 	itren = duh_get_it_sigrenderer(ren);
 	dumb_it_set_loop_callback(itren, dumb_it_callback_terminate, nil);