$NetBSD: patch-af,v 1.4 2001/05/20 20:52:24 rh Exp $

--- Output/OSS/audio.c.orig	Sat Jul 29 02:19:41 2000
+++ Output/OSS/audio.c
@@ -39,9 +39,22 @@
 
 static void oss_calc_device_buffer_used(void)
 {
+#if defined(__NetBSD__) && SOUND_VERSION <= 0x030000
+	struct audio_info info;
+#endif
 	audio_buf_info buf_info;
 	if(paused)
 		device_buffer_used = 0;
+#if defined(__NetBSD__) && SOUND_VERSION <= 0x030000
+	/*
+	  This is to work around a bug in NetBSD-1.5.1 and earlier, in which
+	  the SNDCTL_DSP_GETOSPACE(&buf_info) ioctl was not handled properly.
+	  The correct information is always available via the native audio
+	  driver, so use that instead.
+	*/
+	else if (!ioctl(fd, AUDIO_GETINFO, &info))
+		device_buffer_used = info.play.seek;
+#endif
 	else if (!ioctl(fd, SNDCTL_DSP_GETOSPACE, &buf_info))
 		device_buffer_used = (buf_info.fragstotal * buf_info.fragsize) - buf_info.bytes;
 }
