code cleanup: compiles under gcc-c++ 3.1, using -pedantic option

This commit is contained in:
darkeye 2002-05-28 12:35:41 +00:00
parent 7e9555b97c
commit 0913fefad2
19 changed files with 166 additions and 69 deletions

View File

@ -22,6 +22,8 @@ AC_CHECK_LIB( socket, socket)
AC_CHECK_LIB( nsl, gethostbyname) AC_CHECK_LIB( nsl, gethostbyname)
AC_CHECK_LIB( rt, sched_getscheduler) AC_CHECK_LIB( rt, sched_getscheduler)
SYSTEM_INCLUDE=/usr/include
dnl----------------------------------------------------------------------------- dnl-----------------------------------------------------------------------------
dnl link the lame library if requested dnl link the lame library if requested
@ -44,7 +46,9 @@ if test "x${USE_LAME}" = "xyes" ; then
${CONFIG_LAME_PREFIX}) ${CONFIG_LAME_PREFIX})
if test "x${LAME_LIB_LOC}" != "x" ; then if test "x${LAME_LIB_LOC}" != "x" ; then
AC_DEFINE( HAVE_LAME_LIB, 1, [build with lame library] ) AC_DEFINE( HAVE_LAME_LIB, 1, [build with lame library] )
LAME_INCFLAGS="-I${LAME_INC_LOC}" if test "x${LAME_INC_LOC}" != "x${SYSTEM_INCLUDE}" ; then
LAME_INCFLAGS="-I${LAME_INC_LOC}"
fi
LAME_LDFLAGS="-L${LAME_LIB_LOC} -lmp3lame" LAME_LDFLAGS="-L${LAME_LIB_LOC} -lmp3lame"
AC_MSG_RESULT( [found at ${CONFIG_LAME_PREFIX}] ) AC_MSG_RESULT( [found at ${CONFIG_LAME_PREFIX}] )
else else
@ -85,7 +89,9 @@ if test "x${USE_VORBIS}" = "xyes" ; then
"x${VORBISENC_LIB_LOC}" != "x" ; then "x${VORBISENC_LIB_LOC}" != "x" ; then
AC_DEFINE( HAVE_VORBIS_LIB, 1, [build with Ogg Vorbis library] ) AC_DEFINE( HAVE_VORBIS_LIB, 1, [build with Ogg Vorbis library] )
VORBIS_INCFLAGS="-I${OGG_INC_LOC}" if test "x${OGG_INC_LOC}" != "x${SYSTEM_INCLUDE}" ; then
LAME_INCFLAGS="-I${OGG_INC_LOC}"
fi
VORBIS_LDFLAGS="-L${OGG_LIB_LOC} -logg -lvorbis -lvorbisenc" VORBIS_LDFLAGS="-L${OGG_LIB_LOC} -logg -lvorbis -lvorbisenc"
AC_MSG_RESULT( [found at ${CONFIG_VORBIS_PREFIX}] ) AC_MSG_RESULT( [found at ${CONFIG_VORBIS_PREFIX}] )
else else
@ -114,7 +120,7 @@ if test "x${USE_VORBIS_LIB}" = "xrc3" ; then
fi fi
dnl make sure at least one of lame and vorbis present dnl make sure at least one of lame and vorbis present
if test "x${LAME_INCFLAGS}" = "x" -a "x${VORBIS_INCFLAGS}" = "x" ; then if test "x${LAME_LDFLAGS}" = "x" -a "x${VORBIS_LDFLAGS}" = "x" ; then
AC_MSG_ERROR( [neither lame nor Ogg Vorbis configured]) AC_MSG_ERROR( [neither lame nor Ogg Vorbis configured])
fi fi

View File

@ -361,7 +361,7 @@ class BufferedSink : public Sink, public virtual Reporter
inline virtual void inline virtual void
flush ( void ) throw ( Exception ) flush ( void ) throw ( Exception )
{ {
unsigned char b[0]; unsigned char b[1];
write( b, 0); write( b, 0);
} }
@ -391,6 +391,9 @@ class BufferedSink : public Sink, public virtual Reporter
$Source$ $Source$
$Log$ $Log$
Revision 1.6 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.5 2000/11/15 18:08:42 darkeye Revision 1.5 2000/11/15 18:08:42 darkeye
added multiple verbosity-level event reporting and verbosity command added multiple verbosity-level event reporting and verbosity command
line option line option

View File

@ -35,7 +35,7 @@
#include <iterator> #include <iterator>
#include <iostream.h> #include <iostream>
#include "Config.h" #include "Config.h"
@ -146,7 +146,7 @@ Config :: addLine ( const char * line ) throw ( Exception )
* Add a configuration line * Add a configuration line
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
Config :: read ( istream & is ) throw ( Exception ) Config :: read ( std::istream & is ) throw ( Exception )
{ {
char line[LINE_SIZE]; char line[LINE_SIZE];
unsigned int num; unsigned int num;
@ -170,6 +170,9 @@ Config :: read ( istream & is ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.7 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.6 2001/10/19 09:20:09 darkeye Revision 1.6 2001/10/19 09:20:09 darkeye
config file now may contain tabs also as white space config file now may contain tabs also as white space

View File

@ -39,7 +39,7 @@
#include <map> #include <map>
#include <string> #include <string>
#include <iostream.h> #include <iostream>
#include "Referable.h" #include "Referable.h"
#include "ConfigSection.h" #include "ConfigSection.h"
@ -123,7 +123,7 @@ class Config : public virtual Referable
* @exception Exception * @exception Exception
*/ */
inline inline
Config ( istream & is ) throw ( Exception ) Config ( std::istream & is ) throw ( Exception )
{ {
read( is ); read( is );
} }
@ -184,7 +184,7 @@ class Config : public virtual Referable
* @exception Exception * @exception Exception
*/ */
virtual void virtual void
read ( istream & is ) throw ( Exception ); read ( std::istream & is ) throw ( Exception );
/** /**
* Get a ConfigSection by name. * Get a ConfigSection by name.
@ -213,6 +213,9 @@ class Config : public virtual Referable
$Source$ $Source$
$Log$ $Log$
Revision 1.5 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.4 2001/09/05 20:11:15 darkeye Revision 1.4 2001/09/05 20:11:15 darkeye
removed dependency on locally stored SGI STL header files removed dependency on locally stored SGI STL header files
now compiler-supplied C++ library STL header files are used now compiler-supplied C++ library STL header files are used

View File

@ -35,7 +35,7 @@
#include <iterator> #include <iterator>
#include <iostream.h> #include <iostream>
#include "ConfigSection.h" #include "ConfigSection.h"
@ -106,9 +106,9 @@ ConfigSection :: get ( const char * key ) const throw ( Exception )
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
const char * const char *
ConfigSection :: getForSure ( const char * key, ConfigSection :: getForSure ( const char * key,
const char * message1 = 0, const char * message1,
const char * message2 = 0, const char * message2,
int code = 0 ) const int code ) const
throw ( Exception ) throw ( Exception )
{ {
const char * value; const char * value;
@ -177,6 +177,9 @@ ConfigSection :: addLine ( const char * line ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.8 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.7 2001/10/19 09:20:09 darkeye Revision 1.7 2001/10/19 09:20:09 darkeye
config file now may contain tabs also as white space config file now may contain tabs also as white space

View File

@ -255,7 +255,7 @@ Connector :: transfer ( unsigned long bytes,
{ {
unsigned int u; unsigned int u;
unsigned long b; unsigned long b;
unsigned char buf[bufSize]; unsigned char * buf = new unsigned char[bufSize];
if ( numSinks == 0 ) { if ( numSinks == 0 ) {
return 0; return 0;
@ -308,6 +308,7 @@ Connector :: transfer ( unsigned long bytes,
} }
} }
delete[] buf;
return b; return b;
} }
@ -333,6 +334,9 @@ Connector :: close ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.7 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.6 2001/08/26 20:44:30 darkeye Revision 1.6 2001/08/26 20:44:30 darkeye
removed external command-line encoder support removed external command-line encoder support
replaced it with a shared-object support for lame with the possibility replaced it with a shared-object support for lame with the possibility

View File

@ -46,7 +46,7 @@
#error need unistd.h #error need unistd.h
#endif #endif
#include <iostream.h> #include <iostream>
#include "Referable.h" #include "Referable.h"
#include "Reporter.h" #include "Reporter.h"
@ -309,6 +309,9 @@ class DarkIce : public virtual Referable, public virtual Reporter
$Source$ $Source$
$Log$ $Log$
Revision 1.14 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.13 2002/02/28 09:49:25 darkeye Revision 1.13 2002/02/28 09:49:25 darkeye
added possibility to save the encoded stream to a local file only added possibility to save the encoded stream to a local file only
(no streaming server needed) (no streaming server needed)

View File

@ -66,7 +66,7 @@ Exception :: Exception ( const char * file,
unsigned int line, unsigned int line,
const char * description1, const char * description1,
const char * description2, const char * description2,
int code = 0 ) throw () int code ) throw ()
{ {
size_t len = 0; size_t len = 0;
@ -78,7 +78,7 @@ Exception :: Exception ( const char * file,
} }
if ( len ) { if ( len ) {
char str[len+1]; char * str = new char[len+1];
str[0] = '\0'; str[0] = '\0';
if ( description1 ) { if ( description1 ) {
@ -89,6 +89,7 @@ Exception :: Exception ( const char * file,
} }
init( file, line, str, code); init( file, line, str, code);
delete[] str;
} else { } else {
@ -105,7 +106,7 @@ Exception :: Exception ( const char * file,
const char * description1, const char * description1,
const char * description2, const char * description2,
const char * description3, const char * description3,
int code = 0 ) throw () int code ) throw ()
{ {
size_t len = 0; size_t len = 0;
@ -120,7 +121,7 @@ Exception :: Exception ( const char * file,
} }
if ( len ) { if ( len ) {
char str[len+1]; char * str = new char[len+1];
str[0] = '\0'; str[0] = '\0';
if ( description1 ) { if ( description1 ) {
@ -134,6 +135,7 @@ Exception :: Exception ( const char * file,
} }
init( file, line, str, code); init( file, line, str, code);
delete[] str;
} else { } else {
@ -203,6 +205,9 @@ Exception :: strip ( void ) throw ()
$Source$ $Source$
$Log$ $Log$
Revision 1.6 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.5 2001/08/30 17:25:56 darkeye Revision 1.5 2001/08/30 17:25:56 darkeye
renamed configure.h to config.h renamed configure.h to config.h

View File

@ -36,7 +36,7 @@
/* ============================================================ include files */ /* ============================================================ include files */
#include <iostream.h> #include <iostream>
/* ================================================================ constants */ /* ================================================================ constants */
@ -282,8 +282,8 @@ class Exception
* @param e the Exception to print. * @param e the Exception to print.
* @return a reference to the supplied output stream. * @return a reference to the supplied output stream.
*/ */
inline ostream & inline std::ostream &
operator<< ( ostream & os, operator<< ( std::ostream & os,
const Exception & e ) const Exception & e )
{ {
os << e.getFile() << ":" << e.getLine() << ": " os << e.getFile() << ":" << e.getLine() << ": "
@ -302,6 +302,9 @@ operator<< ( ostream & os,
$Source$ $Source$
$Log$ $Log$
Revision 1.6 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.5 2000/11/17 15:33:54 darkeye Revision 1.5 2000/11/17 15:33:54 darkeye
bug fix: ostream << operator overload didn't return the ostream bug fix: ostream << operator overload didn't return the ostream

View File

@ -45,6 +45,12 @@
#error need string.h #error need string.h
#endif #endif
#ifdef HAVE_MATH_H
#include <math.h>
#else
#error need math.h
#endif
#include "Exception.h" #include "Exception.h"
#include "Source.h" #include "Source.h"
@ -139,9 +145,11 @@ IceCast :: sendLogin ( void ) throw ( Exception )
/* send the x-audiocast headers */ /* send the x-audiocast headers */
str = "\nx-audiocast-bitrate: "; str = "\nx-audiocast-bitrate: ";
sink->write( str, strlen( str)); sink->write( str, strlen( str));
if ( snprintf( resp, STRBUF_SIZE, "%d", getBitRate()) == -1 ) { if ( log10(getBitRate()) >= (STRBUF_SIZE-2) ) {
throw Exception( __FILE__, __LINE__, "snprintf overflow"); throw Exception( __FILE__, __LINE__,
"bitrate does not fit string buffer", getBitRate());
} }
sprintf( resp, "%d", getBitRate());
sink->write( resp, strlen( resp)); sink->write( resp, strlen( resp));
str = "\nx-audiocast-public: "; str = "\nx-audiocast-public: ";
@ -211,6 +219,9 @@ IceCast :: sendLogin ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.10 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.9 2001/11/20 09:06:18 darkeye Revision 1.9 2001/11/20 09:06:18 darkeye
fixed public stream reporting fixed public stream reporting

View File

@ -45,6 +45,12 @@
#error need string.h #error need string.h
#endif #endif
#ifdef HAVE_MATH_H
#include <math.h>
#else
#error need math.h
#endif
#include "Exception.h" #include "Exception.h"
#include "Source.h" #include "Source.h"
@ -157,9 +163,11 @@ IceCast2 :: sendLogin ( void ) throw ( Exception )
str = "\nice-bitrate: "; str = "\nice-bitrate: ";
sink->write( str, strlen( str)); sink->write( str, strlen( str));
if ( snprintf( resp, STRBUF_SIZE, "%d", getBitRate()) == -1 ) { if ( log10(getBitRate()) >= (STRBUF_SIZE-2) ) {
throw Exception( __FILE__, __LINE__, "snprintf overflow"); throw Exception( __FILE__, __LINE__,
"bitrate does not fit string buffer", getBitRate());
} }
sprintf( resp, "%d", getBitRate());
sink->write( resp, strlen( resp)); sink->write( resp, strlen( resp));
str = "\nice-public: "; str = "\nice-public: ";
@ -209,6 +217,9 @@ IceCast2 :: sendLogin ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.5 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.4 2002/02/20 10:35:35 darkeye Revision 1.4 2002/02/20 10:35:35 darkeye
updated to work with Ogg Vorbis libs rc3 and current IceCast2 cvs updated to work with Ogg Vorbis libs rc3 and current IceCast2 cvs

View File

@ -280,8 +280,8 @@ LameLibEncoder :: write ( const void * buf,
unsigned char * b = (unsigned char*) buf; unsigned char * b = (unsigned char*) buf;
unsigned int processed = len - (len % sampleSize); unsigned int processed = len - (len % sampleSize);
unsigned int nSamples = processed / sampleSize; unsigned int nSamples = processed / sampleSize;
short int leftBuffer[nSamples]; short int * leftBuffer = new short int[nSamples];
short int rightBuffer[nSamples]; short int * rightBuffer = new short int[nSamples];
if ( bitsPerSample == 8 ) { if ( bitsPerSample == 8 ) {
Util::conv8( b, processed, leftBuffer, rightBuffer, channels); Util::conv8( b, processed, leftBuffer, rightBuffer, channels);
@ -293,6 +293,8 @@ LameLibEncoder :: write ( const void * buf,
channels, channels,
isInBigEndian()); isInBigEndian());
} else { } else {
delete[] leftBuffer;
delete[] rightBuffer;
throw Exception( __FILE__, __LINE__, throw Exception( __FILE__, __LINE__,
"unsupported number of bits per sample for the encoder", "unsupported number of bits per sample for the encoder",
bitsPerSample ); bitsPerSample );
@ -300,7 +302,7 @@ LameLibEncoder :: write ( const void * buf,
// data chunk size estimate according to lame documentation // data chunk size estimate according to lame documentation
unsigned int mp3Size = (unsigned int) (1.25 * nSamples + 7200); unsigned int mp3Size = (unsigned int) (1.25 * nSamples + 7200);
unsigned char mp3Buf[mp3Size]; unsigned char * mp3Buf = new unsigned char[mp3Size];
int ret; int ret;
ret = lame_encode_buffer( lameGlobalFlags, ret = lame_encode_buffer( lameGlobalFlags,
@ -310,6 +312,10 @@ LameLibEncoder :: write ( const void * buf,
mp3Buf, mp3Buf,
mp3Size ); mp3Size );
delete[] mp3Buf;
delete[] leftBuffer;
delete[] rightBuffer;
if ( ret < 0 ) { if ( ret < 0 ) {
reportEvent( 3, "lame encoding error", ret); reportEvent( 3, "lame encoding error", ret);
return 0; return 0;
@ -340,12 +346,14 @@ LameLibEncoder :: flush ( void )
// data chunk size estimate according to lame documentation // data chunk size estimate according to lame documentation
unsigned int mp3Size = 7200; unsigned int mp3Size = 7200;
unsigned char mp3Buf[mp3Size]; unsigned char * mp3Buf = new unsigned char[mp3Size];
int ret; int ret;
ret = lame_encode_flush( lameGlobalFlags, mp3Buf, mp3Size ); ret = lame_encode_flush( lameGlobalFlags, mp3Buf, mp3Size );
unsigned int written = sink->write( mp3Buf, ret); unsigned int written = sink->write( mp3Buf, ret);
delete[] mp3Buf;
// just let go data that could not be written // just let go data that could not be written
if ( written < (unsigned int) ret ) { if ( written < (unsigned int) ret ) {
reportEvent( 2, reportEvent( 2,
@ -379,6 +387,9 @@ LameLibEncoder :: close ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.12 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.11 2002/04/13 11:26:00 darkeye Revision 1.11 2002/04/13 11:26:00 darkeye
added cbr, abr and vbr setting feature with encoding quality added cbr, abr and vbr setting feature with encoding quality

View File

@ -1,5 +1,5 @@
bin_PROGRAMS = darkice bin_PROGRAMS = darkice
CXXFLAGS = -O2 -Wall CXXFLAGS = -O2 -pedantic -Wall
INCLUDES = @LAME_INCFLAGS@ @VORBIS_INCFLAGS@ INCLUDES = @LAME_INCFLAGS@ @VORBIS_INCFLAGS@
LDADD = @LAME_LDFLAGS@ @VORBIS_LDFLAGS@ LDADD = @LAME_LDFLAGS@ @VORBIS_LDFLAGS@

View File

@ -217,9 +217,10 @@ OssDspSource :: canRead ( unsigned int sec,
if ( !running ) { if ( !running ) {
/* ugly workaround to get the dsp into recording state */ /* ugly workaround to get the dsp into recording state */
unsigned char b[getChannel()*getBitsPerSample()/8]; unsigned char * b =
new unsigned char[getChannel()*getBitsPerSample()/8];
read( b, getChannel()*getBitsPerSample()/8); read( b, getChannel()*getBitsPerSample()/8);
delete[] b;
} }
FD_ZERO( &fdset); FD_ZERO( &fdset);
@ -284,6 +285,9 @@ OssDspSource :: close ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.11 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.10 2001/09/26 16:55:30 darkeye Revision 1.10 2001/09/26 16:55:30 darkeye
BSD port BSD port

View File

@ -29,7 +29,7 @@
/* ============================================================ include files */ /* ============================================================ include files */
#include <iostream.h> #include <iostream>
#include "Reporter.h" #include "Reporter.h"
@ -49,7 +49,7 @@ static const char fileid[] = "$Id$";
* Initial values for static members of the class * Initial values for static members of the class
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
unsigned int Reporter::verbosity = 1; unsigned int Reporter::verbosity = 1;
ostream * Reporter::os = &cout; std::ostream * Reporter::os = &std::cout;
/* =============================================== local function prototypes */ /* =============================================== local function prototypes */
@ -64,6 +64,9 @@ ostream * Reporter::os = &cout;
$Source$ $Source$
$Log$ $Log$
Revision 1.2 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.1 2000/11/16 08:48:43 darkeye Revision 1.1 2000/11/16 08:48:43 darkeye
added multiple verbosity-level event reporting and verbosity command added multiple verbosity-level event reporting and verbosity command
line option line option

View File

@ -53,7 +53,7 @@
#endif #endif
#include <iostream.h> #include <iostream>
#include "Exception.h" #include "Exception.h"
@ -93,7 +93,7 @@ class Reporter
/** /**
* The output stream to report to. * The output stream to report to.
*/ */
static ostream * os; static std::ostream * os;
/** /**
* Print timestamp for every report only if verbosity level * Print timestamp for every report only if verbosity level
@ -164,7 +164,7 @@ class Reporter
* @param os the output stream * @param os the output stream
*/ */
inline void inline void
setReportOutputStream ( ostream & os ) throw () setReportOutputStream ( std::ostream & os ) throw ()
{ {
Reporter::os = &os; Reporter::os = &os;
} }
@ -174,7 +174,7 @@ class Reporter
* *
* @return the output stream * @return the output stream
*/ */
inline ostream & inline std::ostream &
getReportOutputStream ( void ) throw () getReportOutputStream ( void ) throw ()
{ {
return *(Reporter::os); return *(Reporter::os);
@ -196,7 +196,7 @@ class Reporter
{ {
if ( Reporter::verbosity >= verbosity ) { if ( Reporter::verbosity >= verbosity ) {
printPrefix(); printPrefix();
(*(Reporter::os)) << t << endl; (*(Reporter::os)) << t << std::endl;
} }
} }
@ -221,7 +221,7 @@ class Reporter
if ( Reporter::verbosity >= verbosity ) { if ( Reporter::verbosity >= verbosity ) {
printPrefix(); printPrefix();
(*(Reporter::os)) << t << " " (*(Reporter::os)) << t << " "
<< u << endl; << u << std::endl;
} }
} }
@ -251,7 +251,7 @@ class Reporter
printPrefix(); printPrefix();
(*(Reporter::os)) << t << " " (*(Reporter::os)) << t << " "
<< u << " " << u << " "
<< v << endl; << v << std::endl;
} }
} }
@ -286,7 +286,7 @@ class Reporter
(*(Reporter::os)) << t << " " (*(Reporter::os)) << t << " "
<< u << " " << u << " "
<< v << " " << v << " "
<< w << endl; << w << std::endl;
} }
} }
}; };
@ -309,6 +309,9 @@ class Reporter
$Source$ $Source$
$Log$ $Log$
Revision 1.6 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.5 2001/09/05 20:11:15 darkeye Revision 1.5 2001/09/05 20:11:15 darkeye
removed dependency on locally stored SGI STL header files removed dependency on locally stored SGI STL header files
now compiler-supplied C++ library STL header files are used now compiler-supplied C++ library STL header files are used

View File

@ -45,6 +45,12 @@
#error need string.h #error need string.h
#endif #endif
#ifdef HAVE_MATH_H
#include <math.h>
#else
#error need math.h
#endif
#include "Exception.h" #include "Exception.h"
#include "Source.h" #include "Source.h"
@ -179,9 +185,11 @@ ShoutCast :: sendLogin ( void ) throw ( Exception )
str = "\nicy-br:"; str = "\nicy-br:";
sink->write( str, strlen( str)); sink->write( str, strlen( str));
if ( snprintf( resp, STRBUF_SIZE, "%d", getBitRate()) == -1 ) { if ( log10(getBitRate()) >= (STRBUF_SIZE-2) ) {
throw Exception( __FILE__, __LINE__, "snprintf overflow"); throw Exception( __FILE__, __LINE__,
"bitrate does not fit string buffer", getBitRate());
} }
sprintf( resp, "%d", getBitRate());
sink->write( resp, strlen( resp)); sink->write( resp, strlen( resp));
str = "\nicy-pub:"; str = "\nicy-pub:";
@ -215,6 +223,9 @@ ShoutCast :: sendLogin ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.3 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.2 2001/11/20 09:06:18 darkeye Revision 1.2 2001/11/20 09:06:18 darkeye
fixed public stream reporting fixed public stream reporting

View File

@ -199,14 +199,14 @@ VorbisLibEncoder :: write ( const void * buf,
// convert the byte-based raw input into a short buffer // convert the byte-based raw input into a short buffer
// with channels still interleaved // with channels still interleaved
unsigned int totalSamples = nSamples * channels; unsigned int totalSamples = nSamples * channels;
short int shortBuffer[totalSamples]; short int * shortBuffer = new short int[totalSamples];
Util::conv( bitsPerSample, b, processed, shortBuffer, isInBigEndian()); Util::conv( bitsPerSample, b, processed, shortBuffer, isInBigEndian());
if ( converter ) { if ( converter ) {
// resample if needed // resample if needed
int inCount = totalSamples; int inCount = totalSamples;
int outCount = (int) (inCount * resampleRatio); int outCount = (int) (inCount * resampleRatio);
short int resampledBuffer[outCount * channels]; short int * resampledBuffer = new short int[outCount * channels];
int converted; int converted;
converted = converter->resample( inCount, converted = converter->resample( inCount,
@ -217,6 +217,8 @@ VorbisLibEncoder :: write ( const void * buf,
vorbisBuffer = vorbis_analysis_buffer( &vorbisDspState, vorbisBuffer = vorbis_analysis_buffer( &vorbisDspState,
converted / channels); converted / channels);
Util::conv( resampledBuffer, converted, vorbisBuffer, channels); Util::conv( resampledBuffer, converted, vorbisBuffer, channels);
delete[] resampledBuffer;
vorbis_analysis_wrote( &vorbisDspState, converted / channels); vorbis_analysis_wrote( &vorbisDspState, converted / channels);
} else { } else {
@ -226,6 +228,7 @@ VorbisLibEncoder :: write ( const void * buf,
vorbis_analysis_wrote( &vorbisDspState, nSamples); vorbis_analysis_wrote( &vorbisDspState, nSamples);
} }
delete[] shortBuffer;
vorbisBlocksOut(); vorbisBlocksOut();
return processed; return processed;
@ -316,6 +319,9 @@ VorbisLibEncoder :: close ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.9 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.8 2002/04/13 11:26:00 darkeye Revision 1.8 2002/04/13 11:26:00 darkeye
added cbr, abr and vbr setting feature with encoding quality added cbr, abr and vbr setting feature with encoding quality

View File

@ -43,8 +43,8 @@
#error needs stdlib.h #error needs stdlib.h
#endif #endif
#include <iostream.h> #include <iostream>
#include <fstream.h> #include <fstream>
#include "Ref.h" #include "Ref.h"
#include "Exception.h" #include "Exception.h"
@ -69,7 +69,7 @@ static const char fileid[] = "$Id$";
* Show program usage * Show program usage
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
static void static void
showUsage ( ostream & os ); showUsage ( std::ostream & os );
/* ============================================================= module code */ /* ============================================================= module code */
@ -84,10 +84,11 @@ main (
{ {
int res = -1; int res = -1;
cout << "DarkIce " << VERSION std::cout << "DarkIce " << VERSION
<< " live audio streamer, http://darkice.sourceforge.net" << endl; << " live audio streamer, http://darkice.sourceforge.net"
cout << "Copyright (c) 2000-2002, Tyrell Hungary, http://tyrell.hu" << endl; << std::endl
cout << endl; << "Copyright (c) 2000-2002, Tyrell Hungary, http://tyrell.hu"
<< std::endl << std::endl;
try { try {
const char * configFileName = 0; const char * configFileName = 0;
@ -109,29 +110,29 @@ main (
case ':': case ':':
case '?': case '?':
case 'h': case 'h':
showUsage( cout); showUsage( std::cout);
return 1; return 1;
} }
} }
if ( !configFileName ) { if ( !configFileName ) {
showUsage( cout); showUsage( std::cout);
throw Exception( __FILE__, __LINE__, throw Exception( __FILE__, __LINE__,
"no configuration file specified"); "no configuration file specified");
} }
cout << "Using config file: " << configFileName << endl; std::cout << "Using config file: " << configFileName << std::endl;
ifstream configFile( configFileName); std::ifstream configFile( configFileName);
Config config( configFile); Config config( configFile);
Ref<DarkIce> di = new DarkIce( config); Ref<DarkIce> di = new DarkIce( config);
di->setReportVerbosity( verbosity ); di->setReportVerbosity( verbosity );
di->setReportOutputStream( cout ); di->setReportOutputStream( std::cout );
res = di->run(); res = di->run();
} catch ( Exception & e ) { } catch ( Exception & e ) {
cout << "DarkIce: " << e << endl << flush; std::cout << "DarkIce: " << e << std::endl << std::flush;
} }
return res; return res;
@ -142,21 +143,21 @@ main (
* Show program usage * Show program usage
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
static void static void
showUsage ( ostream & os ) showUsage ( std::ostream & os )
{ {
os os
<< "usage: darkice [-v n] -c config.file" << "usage: darkice [-v n] -c config.file"
<< endl << std::endl
<< endl << std::endl
<< "options:" << "options:"
<< endl << std::endl
<< " -c config.file use configuration file config.file" << " -c config.file use configuration file config.file"
<< endl << std::endl
<< " -v n verbosity level (0 = silent, 10 = loud)" << " -v n verbosity level (0 = silent, 10 = loud)"
<< endl << std::endl
<< " -h print this message and exit" << " -h print this message and exit"
<< endl << std::endl
<< endl; << std::endl;
} }
@ -165,6 +166,9 @@ showUsage ( ostream & os )
$Source$ $Source$
$Log$ $Log$
Revision 1.11 2002/05/28 12:35:41 darkeye
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
Revision 1.10 2002/02/20 15:08:52 darkeye Revision 1.10 2002/02/20 15:08:52 darkeye
minor changes minor changes