finalized Solaris port

This commit is contained in:
darkeye 2001-09-18 14:57:19 +00:00
parent 89d82d4477
commit fe9fdd0e3d
7 changed files with 173 additions and 39 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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