From 0fbff7195ec107da5bf11743002dcb5bee0dab3a Mon Sep 17 00:00:00 2001 From: darkeye Date: Wed, 18 Feb 2004 21:08:11 +0000 Subject: [PATCH] ported to OpenBSD (real-time scheduling not yet supported) --- darkice/trunk/ChangeLog | 4 ++++ darkice/trunk/configure.in | 4 ++-- darkice/trunk/src/AudioSource.h | 7 +++++-- darkice/trunk/src/DarkIce.cpp | 13 +++++++++++++ darkice/trunk/src/SolarisDspSource.cpp | 27 +++++++++++++------------- darkice/trunk/src/SolarisDspSource.h | 9 +++------ 6 files changed, 40 insertions(+), 24 deletions(-) diff --git a/darkice/trunk/ChangeLog b/darkice/trunk/ChangeLog index a62e76b..b00cf20 100644 --- a/darkice/trunk/ChangeLog +++ b/darkice/trunk/ChangeLog @@ -1,3 +1,7 @@ +DarkIce next release + + o ported to OpenBSD, though real-time scheduling not yet supported + 15-02-2004: DarkIce 0.14 released o added ALSA support, thanks to Christian Forster diff --git a/darkice/trunk/configure.in b/darkice/trunk/configure.in index 98349db..1e63198 100644 --- a/darkice/trunk/configure.in +++ b/darkice/trunk/configure.in @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(src/DarkIce.cpp) -AM_INIT_AUTOMAKE(darkice, 0.14) +AM_INIT_AUTOMAKE(darkice, 0.15beta) AM_CONFIG_HEADER(config.h) @@ -12,7 +12,7 @@ AC_HAVE_HEADERS(errno.h fcntl.h stdio.h stdlib.h string.h unistd.h limits.h) AC_HAVE_HEADERS(signal.h time.h sys/time.h sys/types.h sys/wait.h math.h) AC_HAVE_HEADERS(netdb.h netinet/in.h sys/ioctl.h sys/socket.h sys/stat.h) AC_HAVE_HEADERS(sched.h pthread.h) -AC_HAVE_HEADERS(sys/soundcard.h sys/audio.h) +AC_HAVE_HEADERS(sys/soundcard.h sys/audio.h sys/audioio.h) AC_HEADER_SYS_WAIT() AC_TYPE_PID_T() diff --git a/darkice/trunk/src/AudioSource.h b/darkice/trunk/src/AudioSource.h index 2a9c1a9..c89cc18 100644 --- a/darkice/trunk/src/AudioSource.h +++ b/darkice/trunk/src/AudioSource.h @@ -58,8 +58,8 @@ #define SUPPORT_OSS_DSP #endif -#if defined( HAVE_SYS_AUDIO_H ) -// we have a Solaris DSP sound device available +#if defined( HAVE_SYS_AUDIO_H ) || defined( HAVE_SYS_AUDIOIO_H ) +// we have a Solaris DSP sound device available (same for OpenBSD) #define SUPPORT_SOLARIS_DSP #endif @@ -288,6 +288,9 @@ class AudioSource : public Source, public virtual Reporter $Source$ $Log$ + Revision 1.7 2004/02/18 21:08:11 darkeye + ported to OpenBSD (real-time scheduling not yet supported) + Revision 1.6 2004/02/15 12:06:29 darkeye added ALSA support, thanks to Christian Forster diff --git a/darkice/trunk/src/DarkIce.cpp b/darkice/trunk/src/DarkIce.cpp index a5a99be..caf881b 100644 --- a/darkice/trunk/src/DarkIce.cpp +++ b/darkice/trunk/src/DarkIce.cpp @@ -873,6 +873,10 @@ DarkIce :: configFileCast ( const Config & config ) void DarkIce :: setRealTimeScheduling ( void ) throw ( Exception ) { +// don't include the following on OpenBSD, as the scheduling functions are +// not implemented. +// FIXME: using HAVE_SYS_AUDIOIO_H as a sign of being on OpenBSD is buggy +#if !defined( HAVE_SYS_AUDIOIO_H ) uid_t euid; euid = geteuid(); @@ -917,6 +921,7 @@ DarkIce :: setRealTimeScheduling ( void ) throw ( Exception ) reportEvent( 1, "It is recommended that you run this program as super-user"); } +#endif } @@ -928,6 +933,10 @@ DarkIce :: setRealTimeScheduling ( void ) throw ( Exception ) void DarkIce :: setOriginalScheduling ( void ) throw ( Exception ) { +// don't include the following on OpenBSD, as the scheduling functions are +// not implemented. +// FIXME: using HAVE_SYS_AUDIOIO_H as a sign of being on OpenBSD is buggy +#if !defined( HAVE_SYS_AUDIOIO_H ) uid_t euid; euid = geteuid(); @@ -947,6 +956,7 @@ DarkIce :: setOriginalScheduling ( void ) throw ( Exception ) reportEvent( 5, "reverted to original scheduling"); } +#endif } @@ -999,6 +1009,9 @@ DarkIce :: run ( void ) throw ( Exception ) $Source$ $Log$ + Revision 1.38 2004/02/18 21:08:11 darkeye + ported to OpenBSD (real-time scheduling not yet supported) + Revision 1.37 2004/02/15 12:14:38 darkeye added patch to allow mp3 stream downsampling to mono for icecast2 as well diff --git a/darkice/trunk/src/SolarisDspSource.cpp b/darkice/trunk/src/SolarisDspSource.cpp index 3aa12d5..18d9c7a 100644 --- a/darkice/trunk/src/SolarisDspSource.cpp +++ b/darkice/trunk/src/SolarisDspSource.cpp @@ -80,10 +80,12 @@ #error need sys/ioctl.h #endif -#ifdef HAVE_SYS_AUDIO_H +#if defined( HAVE_SYS_AUDIO_H ) #include +#elif defined( HAVE_SYS_AUDIOIO_H ) +#include #else -#error need sys/audio.h +#error need sys/audio.h or sys/audioio.h #endif @@ -116,7 +118,6 @@ SolarisDspSource :: init ( const char * name ) throw ( Exception ) { fileName = Util::strDup( name); fileDescriptor = 0; - running = false; } @@ -157,6 +158,9 @@ SolarisDspSource :: open ( void ) throw ( Exception ) audioInfo.record.channels = getChannel(); audioInfo.record.precision = getBitsPerSample(); audioInfo.record.encoding = AUDIO_ENCODING_LINEAR; + // for stupid OpenBSD we need to add the following, as it masks + // read/write calls when using -pthread + audioInfo.record.pause = 0; if ( ioctl( fileDescriptor, AUDIO_SETINFO, &audioInfo) == -1 ) { @@ -185,6 +189,7 @@ SolarisDspSource :: open ( void ) throw ( Exception ) "drift in the sound card driver"); } + return true; } @@ -194,7 +199,7 @@ SolarisDspSource :: open ( void ) throw ( Exception ) *----------------------------------------------------------------------------*/ bool SolarisDspSource :: canRead ( unsigned int sec, - unsigned int usec ) throw ( Exception ) + unsigned int usec ) throw ( Exception ) { fd_set fdset; struct timeval tv; @@ -204,13 +209,6 @@ SolarisDspSource :: canRead ( unsigned int sec, return false; } - if ( !running ) { - /* ugly workaround to get the dsp into recording state */ - unsigned char b[getChannel()*getBitsPerSample()/8]; - - read( b, getChannel()*getBitsPerSample()/8); - } - FD_ZERO( &fdset); FD_SET( fileDescriptor, &fdset); tv.tv_sec = sec; @@ -231,7 +229,7 @@ SolarisDspSource :: canRead ( unsigned int sec, *----------------------------------------------------------------------------*/ unsigned int SolarisDspSource :: read ( void * buf, - unsigned int len ) throw ( Exception ) + unsigned int len ) throw ( Exception ) { ssize_t ret; @@ -245,7 +243,6 @@ SolarisDspSource :: read ( void * buf, throw Exception( __FILE__, __LINE__, "read error"); } - running = true; return ret; } @@ -262,7 +259,6 @@ SolarisDspSource :: close ( void ) throw ( Exception ) ::close( fileDescriptor); fileDescriptor = 0; - running = false; } #endif // SUPPORT_SOLARIS_DSP @@ -273,6 +269,9 @@ SolarisDspSource :: close ( void ) throw ( Exception ) $Source$ $Log$ + Revision 1.2 2004/02/18 21:08:11 darkeye + ported to OpenBSD (real-time scheduling not yet supported) + Revision 1.1 2001/09/11 15:05:21 darkeye added Solaris support diff --git a/darkice/trunk/src/SolarisDspSource.h b/darkice/trunk/src/SolarisDspSource.h index 5c8ce4b..027cedc 100644 --- a/darkice/trunk/src/SolarisDspSource.h +++ b/darkice/trunk/src/SolarisDspSource.h @@ -68,12 +68,6 @@ class SolarisDspSource : public AudioSource, public virtual Reporter */ int fileDescriptor; - /** - * Indicates wether the low-level Solaris DSP device is in a recording - * state. - */ - bool running; - protected: @@ -263,6 +257,9 @@ class SolarisDspSource : public AudioSource, public virtual Reporter $Source$ $Log$ + Revision 1.3 2004/02/18 21:08:11 darkeye + ported to OpenBSD (real-time scheduling not yet supported) + Revision 1.2 2001/09/18 14:57:19 darkeye finalized Solaris port