Subject: pkg/18812: Cheesetracker does not compile on 1.5.0
To: None <gnats-bugs@gnats.netbsd.org>
From: None <ben@wongs.net>
List: netbsd-bugs
Date: 10/26/2002 10:37:07
>Number:         18812
>Category:       pkg
>Synopsis:       Cheesetracker does not compile on 1.5.0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 26 07:38:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Ben Wong
>Release:        NetBSD-1.5.0
>Organization:
Georgia Institute of Technology
>Environment:
	
System: NetBSD hrududu.wongs.net 1.5 NetBSD 1.5 (HRUDUDU) #9: Thu Sep 5 13:18:30 EDT 2002 root@hrududu.wongs.net:/usr/src/sys/arch/i386/compile/HRUDUDU i386


>Description:
Under NetBSD-1.5.1 and earlier the package audio/cheesetracker uses
ifdef'd code which is supposed to work around a bug in the OSS
emulation. Unfortunately, it causes the program to not compile.

>How-To-Repeat:
Use NetBSD-1.5 and simply run 'make' audio/cheesetracker. It will fail
when trying to compile waveout/sound_driver_oss.cpp. In particular, it
will die because of the additions put in to that file by patch-ad.


>Fix:
Replace patch-ad with the following patch which simply adds a
declaration for the variable "info" in the update method.


$NetBSD$

--- waveout/sound_driver_oss.cpp.orig	Wed Apr 10 23:46:44 2002
+++ waveout/sound_driver_oss.cpp
@@ -18,7 +18,11 @@
 #include "sound_driver_oss.h"
 #include "math.h"
 
+#if defined(__NetBSD__)
+#define AUDIO_DEVICE "/dev/audio"
+#else
 #define AUDIO_DEVICE "/dev/dsp"
+#endif
 
 int Sound_Driver_OSS::init() {
 
@@ -28,6 +32,10 @@
 	long supported_formats;
 	audio_buf_info buffinf;
  	int request_buffer_size;
+#if defined(__NetBSD__) && SOUND_VERSION <= 0x030000
+	struct audio_info info;
+#endif
+
 
 	if (mix_frequency==-1) {
          	
@@ -106,11 +114,29 @@
 	}
 
 
+#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.
+*/
+	if (ioctl(sound_fd, AUDIO_GETINFO, &info) == 0) {
+		buffinf.fragsize = info.blocksize;
+		buffinf.fragments = info.hiwat - info.play.seek /
+			info.blocksize;
+		buffinf.bytes = info.play.buffer_size;
+	} else {
+		buffinf.fragments--;
+		buffinf.fragsize = buffinf.bytes = buffersize;
+	}
+#else
 	/* This call fails on Linux/PPC */
 	if( (ioctl(sound_fd,SNDCTL_DSP_GETOSPACE,&buffinf)<0) ) {
 
 		ioctl(sound_fd,SNDCTL_DSP_GETBLKSIZE,&buffinf.fragsize);
 	}
+#endif
 
 	
 
@@ -158,22 +184,43 @@
 
 	int done;
 	audio_buf_info buffinf;
+#if defined(__NetBSD__) && SOUND_VERSION <= 0x030000
+	struct audio_info info;
+#endif
 
 	if (!active) return false;
 	
 	for (;;) {
 
+#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.
+*/
+		if (ioctl(sound_fd, AUDIO_GETINFO, &info) == 0) {
+			buffinf.fragsize = info.blocksize;
+			buffinf.fragments = info.hiwat - info.play.seek /
+				info.blocksize;
+			buffinf.bytes = info.play.buffer_size;
+		} else {
+			buffinf.fragments--;
+			buffinf.fragsize = buffinf.bytes = buffersize;
+		}
+#else
 		if ((ioctl(sound_fd,SNDCTL_DSP_GETOSPACE,&buffinf)<0)) {
 
 			buffinf.fragments--;
 			buffinf.fragsize = buffinf.bytes = buffersize;
 		}
+#endif
 
                 if(!buffinf.fragments) break;
 
 		done=mixer->write_bytes(audiobuffer,buffinf.fragsize>buffinf.bytes?buffinf.bytes:buffinf.fragsize);
 
-                write(sound_fd,audiobuffer,done);
+                __pthread_write(sound_fd,audiobuffer,done);
 	}		
 
 	return true;	

>Release-Note:
>Audit-Trail:
>Unformatted: