$OpenBSD: patch-portaudio_portaudio_v18_1_patch,v 1.2 2006/10/27 16:02:02 kurt Exp $
--- portaudio/portaudio_v18_1.patch.orig.port	Wed Mar  8 09:03:33 2006
+++ portaudio/portaudio_v18_1.patch	Thu Oct 26 23:34:46 2006
@@ -12,7 +12,7 @@
   	;;
   
     mingw* )
---- 1883,1921 ----
+--- 1883,1931 ----
   case "${host_os}" in
     darwin* )
   
@@ -49,6 +49,16 @@
 ! 	PADLL="libportaudio.so";
 ! 	SHARED_FLAGS="-shared -Wl,-soname=libportaudio.so.0";
 ! 	CFLAGS="-O2 -fPIC ${PTHREAD_CFLAGS} ${ARCH_FLAGS}"
+! 	;;
+! 
+!   openbsd* )
+! 
+! 	OTHER_OBJS="pa_unix_oss/pa_unix_oss.o pa_unix_oss/pa_unix.o";
+! 	LIBS="-lm -lpthread";
+! 	PADLL="libportaudio.so";
+! 	SHARED_FLAGS="-shared -Wl,-soname=libportaudio.so.0";
+! 	CFLAGS="${CFLAGS} -fPIC -pthread ${ARCH_FLAGS}"
+! 	DLL_LIBS="-lossaudio";
   	;;
   
     mingw* )
@@ -90,29 +100,216 @@
   LIBINST = /usr/local/lib
   
   TESTS:= $(wildcard pa_tests/pa*.c pa_tests/debug*.c)
-*** misc/portaudio_v18_1/pa_unix_oss/pa_unix_oss.c	2003-06-30 17:05:50.000000000 +0200
---- misc/build/portaudio_v18_1/pa_unix_oss/pa_unix_oss.c	2006-01-31 20:10:00.363708000 +0100
+*** misc/portaudio_v18_1/pa_tests/patest_buffer.c.old	2003-02-11 19:41:32.000000000 +0100
+--- misc/build/portaudio_v18_1/pa_tests/patest_buffer.c	2005-08-15 11:46:53.000000000 +0200
 ***************
+*** 125,130 ****
+--- 125,131 ----
+          if( err < 0 ) return 0;
+  
+      }
++     return 0;
+  }
+  
+  
+*** misc/portaudio_v18_1/pa_unix_oss/pa_unix.c	Mon Jun 30 11:05:50 2003
+--- misc/build/portaudio_v18_1/pa_unix_oss/pa_unix.c	Thu Oct 26 11:50:21 2006
+***************
+*** 401,406 ****
+--- 401,407 ----
+      return result;
+  }
+  
++ #ifndef __OpenBSD__
+  /*******************************************************************************************
+   * Monitor audio thread and lower its it if it hogs the CPU.
+   * To prevent getting killed, the audio thread must update a
+***************
+*** 600,605 ****
+--- 601,607 ----
+  
+      return result;
+  }
++ #endif  /* Watchdog */
+  
+  /*******************************************************************************************/
+  static PaError Pa_AudioThreadProc( internalPortAudioStream   *past )
+***************
+*** 615,622 ****
+--- 617,626 ----
+      GSRegisterCurrentThread(); /* SB20010904 */
+  #endif
+  
++ #ifndef __OpenBSD__
+      result = PaHost_BoostPriority( past );
+      if( result < 0 ) goto error;
++ #endif
+  
+      past->past_IsActive = 1;
+      DBUG(("entering thread.\n"));
+***************
+*** 682,688 ****
+--- 686,694 ----
+      DBUG(("Pa_AudioThreadProc: left audio loop.\n"));
+  
+      past->past_IsActive = 0;
++ #ifndef __OpenBSD__
+      PaHost_StopWatchDog( pahsc );
++ #endif
+  
+  error:
+      DBUG(("leaving audio thread.\n"));
+***************
+*** 812,818 ****
+                             past->past_NumUserBuffers, past->past_FramesPerUserBuffer,
+                             past->past_NumOutputChannels );
+              result = Pa_SetupDeviceFormat( pahsc->pahsc_OutputHandle,
+!                                            past->past_NumOutputChannels, (int)past->past_SampleRate );
+          }
+      }
+      else
+--- 818,824 ----
+                             past->past_NumUserBuffers, past->past_FramesPerUserBuffer,
+                             past->past_NumOutputChannels );
+              result = Pa_SetupDeviceFormat( pahsc->pahsc_OutputHandle,
+!                                            past->past_NumOutputChannels, (int)past->past_SampleRate, 2 );
+          }
+      }
+      else
+*** misc/portaudio_v18_1/pa_unix_oss/pa_unix.h	Thu Apr 10 17:42:34 2003
+--- misc/build/portaudio_v18_1/pa_unix_oss/pa_unix.h	Thu Oct 26 11:50:03 2006
+***************
+*** 133,139 ****
+  internalPortAudioDevice *Pa_GetInternalDevice( PaDeviceID id );
+  PaError Pa_QueryDevices( void );
+  PaError Pa_QueryDevice( const char *deviceName, internalPortAudioDevice *pad );
+! PaError Pa_SetupDeviceFormat( int devHandle, int numChannels, int sampleRate );
+  PaError Pa_SetupInputDeviceFormat( int devHandle, int numChannels, int sampleRate );
+  PaError Pa_SetupOutputDeviceFormat( int devHandle, int numChannels, int sampleRate );
+  void Pa_SetLatency( int devHandle, int numBuffers, int framesPerBuffer, int channelsPerFrame  );
+--- 133,139 ----
+  internalPortAudioDevice *Pa_GetInternalDevice( PaDeviceID id );
+  PaError Pa_QueryDevices( void );
+  PaError Pa_QueryDevice( const char *deviceName, internalPortAudioDevice *pad );
+! PaError Pa_SetupDeviceFormat( int devHandle, int numChannels, int sampleRate, int input );
+  PaError Pa_SetupInputDeviceFormat( int devHandle, int numChannels, int sampleRate );
+  PaError Pa_SetupOutputDeviceFormat( int devHandle, int numChannels, int sampleRate );
+  void Pa_SetLatency( int devHandle, int numBuffers, int framesPerBuffer, int channelsPerFrame  );
+*** misc/portaudio_v18_1/pa_unix_oss/pa_unix_oss.c	Mon Jun 30 11:05:50 2003
+--- misc/build/portaudio_v18_1/pa_unix_oss/pa_unix_oss.c	Thu Oct 26 11:49:47 2006
+***************
 *** 43,48 ****
---- 43,50 ----
+--- 43,53 ----
   
   #ifdef __linux__
   #include <linux/soundcard.h>
 + #elif defined (__FreeBSD__)
 + #include <sys/soundcard.h>
++ #elif defined (__OpenBSD__)
++ #include <soundcard.h>
++ #include <sys/audioio.h>
   #else
   #include <machine/soundcard.h> /* JH20010905 */
   #endif
-
-*** misc/portaudio_v18_1/pa_tests/patest_buffer.c.old	2003-02-11 19:41:32.000000000 +0100
---- misc/build/portaudio_v18_1/pa_tests/patest_buffer.c	2005-08-15 11:46:53.000000000 +0200
 ***************
-*** 125,130 ****
---- 125,131 ----
-          if( err < 0 ) return 0;
+*** 218,228 ****
+  }
   
+  /*******************************************************************************************/
+! PaError Pa_SetupDeviceFormat( int devHandle, int numChannels, int sampleRate )
+  {
+      PaError result = paNoError;
+      int     tmp;
+  
+      /* Set format, channels, and rate in this order to keep OSS happy. */
+      /* Set data format. FIXME - handle more native formats. */
+      tmp = AFMT_S16_NE;
+--- 223,237 ----
+  }
+  
+  /*******************************************************************************************/
+! PaError Pa_SetupDeviceFormat( int devHandle, int numChannels, int sampleRate, int input )
+  {
+      PaError result = paNoError;
+      int     tmp;
+  
++ #ifdef __OpenBSD__
++     audio_info_t audio_if;
++ #endif
++ 
+      /* Set format, channels, and rate in this order to keep OSS happy. */
+      /* Set data format. FIXME - handle more native formats. */
+      tmp = AFMT_S16_NE;
+***************
+*** 272,289 ****
+             return paHostError;
+          }
       }
-+     return 0;
+!     
+      return result;
+  }
+  
+  PaError Pa_SetupOutputDeviceFormat( int devHandle, int numChannels, int sampleRate )
+  {
+!   return Pa_SetupDeviceFormat(devHandle, numChannels, sampleRate);
+  }
+  
+  PaError Pa_SetupInputDeviceFormat( int devHandle, int numChannels, int sampleRate )
+  {
+!   return Pa_SetupDeviceFormat(devHandle, numChannels, sampleRate);
+  }
+  
+  
+--- 281,332 ----
+             return paHostError;
+          }
+      }
+! 
+! #ifdef __OpenBSD__
+! 
+!     AUDIO_INITINFO(&audio_if);
+! 
+!     switch(input) {
+!     case 2:
+!         audio_if.record.open = 1;
+!         audio_if.record.pause = 0;
+!         audio_if.play.open = 1;
+!         audio_if.play.pause = 0;
+!         break;
+! 
+!     case 1:
+!         audio_if.record.open = 1;
+!         audio_if.record.pause = 0;
+!         break;
+! 
+!     case 0:
+!         audio_if.play.open = 1;
+!         audio_if.play.pause = 0;
+!         break;
+! 
+!     default:
+!        break;
+!     }
+! 
+!     if (ioctl(devHandle, AUDIO_SETINFO, &audio_if) == -1)
+!     {
+!         ERR_RPT(("Pa_SetupDeviceFormat: could not AUDIO_SETINFO for recording on OpenBSD\n" ));
+!         return paHostError;
+!     }
+! 
+! #endif
+! 
+      return result;
+  }
+  
+  PaError Pa_SetupOutputDeviceFormat( int devHandle, int numChannels, int sampleRate )
+  {
+!   return Pa_SetupDeviceFormat(devHandle, numChannels, sampleRate, 0);
+  }
+  
+  PaError Pa_SetupInputDeviceFormat( int devHandle, int numChannels, int sampleRate )
+  {
+!   return Pa_SetupDeviceFormat(devHandle, numChannels, sampleRate, 1);
   }
   
   
