--- flow/audioiooss.cc	29 Oct 2002 02:31:12 -0000	1.1.1.3
+++ flow/audioiooss.cc	7 Nov 2002 00:16:37 -0000	1.6
@@ -28,10 +28,30 @@
 
 #if defined(HAVE_SYS_SOUNDCARD_H)
 	#include <sys/soundcard.h>
+	#include <sys/ioctl.h>
 	#define COMPILE_AUDIOIO_OSS 1
+	#define OSS_OPEN open
+	#define OSS_CLOSE close
+	#define OSS_IOCTL ioctl
+	#define OSS_WRITE write
 #elif defined(HAVE_SOUNDCARD_H)
 	#include <soundcard.h>
+	#include <sys/ioctl.h>
 	#define COMPILE_AUDIOIO_OSS 1
+	#define OSS_OPEN open
+	#define OSS_CLOSE close
+	#define OSS_IOCTL ioctl
+	#define OSS_WRITE write
+#endif
+
+#ifdef HAVE_LIBOSS
+	#define LIBOSS_IOCTL OSS_IOCTL
+	#define LIBOSS_OPEN  OSS_OPEN
+	#define LIBOSS_CLOSE OSS_CLOSE
+	#define LIBOSS_WRITE OSS_WRITE
+	#define COMPILE_AUDIOIO_OSS 1
+	#include <liboss/soundcard.h>
+	#include <sys/ioctl.h>
 #endif
 
 /**
@@ -40,7 +60,6 @@
 #ifdef COMPILE_AUDIOIO_OSS
 
 #include <sys/types.h>
-#include <sys/ioctl.h>
 #include <sys/time.h>
 #include <sys/stat.h>
 
@@ -159,7 +178,7 @@
 		return false;
 	}
 
-	audio_fd = ::open(_deviceName.c_str(), mode, 0);
+	audio_fd = ::OSS_OPEN(_deviceName.c_str(), mode, 0);
 
 	if(audio_fd == -1)
 	{
@@ -174,7 +193,7 @@
 	 * check device capabilities
 	 */
 	int device_caps;
-	if(ioctl(audio_fd,SNDCTL_DSP_GETCAPS,&device_caps) == -1)
+	if(OSS_IOCTL(audio_fd,SNDCTL_DSP_GETCAPS,&device_caps) == -1)
             device_caps=0;
 
 	string caps = "";
@@ -189,7 +208,7 @@
 
 	int requestedFormat = (_format == 8)?AFMT_U8:AFMT_S16_LE;
 	int gotFormat = requestedFormat;
-	if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &gotFormat)==-1)  
+	if (OSS_IOCTL(audio_fd, SNDCTL_DSP_SETFMT, &gotFormat)==-1)  
 	{
 		_error = "SNDCTL_DSP_SETFMT failed - ";
 		_error += strerror(errno);
@@ -252,7 +271,7 @@
 
 	int requeststereo = stereo;
 
-	if (ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo)==-1)
+	if (OSS_IOCTL(audio_fd, SNDCTL_DSP_STEREO, &stereo)==-1)
 	{
 		_error = "SNDCTL_DSP_STEREO failed - ";
 		_error += strerror(errno);
@@ -271,7 +290,7 @@
 
 	int speed = _samplingRate;
 
-	if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &speed)==-1)  
+	if (OSS_IOCTL(audio_fd, SNDCTL_DSP_SPEED, &speed)==-1)  
 	{
 		_error = "SNDCTL_DSP_SPEED failed - ";
 		_error += strerror(errno);
@@ -322,7 +341,7 @@
 	int size = _fragmentSize;
 	while(size > 1) { size /= 2; frag_arg++; }
 	frag_arg += (_fragmentCount << 16);
-	if(ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_arg) == -1)
+	if(OSS_IOCTL(audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_arg) == -1)
 	{
 		char buffer[1024];
 		_error = "can't set requested fragments settings";
@@ -336,7 +355,7 @@
 	 * we asked for
 	 */
 	audio_buf_info info;
-	if(ioctl(audio_fd,SNDCTL_DSP_GETOSPACE, &info) == -1)
+	if(OSS_IOCTL(audio_fd,SNDCTL_DSP_GETOSPACE, &info) == -1)
 	{
 		_error = "can't retrieve fragment settings";
 		close();
@@ -393,7 +412,7 @@
 		if(param(direction) & 1) enable_bits |= PCM_ENABLE_INPUT;
 		if(param(direction) & 2) enable_bits |= PCM_ENABLE_OUTPUT;
 
-		if(ioctl(audio_fd,SNDCTL_DSP_SETTRIGGER, &enable_bits) == -1)
+		if(OSS_IOCTL(audio_fd,SNDCTL_DSP_SETTRIGGER, &enable_bits) == -1)
 		{
 			_error = "can't start sound i/o";
 
@@ -406,7 +425,7 @@
 
 void AudioIOOSS::close()
 {
-	::close(audio_fd);
+	::OSS_CLOSE(audio_fd);
 }
 
 void AudioIOOSS::setParam(AudioParam p, int& value)
@@ -431,12 +450,12 @@
 	switch(p)
 	{
 		case canRead:
-				ioctl(audio_fd, SNDCTL_DSP_GETISPACE, &info);
+				OSS_IOCTL(audio_fd, SNDCTL_DSP_GETISPACE, &info);
 				return info.bytes;
 			break;
 
 		case canWrite:
-				ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info);
+				OSS_IOCTL(audio_fd, SNDCTL_DSP_GETOSPACE, &info);
 				return info.bytes;
 			break;
 
@@ -477,7 +496,7 @@
 
 	int result;
 	do {
-		result = ::write(audio_fd,buffer,size);
+		result = ::OSS_WRITE(audio_fd,buffer,size);
 	} while(result == -1 && errno == EINTR);
 
 	return result;
