From fe9fdd0e3de3e1060a4dbe32e32a72ce80c1cf46 Mon Sep 17 00:00:00 2001 From: darkeye Date: Tue, 18 Sep 2001 14:57:19 +0000 Subject: [PATCH] finalized Solaris port --- darkice/trunk/configure.in | 5 +- darkice/trunk/src/AudioEncoder.h | 32 +++++++++++- darkice/trunk/src/AudioSource.h | 11 +++++ darkice/trunk/src/LameLibEncoder.cpp | 68 +++++++++++++++++++------- darkice/trunk/src/OssDspSource.h | 14 ++++++ darkice/trunk/src/SolarisDspSource.h | 14 ++++++ darkice/trunk/src/VorbisLibEncoder.cpp | 68 +++++++++++++++++++------- 7 files changed, 173 insertions(+), 39 deletions(-) diff --git a/darkice/trunk/configure.in b/darkice/trunk/configure.in index 813c301..7a1d6ed 100644 --- a/darkice/trunk/configure.in +++ b/darkice/trunk/configure.in @@ -13,9 +13,11 @@ AC_HAVE_HEADERS(signal.h time.h sys/time.h sys/types.h sys/wait.h) AC_HAVE_HEADERS(netdb.h netinet/in.h sys/ioctl.h sys/socket.h sys/stat.h) AC_HAVE_HEADERS(sched.h) AC_HAVE_HEADERS(sys/soundcard.h sys/audio.h) -AC_HAVE_HEADERS(lame/lame.h vorbis/vorbisenc.h) AC_HEADER_SYS_WAIT() +AC_CHECK_HEADERS(lame/lame.h) +AC_CHECK_HEADERS(vorbis/vorbisenc.h) + AC_TYPE_PID_T() AC_TYPE_SIZE_T() @@ -24,6 +26,7 @@ AC_SUBST(LINK_STATIC) AC_CHECK_LIB( socket, socket) AC_CHECK_LIB( nsl, gethostbyname) AC_CHECK_LIB( rt, sched_getscheduler) +AC_CHECK_LIB( ogg, ogg_stream_init) AC_CHECK_LIB( vorbis, vorbis_info_init) AC_CHECK_LIB( vorbisenc, vorbis_encode_init) AC_CHECK_LIB( mp3lame, lame_init) diff --git a/darkice/trunk/src/AudioEncoder.h b/darkice/trunk/src/AudioEncoder.h index 0bab8bf..7288968 100644 --- a/darkice/trunk/src/AudioEncoder.h +++ b/darkice/trunk/src/AudioEncoder.h @@ -74,6 +74,11 @@ class AudioEncoder : public Sink, public virtual Referable */ unsigned int inChannel; + /** + * Is the input big endian or little endian? + */ + bool inBigEndian; + /** * Bit rate of the output. (bits/sec) */ @@ -95,6 +100,7 @@ class AudioEncoder : public Sink, public virtual Referable * @param inSampleRate sample rate of the input. * @param inBitsPerSample number of bits per sample of the input. * @param inChannel number of channels of the input. + * @param inBigEndian shows if the input is big or little endian * @param outBitrate bit rate of the output. * @param outSampleRate sample rate of the output. * @param outChannel number of channels of the output. @@ -104,6 +110,7 @@ class AudioEncoder : public Sink, public virtual Referable init ( unsigned int inSampleRate, unsigned int inBitsPerSample, unsigned int inChannel, + bool inBigEndian, unsigned int outBitrate, unsigned int outSampleRate, unsigned int outChannel ) throw ( Exception ) @@ -111,6 +118,7 @@ class AudioEncoder : public Sink, public virtual Referable this->inSampleRate = inSampleRate; this->inBitsPerSample = inBitsPerSample; this->inChannel = inChannel; + this->inBigEndian = inBigEndian; this->outBitrate = outBitrate; this->outSampleRate = outSampleRate; this->outChannel = outChannel; @@ -146,6 +154,7 @@ class AudioEncoder : public Sink, public virtual Referable * @param inSampleRate sample rate of the input. * @param inBitsPerSample number of bits per sample of the input. * @param inChannel number of channels of the input. + * @param inBigEndian shows if the input is big or little endian * @param outBitrate bit rate of the output (bits/sec). * @param outSampleRate sample rate of the output. * If 0, inSampleRate is used. @@ -157,6 +166,7 @@ class AudioEncoder : public Sink, public virtual Referable AudioEncoder ( unsigned int inSampleRate, unsigned int inBitsPerSample, unsigned int inChannel, + bool inBigEndian, unsigned int outBitrate, unsigned int outSampleRate = 0, unsigned int outChannel = 0 ) @@ -164,7 +174,8 @@ class AudioEncoder : public Sink, public virtual Referable { init ( inSampleRate, inBitsPerSample, - inChannel, + inChannel, + inBigEndian, outBitrate, outSampleRate ? outSampleRate : inSampleRate, outChannel ? outChannel : inChannel ); @@ -191,7 +202,8 @@ class AudioEncoder : public Sink, public virtual Referable { init( as->getSampleRate(), as->getBitsPerSample(), - as->getChannel(), + as->getChannel(), + as->isBigEndian(), outBitrate, outSampleRate ? outSampleRate : as->getSampleRate(), outChannel ? outChannel : as->getChannel() ); @@ -208,6 +220,7 @@ class AudioEncoder : public Sink, public virtual Referable init ( encoder.inSampleRate, encoder.inBitsPerSample, encoder.inChannel, + encoder.inBigEndian, encoder.outBitrate, encoder.outSampleRate, encoder.outChannel ); @@ -229,6 +242,7 @@ class AudioEncoder : public Sink, public virtual Referable init ( encoder.inSampleRate, encoder.inBitsPerSample, encoder.inChannel, + encoder.inBigEndian, encoder.outBitrate, encoder.outSampleRate, encoder.outChannel ); @@ -262,6 +276,17 @@ class AudioEncoder : public Sink, public virtual Referable return inChannel; } + /** + * Tell if the input is big or little endian. + * + * @return true if the input is big endian, false if little endian. + */ + inline bool + isInBigEndian ( void ) const throw () + { + return inBigEndian; + } + /** * Get the sample rate of the input. * @@ -360,6 +385,9 @@ class AudioEncoder : public Sink, public virtual Referable $Source$ $Log$ + Revision 1.4 2001/09/18 14:57:19 darkeye + finalized Solaris port + Revision 1.3 2001/09/14 19:31:06 darkeye added IceCast2 / vorbis support diff --git a/darkice/trunk/src/AudioSource.h b/darkice/trunk/src/AudioSource.h index 665a4c0..a08f631 100644 --- a/darkice/trunk/src/AudioSource.h +++ b/darkice/trunk/src/AudioSource.h @@ -180,6 +180,14 @@ class AudioSource : public Source return channel; } + /** + * Tell if the data from this source comes in big or little endian. + * + * @return true if the data is big endian, false if little endian + */ + virtual bool + isBigEndian ( void ) const throw () = 0; + /** * Get the sample rate per seconds for this AudioSource. * @@ -244,6 +252,9 @@ typedef class SolarisDspSource DspSource; $Source$ $Log$ + Revision 1.5 2001/09/18 14:57:19 darkeye + finalized Solaris port + Revision 1.4 2001/09/11 15:05:21 darkeye added Solaris support diff --git a/darkice/trunk/src/LameLibEncoder.cpp b/darkice/trunk/src/LameLibEncoder.cpp index 7421bc2..a22411f 100644 --- a/darkice/trunk/src/LameLibEncoder.cpp +++ b/darkice/trunk/src/LameLibEncoder.cpp @@ -240,30 +240,59 @@ LameLibEncoder :: conv16 ( unsigned char * pcmBuffer, short int * rightBuffer, unsigned int channels ) { - if ( channels == 1 ) { - unsigned int i, j; + if ( isInBigEndian() ) { + if ( channels == 1 ) { + unsigned int i, j; - for ( i = 0, j = 0; i < lenPcmBuffer; ) { - unsigned short int value; + for ( i = 0, j = 0; i < lenPcmBuffer; ) { + unsigned short int value; - value = pcmBuffer[i++]; - value |= pcmBuffer[i++] << 8; - leftBuffer[j] = (short int) value; - ++j; + value = pcmBuffer[i++] << 8; + value |= pcmBuffer[i++]; + leftBuffer[j] = (short int) value; + ++j; + } + } else { + unsigned int i, j; + + for ( i = 0, j = 0; i < lenPcmBuffer; ) { + unsigned short int value; + + value = pcmBuffer[i++] << 8; + value |= pcmBuffer[i++]; + leftBuffer[j] = (short int) value; + value = pcmBuffer[i++] << 8; + value |= pcmBuffer[i++]; + rightBuffer[j] = (short int) value; + ++j; + } } } else { - unsigned int i, j; + if ( channels == 1 ) { + unsigned int i, j; - for ( i = 0, j = 0; i < lenPcmBuffer; ) { - unsigned short int value; + for ( i = 0, j = 0; i < lenPcmBuffer; ) { + unsigned short int value; - value = pcmBuffer[i++]; - value |= pcmBuffer[i++] << 8; - leftBuffer[j] = (short int) value; - value = pcmBuffer[i++]; - value |= pcmBuffer[i++] << 8; - rightBuffer[j] = (short int) value; - ++j; + value = pcmBuffer[i++]; + value |= pcmBuffer[i++] << 8; + leftBuffer[j] = (short int) value; + ++j; + } + } else { + unsigned int i, j; + + for ( i = 0, j = 0; i < lenPcmBuffer; ) { + unsigned short int value; + + value = pcmBuffer[i++]; + value |= pcmBuffer[i++] << 8; + leftBuffer[j] = (short int) value; + value = pcmBuffer[i++]; + value |= pcmBuffer[i++] << 8; + rightBuffer[j] = (short int) value; + ++j; + } } } } @@ -385,6 +414,9 @@ LameLibEncoder :: close ( void ) throw ( Exception ) $Source$ $Log$ + Revision 1.7 2001/09/18 14:57:19 darkeye + finalized Solaris port + Revision 1.6 2001/09/15 11:35:08 darkeye minor fixes diff --git a/darkice/trunk/src/OssDspSource.h b/darkice/trunk/src/OssDspSource.h index 6cffd9d..281ce56 100644 --- a/darkice/trunk/src/OssDspSource.h +++ b/darkice/trunk/src/OssDspSource.h @@ -173,6 +173,17 @@ class OssDspSource : public AudioSource, public virtual Reporter return *this; } + /** + * Tell if the data from this source comes in big or little endian. + * + * @return false + */ + virtual inline bool + isBigEndian ( void ) const throw () + { + return false; + } + /** * Open the OssDspSource. * This does not put the OSS DSP device into recording mode. @@ -251,6 +262,9 @@ class OssDspSource : public AudioSource, public virtual Reporter $Source$ $Log$ + Revision 1.5 2001/09/18 14:57:19 darkeye + finalized Solaris port + Revision 1.4 2001/09/02 14:08:40 darkeye setting the sound card recording sample rate is now more relaxed there is no error reported if the sample rate is not exactly the same diff --git a/darkice/trunk/src/SolarisDspSource.h b/darkice/trunk/src/SolarisDspSource.h index 383a5a3..5c8ce4b 100644 --- a/darkice/trunk/src/SolarisDspSource.h +++ b/darkice/trunk/src/SolarisDspSource.h @@ -174,6 +174,17 @@ class SolarisDspSource : public AudioSource, public virtual Reporter return *this; } + /** + * Tell if the data from this source comes in big or little endian. + * + * @return true + */ + virtual inline bool + isBigEndian ( void ) const throw () + { + return true; + } + /** * Open the SolarisDspSource. * This does not put the Solaris DSP device into recording mode. @@ -252,6 +263,9 @@ class SolarisDspSource : public AudioSource, public virtual Reporter $Source$ $Log$ + Revision 1.2 2001/09/18 14:57:19 darkeye + finalized Solaris port + Revision 1.1 2001/09/11 15:05:21 darkeye added Solaris support diff --git a/darkice/trunk/src/VorbisLibEncoder.cpp b/darkice/trunk/src/VorbisLibEncoder.cpp index ee24088..e2d48a2 100644 --- a/darkice/trunk/src/VorbisLibEncoder.cpp +++ b/darkice/trunk/src/VorbisLibEncoder.cpp @@ -179,30 +179,59 @@ VorbisLibEncoder :: conv16 ( unsigned char * pcmBuffer, float * rightBuffer, unsigned int channels ) { - if ( channels == 1 ) { - unsigned int i, j; + if ( isInBigEndian() ) { + if ( channels == 1 ) { + unsigned int i, j; - for ( i = 0, j = 0; i < lenPcmBuffer; ) { - short int value; + for ( i = 0, j = 0; i < lenPcmBuffer; ) { + short int value; - value = pcmBuffer[i++]; - value |= pcmBuffer[i++] << 8; - leftBuffer[j] = ((float) value) / 32768.f; - ++j; + value = pcmBuffer[i++] << 8; + value |= pcmBuffer[i++]; + leftBuffer[j] = ((float) value) / 32768.f; + ++j; + } + } else { + unsigned int i, j; + + for ( i = 0, j = 0; i < lenPcmBuffer; ) { + short int value; + + value = pcmBuffer[i++] << 8; + value |= pcmBuffer[i++]; + leftBuffer[j] = ((float) value) / 32768.f; + value = pcmBuffer[i++] << 8; + value |= pcmBuffer[i++]; + rightBuffer[j] = ((float) value) / 32768.f; + ++j; + } } } else { - unsigned int i, j; + if ( channels == 1 ) { + unsigned int i, j; - for ( i = 0, j = 0; i < lenPcmBuffer; ) { - short int value; + for ( i = 0, j = 0; i < lenPcmBuffer; ) { + short int value; - value = pcmBuffer[i++]; - value |= pcmBuffer[i++] << 8; - leftBuffer[j] = ((float) value) / 32768.f; - value = pcmBuffer[i++]; - value |= pcmBuffer[i++] << 8; - rightBuffer[j] = ((float) value) / 32768.f; - ++j; + value = pcmBuffer[i++]; + value |= pcmBuffer[i++] << 8; + leftBuffer[j] = ((float) value) / 32768.f; + ++j; + } + } else { + unsigned int i, j; + + for ( i = 0, j = 0; i < lenPcmBuffer; ) { + short int value; + + value = pcmBuffer[i++]; + value |= pcmBuffer[i++] << 8; + leftBuffer[j] = ((float) value) / 32768.f; + value = pcmBuffer[i++]; + value |= pcmBuffer[i++] << 8; + rightBuffer[j] = ((float) value) / 32768.f; + ++j; + } } } } @@ -325,6 +354,9 @@ VorbisLibEncoder :: close ( void ) throw ( Exception ) $Source$ $Log$ + Revision 1.3 2001/09/18 14:57:19 darkeye + finalized Solaris port + Revision 1.2 2001/09/15 11:36:22 darkeye added function vorbisBlocksOut(), finalized vorbis support