Add FreeBSD support

This commit is contained in:
Michal Pasternak 2004-03-31 15:23:26 +00:00 committed by Thomas Klausner
parent 25d430285d
commit 3a5cb638b0
8 changed files with 240 additions and 236 deletions

View file

@ -1,13 +1,13 @@
$NetBSD: distinfo,v 1.7 2004/03/20 21:59:32 mpasternak Exp $
$NetBSD: distinfo,v 1.8 2004/03/31 15:23:26 mpasternak Exp $
SHA1 (fastaudio.tar.gz) = 33fb0d8ca0daf356cacc3cff5ee1674f16d31c98
Size (fastaudio.tar.gz) = 179086 bytes
SHA1 (portaudio_v18_1.zip) = a460ac5484137d77df17a95ce844ff7f178305b1
Size (portaudio_v18_1.zip) = 550130 bytes
SHA1 (patch-aa) = e522bfbf7f69d6f15fd0a32e01a480db922acc56
SHA1 (patch-ab) = f2c5e59df34567ff3af51a9665cbed4efd6fc192
SHA1 (patch-ac) = e6e8e11d7952be8347a6f3289e62b24ca56bf3c6
SHA1 (patch-ad) = 5a343e721ae183facc58195026c7e5c49536632a
SHA1 (patch-ae) = c2744f10d80a478ad571fcce82bf301d6c50cb59
SHA1 (patch-af) = 4dfbc63c44b6ae75b4cf5e6e7c498bc3057c1850
SHA1 (patch-ag) = 3a958b3ee725115937c8105a81597bc46c719696
SHA1 (patch-aa) = 1135c0c551e1e99e6a86fa4dcf101564e544ab28
SHA1 (patch-ab) = 5b5f8de4e7e7eb352e6ff6007c63d0860c4cb176
SHA1 (patch-ac) = 6741f3e2311034682008dcf64d88ee0c94c4a250
SHA1 (patch-ad) = 18c92cd9e231f6d775352f38ef3eb24bd09ab456
SHA1 (patch-ae) = e54dd827b7cf33fd2e2e5c7b1c00f0d133355087
SHA1 (patch-af) = f501d87b9b0d33007e2274bc7768e7b9d89768a2
SHA1 (patch-ag) = 2317b1346678e6fd0e06388d92326bdbab9b4280

View file

@ -1,99 +1,13 @@
$NetBSD: patch-aa,v 1.1.1.1 2003/11/22 17:23:43 mpasternak Exp $
$NetBSD: patch-aa,v 1.2 2004/03/31 15:23:27 mpasternak Exp $
--- pa_unix_oss/pa_unix.c.orig Sat Nov 22 17:06:46 2003
+++ pa_unix_oss/pa_unix.c Sat Nov 22 17:13:50 2003
@@ -375,7 +375,11 @@
* and the watchdog will detect it.
*/
-#define SCHEDULER_POLICY SCHED_RR
+#ifndef _POSIX_THREAD_IS_GNU_PTH
+# define SCHEDULER_POLICY SCHED_RR
+#else
+# define SCHEDULER_POLICY 0
+#endif
#define WATCHDOG_MAX_SECONDS (3)
#define WATCHDOG_INTERVAL_USEC (1000000)
@@ -411,13 +415,16 @@
static PaError PaHost_WatchDogProc( PaHostSoundControl *pahsc )
{
+#ifndef _POSIX_THREAD_IS_GNU_PTH
struct sched_param schp = { 0 };
+#endif
int maxPri;
#ifdef GNUSTEP
GSRegisterCurrentThread(); /* SB20010904 */
#endif
+#ifndef _POSIX_THREAD_IS_GNU_PTH
/* Run at a priority level above audio thread so we can still run if it hangs. */
/* Rise more than 1 because of rumored off-by-one scheduler bugs. */
schp.sched_priority = pahsc->pahsc_AudioPriority + 4;
@@ -429,7 +436,7 @@
ERR_RPT(("PaHost_WatchDogProc: cannot set watch dog priority!\n"));
goto killAudio;
}
-
+#endif
/* Compare watchdog time with audio and canary thread times. */
/* Sleep for a while or until thread cancelled. */
while( pahsc->pahsc_WatchDogRun )
@@ -465,7 +472,8 @@
return 0;
lowerAudio:
- {
+#ifndef _POSIX_THREAD_IS_GNU_PTH
+ {
struct sched_param schat = { 0 };
if( sched_setscheduler(pahsc->pahsc_AudioThreadPID, SCHED_OTHER, &schat) != 0)
{
@@ -478,7 +486,9 @@
goto cleanup;
}
}
-
+#else
+ goto cleanup;
+#endif
killAudio:
ERR_RPT(("PaHost_WatchDogProc: killing hung audio thread!\n"));
pthread_kill( pahsc->pahsc_AudioThread, SIGKILL );
@@ -574,18 +584,19 @@
{
PaHostSoundControl *pahsc;
PaError result = paNoError;
+#ifndef _POSIX_THREAD_IS_GNU_PTH
struct sched_param schp = { 0 };
-
+#endif
pahsc = (PaHostSoundControl *) past->past_DeviceData;
if( pahsc == NULL ) return paInternalError;
pahsc->pahsc_AudioThreadPID = getpid();
DBUG(("PaHost_BoostPriority: audio PID = %d\n", pahsc->pahsc_AudioThreadPID ));
-
+#ifndef _POSIX_THREAD_IS_GNU_PTH
/* Choose a priority in the middle of the range. */
pahsc->pahsc_AudioPriority = (sched_get_priority_max(SCHEDULER_POLICY) -
sched_get_priority_min(SCHEDULER_POLICY)) / 2;
- schp.sched_priority = pahsc->pahsc_AudioPriority;
+ schp.sched_priority = pahsc->pahsc_AudioPriority;
if (sched_setscheduler(0, SCHEDULER_POLICY, &schp) != 0)
{
@@ -597,7 +608,10 @@
/* We are running at high priority so we should have a watchdog in case audio goes wild. */
result = PaHost_StartWatchDog( pahsc );
}
-
+#else
+ DBUG(("PortAudio: audio callback priority set to level %d - call ignored with GNU Pth\n", schp.sched_priority));
+ result = PaHost_StartWatchDog( pahsc );
+#endif
return result;
}
--- Makefile.in.orig Tue Feb 11 23:24:56 2003
+++ Makefile.in
@@ -7,7 +7,7 @@
PREFIX = @prefix@
CC = @CC@
CFLAGS = @CFLAGS@ -Ipa_common
-LIBS = @LIBS@
+LIBS = -lossaudio -L@prefix@/lib -Wl,-R@prefix@/lib @LIBS@
AR = @AR@
RANLIB = @RANLIB@
INSTALL = @INSTALL@

View file

@ -1,34 +1,11 @@
$NetBSD: patch-ab,v 1.3 2003/11/26 01:42:51 mpasternak Exp $
$NetBSD: patch-ab,v 1.4 2004/03/31 15:23:27 mpasternak Exp $
--- pa_unix_oss/pa_unix_oss.c.orig Mon Jun 30 11:05:50 2003
+++ pa_unix_oss/pa_unix_oss.c Wed Nov 26 02:28:19 2003
@@ -44,7 +44,12 @@
#ifdef __linux__
#include <linux/soundcard.h>
--- mysndfile.h.orig Wed May 7 00:06:01 2003
+++ mysndfile.h
@@ -1,5 +1,5 @@
#ifdef WIN32
#include "sndfile-win32.h"
#else
-#include <machine/soundcard.h> /* JH20010905 */
+# ifdef __NetBSD__
+# include <soundcard.h>
+# include <sys/audioio.h>
+# else
+# include <machine/soundcard.h> /* JH20010905 */
+# endif
-#include "sndfile.h"
+#include <sndfile.h>
#endif
@@ -237,7 +242,14 @@
return paHostError;
}
-
+#ifdef __NetBSD__
+ tmp = 1;
+ if ( ioctl(devHandle,AUDIO_SETFD, &tmp) == -1) {
+ ERR_RPT(("Pa_SetupDeviceFormat: could not AUDIO_SETFD. Fastaudio will properly work on NetBSD only with full-duplex soundcard.\n" ));
+ return paHostError;
+ }
+#endif
+
/* Set number of channels. */
tmp = numChannels;
if (ioctl(devHandle, SNDCTL_DSP_CHANNELS, &numChannels) == -1)

View file

@ -1,13 +1,20 @@
$NetBSD: patch-ac,v 1.1.1.1 2003/11/22 17:23:43 mpasternak Exp $
$NetBSD: patch-ac,v 1.2 2004/03/31 15:23:27 mpasternak Exp $
--- Makefile.in~ Tue Feb 11 23:24:56 2003
+++ Makefile.in Sat Nov 22 17:18:08 2003
@@ -7,7 +7,7 @@
PREFIX = @prefix@
CC = @CC@
CFLAGS = @CFLAGS@ -Ipa_common
-LIBS = @LIBS@
+LIBS = -lossaudio -L@prefix@/lib -Wl,-R@prefix@/lib @LIBS@
AR = @AR@
RANLIB = @RANLIB@
INSTALL = @INSTALL@
--- pa_tests/patest_record.c.orig Wed Apr 16 12:07:56 2003
+++ pa_tests/patest_record.c
@@ -133,6 +133,7 @@ static int playCallback( void *inputBuff
unsigned long framesPerBuffer,
PaTimestamp outTime, void *userData )
{
+ int framesToPlay, samplesToPlay, samplesPerBuffer;
paTestData *data = (paTestData*)userData;
SAMPLE *rptr = &data->recordedSamples[data->frameIndex * NUM_CHANNELS];
SAMPLE *wptr = (SAMPLE*)outputBuffer;
@@ -141,7 +142,6 @@ static int playCallback( void *inputBuff
unsigned int framesLeft = data->maxFrameIndex - data->frameIndex;
(void) inputBuffer; /* Prevent unused variable warnings. */
(void) outTime;
- int framesToPlay, samplesToPlay, samplesPerBuffer;
if( framesLeft < framesPerBuffer )
{

View file

@ -1,20 +1,15 @@
$NetBSD: patch-ad,v 1.1.1.1 2003/11/22 17:23:43 mpasternak Exp $
$NetBSD: patch-ad,v 1.2 2004/03/31 15:23:27 mpasternak Exp $
--- pa_tests/patest_record.c.orig Sat Nov 22 17:26:48 2003
+++ pa_tests/patest_record.c Sat Nov 22 17:27:12 2003
@@ -133,6 +133,7 @@
unsigned long framesPerBuffer,
PaTimestamp outTime, void *userData )
{
+ int framesToPlay, samplesToPlay, samplesPerBuffer;
paTestData *data = (paTestData*)userData;
SAMPLE *rptr = &data->recordedSamples[data->frameIndex * NUM_CHANNELS];
SAMPLE *wptr = (SAMPLE*)outputBuffer;
@@ -141,7 +142,6 @@
unsigned int framesLeft = data->maxFrameIndex - data->frameIndex;
(void) inputBuffer; /* Prevent unused variable warnings. */
(void) outTime;
- int framesToPlay, samplesToPlay, samplesPerBuffer;
if( framesLeft < framesPerBuffer )
{
--- pa_tests/patest_wire.c.orig Thu Apr 10 16:09:40 2003
+++ pa_tests/patest_wire.c
@@ -74,9 +74,9 @@ static int wireCallback( void *inputBuff
SAMPLE *out = (SAMPLE*)outputBuffer;
SAMPLE *in = (SAMPLE*)inputBuffer;
unsigned int i;
- (void) outTime;
int samplesPerFrame;
int numSamples;
+ (void) outTime;
samplesPerFrame = (int) userData;
numSamples = framesPerBuffer * samplesPerFrame;

View file

@ -1,15 +1,99 @@
$NetBSD: patch-ae,v 1.1.1.1 2003/11/22 17:23:42 mpasternak Exp $
$NetBSD: patch-ae,v 1.2 2004/03/31 15:23:27 mpasternak Exp $
--- pa_tests/patest_wire.c.orig Sat Nov 22 17:27:23 2003
+++ pa_tests/patest_wire.c Sat Nov 22 17:27:54 2003
@@ -74,9 +74,9 @@
SAMPLE *out = (SAMPLE*)outputBuffer;
SAMPLE *in = (SAMPLE*)inputBuffer;
unsigned int i;
- (void) outTime;
int samplesPerFrame;
int numSamples;
+ (void) outTime;
samplesPerFrame = (int) userData;
numSamples = framesPerBuffer * samplesPerFrame;
--- pa_unix_oss/pa_unix.c.orig Mon Jun 30 11:05:50 2003
+++ pa_unix_oss/pa_unix.c
@@ -375,7 +375,11 @@ PaError PaHost_Init( void )
* and the watchdog will detect it.
*/
-#define SCHEDULER_POLICY SCHED_RR
+#ifndef _POSIX_THREAD_IS_GNU_PTH
+# define SCHEDULER_POLICY SCHED_RR
+#else
+# define SCHEDULER_POLICY 0
+#endif
#define WATCHDOG_MAX_SECONDS (3)
#define WATCHDOG_INTERVAL_USEC (1000000)
@@ -411,13 +415,16 @@ static int PaHost_CanaryProc( PaHostSoun
static PaError PaHost_WatchDogProc( PaHostSoundControl *pahsc )
{
+#ifndef _POSIX_THREAD_IS_GNU_PTH
struct sched_param schp = { 0 };
+#endif
int maxPri;
#ifdef GNUSTEP
GSRegisterCurrentThread(); /* SB20010904 */
#endif
+#ifndef _POSIX_THREAD_IS_GNU_PTH
/* Run at a priority level above audio thread so we can still run if it hangs. */
/* Rise more than 1 because of rumored off-by-one scheduler bugs. */
schp.sched_priority = pahsc->pahsc_AudioPriority + 4;
@@ -429,7 +436,7 @@ static PaError PaHost_WatchDogProc( PaHo
ERR_RPT(("PaHost_WatchDogProc: cannot set watch dog priority!\n"));
goto killAudio;
}
-
+#endif
/* Compare watchdog time with audio and canary thread times. */
/* Sleep for a while or until thread cancelled. */
while( pahsc->pahsc_WatchDogRun )
@@ -465,7 +472,8 @@ static PaError PaHost_WatchDogProc( PaHo
return 0;
lowerAudio:
- {
+#ifndef _POSIX_THREAD_IS_GNU_PTH
+ {
struct sched_param schat = { 0 };
if( sched_setscheduler(pahsc->pahsc_AudioThreadPID, SCHED_OTHER, &schat) != 0)
{
@@ -478,7 +486,9 @@ lowerAudio:
goto cleanup;
}
}
-
+#else
+ goto cleanup;
+#endif
killAudio:
ERR_RPT(("PaHost_WatchDogProc: killing hung audio thread!\n"));
pthread_kill( pahsc->pahsc_AudioThread, SIGKILL );
@@ -574,18 +584,19 @@ static PaError PaHost_BoostPriority( int
{
PaHostSoundControl *pahsc;
PaError result = paNoError;
+#ifndef _POSIX_THREAD_IS_GNU_PTH
struct sched_param schp = { 0 };
-
+#endif
pahsc = (PaHostSoundControl *) past->past_DeviceData;
if( pahsc == NULL ) return paInternalError;
pahsc->pahsc_AudioThreadPID = getpid();
DBUG(("PaHost_BoostPriority: audio PID = %d\n", pahsc->pahsc_AudioThreadPID ));
-
+#ifndef _POSIX_THREAD_IS_GNU_PTH
/* Choose a priority in the middle of the range. */
pahsc->pahsc_AudioPriority = (sched_get_priority_max(SCHEDULER_POLICY) -
sched_get_priority_min(SCHEDULER_POLICY)) / 2;
- schp.sched_priority = pahsc->pahsc_AudioPriority;
+ schp.sched_priority = pahsc->pahsc_AudioPriority;
if (sched_setscheduler(0, SCHEDULER_POLICY, &schp) != 0)
{
@@ -597,7 +608,10 @@ static PaError PaHost_BoostPriority( int
/* We are running at high priority so we should have a watchdog in case audio goes wild. */
result = PaHost_StartWatchDog( pahsc );
}
-
+#else
+ DBUG(("PortAudio: audio callback priority set to level %d - call ignored with GNU Pth\n", schp.sched_priority));
+ result = PaHost_StartWatchDog( pahsc );
+#endif
return result;
}

View file

@ -1,48 +1,38 @@
$NetBSD: patch-af,v 1.4 2004/03/20 21:59:33 mpasternak Exp $
$NetBSD: patch-af,v 1.5 2004/03/31 15:23:27 mpasternak Exp $
--- setup.py.orig Wed May 7 02:06:01 2003
+++ setup.py Mon Nov 24 02:45:20 2003
@@ -2,23 +2,37 @@
from distutils.extension import Extension
from Pyrex.Distutils import build_ext
--- pa_unix_oss/pa_unix_oss.c.orig Mon Jun 30 11:05:50 2003
+++ pa_unix_oss/pa_unix_oss.c
@@ -44,7 +44,16 @@
#ifdef __linux__
#include <linux/soundcard.h>
#else
-#include <machine/soundcard.h> /* JH20010905 */
+# ifdef __NetBSD__
+# include <soundcard.h>
+# include <sys/audioio.h>
+# else
+# ifdef __FreeBSD__
+# include <sys/soundcard.h>
+# else
+# include <machine/soundcard.h> /* JH20010905 */
+# endif
+# endif
#endif
-import sys
+import sys, os
+ROOTDIR = os.path.abspath(os.path.dirname(sys.argv[0]))
+PREFIX = os.environ['PREFIX']
+try:
+ LIBOSSAUDIO = os.environ['LIBOSSAUDIO']
+except:
+ LIBOSSAUDIO = None
if sys.platform == 'win32':
- faSources=['fastaudio.pyx', '../pa_common/pa_lib.c', '../pa_win_wmme/pa_win_wmme.c']
+ faSources=['fastaudio.pyx', ROOTDIR + '/pa_common/pa_lib.c', ROOTDIR + '/pa_win_wmme/pa_win_wmme.c']
defines = [('WIN32', 1)]
libs = ['winmm', 'libsndfile']
extra_link_args = []
-elif sys.platform.find('linux') != -1:
- faSources=['fastaudio.pyx', '../pa_common/pa_lib.c', '../pa_unix_oss/pa_unix_oss.c']
+else: # you can add more sys.platform deps later
+ faSources=['fastaudio.pyx', ROOTDIR + '/pa_common/pa_lib.c',
+ ROOTDIR + '/pa_unix_oss/pa_unix.c',
+ ROOTDIR + '/pa_unix_oss/pa_unix_oss.c']
defines = []
libs = ['sndfile']
- extra_link_args = ['/usr/lib/libsndfile.a']
+ extra_link_args = [PREFIX + '/lib/libsndfile.a']
+ if LIBOSSAUDIO is not None:
+ extra_link_args.append(LIBOSSAUDIO)
+# try: # This has been commented out to make it build on -current, please check other OSs, as I can't do that now -- dotz@irc.pl
+# extra_link_args.append(os.environ['PTHREAD_LDFLAGS'])
+# except KeyError:
+# pass
#faSources=['fastaudio.pyx']
@@ -237,7 +246,14 @@ PaError Pa_SetupDeviceFormat( int devHan
return paHostError;
}
ext_fastaudio = [Extension('fastaudio',
faSources,
- include_dirs=['../pa_common'],
+ include_dirs=[ROOTDIR + '/pa_common', ROOTDIR, os.path.join(PREFIX, 'include')],
define_macros=defines,
libraries=libs,
extra_link_args=extra_link_args
-
+#ifdef __NetBSD__
+ tmp = 1;
+ if ( ioctl(devHandle,AUDIO_SETFD, &tmp) == -1) {
+ ERR_RPT(("Pa_SetupDeviceFormat: could not AUDIO_SETFD. Fastaudio will properly work on NetBSD only with full-duplex soundcard.\n" ));
+ return paHostError;
+ }
+#endif
+
/* Set number of channels. */
tmp = numChannels;
if (ioctl(devHandle, SNDCTL_DSP_CHANNELS, &numChannels) == -1)

View file

@ -1,11 +1,48 @@
$NetBSD: patch-ag,v 1.1.1.1 2003/11/22 17:23:43 mpasternak Exp $
$NetBSD: patch-ag,v 1.2 2004/03/31 15:23:27 mpasternak Exp $
--- mysndfile.h~ Wed May 7 02:06:01 2003
+++ mysndfile.h Sat Nov 22 18:16:54 2003
@@ -1,5 +1,5 @@
#ifdef WIN32
#include "sndfile-win32.h"
#else
-#include "sndfile.h"
+#include <sndfile.h>
#endif
--- setup.py.orig Wed May 7 00:06:01 2003
+++ setup.py
@@ -2,23 +2,37 @@ from distutils.core import setup
from distutils.extension import Extension
from Pyrex.Distutils import build_ext
-import sys
+import sys, os
+ROOTDIR = os.path.abspath(os.path.dirname(sys.argv[0]))
+PREFIX = os.environ['PREFIX']
+try:
+ LIBOSSAUDIO = os.environ['LIBOSSAUDIO']
+except:
+ LIBOSSAUDIO = None
if sys.platform == 'win32':
- faSources=['fastaudio.pyx', '../pa_common/pa_lib.c', '../pa_win_wmme/pa_win_wmme.c']
+ faSources=['fastaudio.pyx', ROOTDIR + '/pa_common/pa_lib.c', ROOTDIR + '/pa_win_wmme/pa_win_wmme.c']
defines = [('WIN32', 1)]
libs = ['winmm', 'libsndfile']
extra_link_args = []
-elif sys.platform.find('linux') != -1:
- faSources=['fastaudio.pyx', '../pa_common/pa_lib.c', '../pa_unix_oss/pa_unix_oss.c']
+else: # you can add more sys.platform deps later
+ faSources=['fastaudio.pyx', ROOTDIR + '/pa_common/pa_lib.c',
+ ROOTDIR + '/pa_unix_oss/pa_unix.c',
+ ROOTDIR + '/pa_unix_oss/pa_unix_oss.c']
defines = []
libs = ['sndfile']
- extra_link_args = ['/usr/lib/libsndfile.a']
+ extra_link_args = [PREFIX + '/lib/libsndfile.a']
+ if LIBOSSAUDIO is not None:
+ extra_link_args.append(LIBOSSAUDIO)
+# try: # This has been commented out to make it build on -current, please check other OSs, as I can't do that now -- dotz@irc.pl
+# extra_link_args.append(os.environ['PTHREAD_LDFLAGS'])
+# except KeyError:
+# pass
#faSources=['fastaudio.pyx']
ext_fastaudio = [Extension('fastaudio',
faSources,
- include_dirs=['../pa_common'],
+ include_dirs=[ROOTDIR + '/pa_common', ROOTDIR, os.path.join(PREFIX, 'include')],
define_macros=defines,
libraries=libs,
extra_link_args=extra_link_args