$NetBSD: patch-aa,v 1.7 2007/06/08 17:18:53 wiz Exp $

--- timidity/sun_a.c.orig	2004-09-26 23:40:14.000000000 +0000
+++ timidity/sun_a.c
@@ -296,6 +296,18 @@ int output_data(char *buff, int32 nbytes
 
 
 #if !defined(I_FLUSH) || !defined(FLUSHW)
+#  if defined(AUDIO_FLUSH)	/* NetBSD */
+static int sun_discard_playing(void)
+{
+    if(ioctl(dpm.fd, AUDIO_FLUSH, NULL) < 0)
+    {
+	ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: (ioctl) %s",
+		  dpm.name, strerror(errno));
+	return -1;
+    }
+    return 0;
+}
+#  else
 static void null_proc(){}
 static int sun_discard_playing(void)
 {
@@ -308,6 +320,7 @@ static int sun_discard_playing(void)
     signal(SIGALRM, orig_alarm_handler);
     return open_output();
 }
+#  endif
 #else
 static int sun_discard_playing(void)
 {
@@ -328,6 +341,23 @@ static int acntl(int request, void *arg)
 
     switch(request)
     {
+#ifdef __NetBSD__
+      case PM_REQ_GETQSIZ:
+	if(ioctl(audioctl_fd, AUDIO_GETINFO, &auinfo) < 0)
+	    return -1;
+	*((int *)arg) = auinfo.play.buffer_size;
+	return 0;
+
+      case PM_REQ_GETFRAGSIZ:
+	if(ioctl(audioctl_fd, AUDIO_GETINFO, &auinfo) < 0)
+	    return -1;
+	*((int *)arg) = auinfo.blocksize;
+	return 0;
+
+      case PM_REQ_OUTPUT_FINISH:
+	return ioctl(audioctl_fd, AUDIO_DRAIN, NULL);
+#endif
+
       case PM_REQ_GETFILLED:
 	if(ioctl(audioctl_fd, AUDIO_GETINFO, &auinfo) < 0)
 	    return -1;
