$NetBSD: patch-ab,v 1.3 2001/05/02 04:02:06 fredb Exp $

--- src/sqUnixSound.c.orig	Tue Jun 22 11:07:36 1999
+++ src/sqUnixSound.c
@@ -38,7 +38,12 @@
 #include <fcntl.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
+#ifdef __NetBSD__
+#include <soundcard.h>
+#include <sys/audioio.h>
+#else
 #include <sys/soundcard.h>
+#endif
 
 static unsigned char *auBuf=	0;
 
@@ -212,6 +217,30 @@
 
 int snd_AvailableSpace(void)
 {
+#if defined(__NetBSD__) && SOUND_VERSION < 0x030001
+/*
+  The OSS emulation layer in NetBSD-1.[45].x failed to update
+  audio_buf_info->fragments, so get the information using the
+  native audio driver.
+*/
+  struct audio_info info;
+  int freeBlocks;
+
+  if (auFd == -1) return -1;
+
+  if (ioctl(auFd, AUDIO_GETINFO, &info) < 0) {
+    perror("ioctl(AUDIO_GETINFO)");
+    return 0;
+  }
+
+  /* Make certain we have one, full hardware block free. */
+  freeBlocks = (long)info.hiwat-- - (long)(info.play.seek--)/info.blocksize;
+  if (freeBlocks > 0) {
+    return info.blocksize;
+  } else {
+    auSemaWaiting= true;
+    return 0;
+#else
   audio_buf_info info;
   if (auFd == -1) return -1;
 
@@ -226,6 +255,7 @@
     return 0;
   } else {
     return info.fragsize;
+#endif
   }
 }
 
