Module Name:    src
Committed By:   mrg
Date:           Sun Mar 22 22:47:43 UTC 2015

Modified Files:
        src/usr.bin/midiplay: midiplay.c

Log Message:
if not playing (-q mode), don't call ioctl() or try to use the results.
now -q mode works.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/midiplay/midiplay.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/midiplay/midiplay.c
diff -u src/usr.bin/midiplay/midiplay.c:1.29 src/usr.bin/midiplay/midiplay.c:1.30
--- src/usr.bin/midiplay/midiplay.c:1.29	Fri Nov 25 01:39:47 2011
+++ src/usr.bin/midiplay/midiplay.c	Sun Mar 22 22:47:43 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: midiplay.c,v 1.29 2011/11/25 01:39:47 jmcneill Exp $	*/
+/*	$NetBSD: midiplay.c,v 1.30 2015/03/22 22:47:43 mrg Exp $	*/
 
 /*
  * Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: midiplay.c,v 1.29 2011/11/25 01:39:47 jmcneill Exp $");
+__RCSID("$NetBSD: midiplay.c,v 1.30 2015/03/22 22:47:43 mrg Exp $");
 #endif
 
 
@@ -404,7 +404,7 @@ playdata(u_char *buf, u_int tot, const c
 
 	/* verify that the requested midi unit exists */
 	info.device = unit;
-	if (ioctl(fd, SEQUENCER_INFO, &info) < 0)
+	if (play && ioctl(fd, SEQUENCER_INFO, &info) < 0)
 		err(1, "ioctl(SEQUENCER_INFO) failed");
 
 	end = buf + tot;
@@ -488,7 +488,9 @@ playdata(u_char *buf, u_int tot, const c
 	 * in some cases by frobbing tempo and timebase more obscurely, but this
 	 * player is meant to be simple and clear.
 	 */
-	if ((divfmt & 0x80) == 0) {
+	if (!play)
+		/* do nothing */;
+	else if ((divfmt & 0x80) == 0) {
 		ticks |= divfmt << 8;
 		if (ioctl(fd, SEQUENCER_TMR_TIMEBASE, &(int){ticks}) < 0)
 			err(1, "SEQUENCER_TMR_TIMEBASE");
@@ -681,7 +683,7 @@ playdata(u_char *buf, u_int tot, const c
 			tp->delta = getvar(tp);
 		Heapify(tracks, ntrks, 0);
 	}
-	if (ioctl(fd, SEQUENCER_SYNC, 0) < 0)
+	if (play && ioctl(fd, SEQUENCER_SYNC, 0) < 0)
 		err(1, "SEQUENCER_SYNC");
 
  ret:

Reply via email to