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( rt, sched_getscheduler)
SYSTEM_INCLUDE=/usr/include
dnl-----------------------------------------------------------------------------
dnl link the lame library if requested
@ -44,7 +46,9 @@ if test "x${USE_LAME}" = "xyes" ; then
${CONFIG_LAME_PREFIX})
if test "x${LAME_LIB_LOC}" != "x" ; then
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"
AC_MSG_RESULT( [found at ${CONFIG_LAME_PREFIX}] )
else
@ -85,7 +89,9 @@ if test "x${USE_VORBIS}" = "xyes" ; then
"x${VORBISENC_LIB_LOC}" != "x" ; then
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"
AC_MSG_RESULT( [found at ${CONFIG_VORBIS_PREFIX}] )
else
@ -114,7 +120,7 @@ if test "x${USE_VORBIS_LIB}" = "xrc3" ; then
fi
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])
fi

View File

@ -361,7 +361,7 @@ class BufferedSink : public Sink, public virtual Reporter
inline virtual void
flush ( void ) throw ( Exception )
{
unsigned char b[0];
unsigned char b[1];
write( b, 0);
}
@ -391,6 +391,9 @@ class BufferedSink : public Sink, public virtual Reporter
$Source$
$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
added multiple verbosity-level event reporting and verbosity command
line option

View File

@ -35,7 +35,7 @@
#include <iterator>
#include <iostream.h>
#include <iostream>
#include "Config.h"
@ -146,7 +146,7 @@ Config :: addLine ( const char * line ) throw ( Exception )
* Add a configuration line
*----------------------------------------------------------------------------*/
void
Config :: read ( istream & is ) throw ( Exception )
Config :: read ( std::istream & is ) throw ( Exception )
{
char line[LINE_SIZE];
unsigned int num;
@ -170,6 +170,9 @@ Config :: read ( istream & is ) throw ( Exception )
$Source$
$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
config file now may contain tabs also as white space

View File

@ -39,7 +39,7 @@
#include <map>
#include <string>
#include <iostream.h>
#include <iostream>
#include "Referable.h"
#include "ConfigSection.h"
@ -123,7 +123,7 @@ class Config : public virtual Referable
* @exception Exception
*/
inline
Config ( istream & is ) throw ( Exception )
Config ( std::istream & is ) throw ( Exception )
{
read( is );
}
@ -184,7 +184,7 @@ class Config : public virtual Referable
* @exception Exception
*/
virtual void
read ( istream & is ) throw ( Exception );
read ( std::istream & is ) throw ( Exception );
/**
* Get a ConfigSection by name.
@ -213,6 +213,9 @@ class Config : public virtual Referable
$Source$
$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
removed dependency on locally stored SGI STL header files
now compiler-supplied C++ library STL header files are used

View File

@ -35,7 +35,7 @@
#include <iterator>
#include <iostream.h>
#include <iostream>
#include "ConfigSection.h"
@ -106,9 +106,9 @@ ConfigSection :: get ( const char * key ) const throw ( Exception )
*----------------------------------------------------------------------------*/
const char *
ConfigSection :: getForSure ( const char * key,
const char * message1 = 0,
const char * message2 = 0,
int code = 0 ) const
const char * message1,
const char * message2,
int code ) const
throw ( Exception )
{
const char * value;
@ -177,6 +177,9 @@ ConfigSection :: addLine ( const char * line ) throw ( Exception )
$Source$
$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
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 long b;
unsigned char buf[bufSize];
unsigned char * buf = new unsigned char[bufSize];
if ( numSinks == 0 ) {
return 0;
@ -308,6 +308,7 @@ Connector :: transfer ( unsigned long bytes,
}
}
delete[] buf;
return b;
}
@ -333,6 +334,9 @@ Connector :: close ( void ) throw ( Exception )
$Source$
$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
removed external command-line encoder support
replaced it with a shared-object support for lame with the possibility

View File

@ -46,7 +46,7 @@
#error need unistd.h
#endif
#include <iostream.h>
#include <iostream>
#include "Referable.h"
#include "Reporter.h"
@ -309,6 +309,9 @@ class DarkIce : public virtual Referable, public virtual Reporter
$Source$
$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
added possibility to save the encoded stream to a local file only
(no streaming server needed)

View File

@ -66,7 +66,7 @@ Exception :: Exception ( const char * file,
unsigned int line,
const char * description1,
const char * description2,
int code = 0 ) throw ()
int code ) throw ()
{
size_t len = 0;
@ -78,7 +78,7 @@ Exception :: Exception ( const char * file,
}
if ( len ) {
char str[len+1];
char * str = new char[len+1];
str[0] = '\0';
if ( description1 ) {
@ -89,6 +89,7 @@ Exception :: Exception ( const char * file,
}
init( file, line, str, code);
delete[] str;
} else {
@ -105,7 +106,7 @@ Exception :: Exception ( const char * file,
const char * description1,
const char * description2,
const char * description3,
int code = 0 ) throw ()
int code ) throw ()
{
size_t len = 0;
@ -120,7 +121,7 @@ Exception :: Exception ( const char * file,
}
if ( len ) {
char str[len+1];
char * str = new char[len+1];
str[0] = '\0';
if ( description1 ) {
@ -134,6 +135,7 @@ Exception :: Exception ( const char * file,
}
init( file, line, str, code);
delete[] str;
} else {
@ -203,6 +205,9 @@ Exception :: strip ( void ) throw ()
$Source$
$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
renamed configure.h to config.h

View File

@ -36,7 +36,7 @@
/* ============================================================ include files */
#include <iostream.h>
#include <iostream>
/* ================================================================ constants */
@ -282,8 +282,8 @@ class Exception
* @param e the Exception to print.
* @return a reference to the supplied output stream.
*/
inline ostream &
operator<< ( ostream & os,
inline std::ostream &
operator<< ( std::ostream & os,
const Exception & e )
{
os << e.getFile() << ":" << e.getLine() << ": "
@ -302,6 +302,9 @@ operator<< ( ostream & os,
$Source$
$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
bug fix: ostream << operator overload didn't return the ostream

View File

@ -45,6 +45,12 @@
#error need string.h
#endif
#ifdef HAVE_MATH_H
#include <math.h>
#else
#error need math.h
#endif
#include "Exception.h"
#include "Source.h"
@ -139,9 +145,11 @@ IceCast :: sendLogin ( void ) throw ( Exception )
/* send the x-audiocast headers */
str = "\nx-audiocast-bitrate: ";
sink->write( str, strlen( str));
if ( snprintf( resp, STRBUF_SIZE, "%d", getBitRate()) == -1 ) {
throw Exception( __FILE__, __LINE__, "snprintf overflow");
if ( log10(getBitRate()) >= (STRBUF_SIZE-2) ) {
throw Exception( __FILE__, __LINE__,
"bitrate does not fit string buffer", getBitRate());
}
sprintf( resp, "%d", getBitRate());
sink->write( resp, strlen( resp));
str = "\nx-audiocast-public: ";
@ -211,6 +219,9 @@ IceCast :: sendLogin ( void ) throw ( Exception )
$Source$
$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
fixed public stream reporting

View File

@ -45,6 +45,12 @@
#error need string.h
#endif
#ifdef HAVE_MATH_H
#include <math.h>
#else
#error need math.h
#endif
#include "Exception.h"
#include "Source.h"
@ -157,9 +163,11 @@ IceCast2 :: sendLogin ( void ) throw ( Exception )
str = "\nice-bitrate: ";
sink->write( str, strlen( str));
if ( snprintf( resp, STRBUF_SIZE, "%d", getBitRate()) == -1 ) {
throw Exception( __FILE__, __LINE__, "snprintf overflow");
if ( log10(getBitRate()) >= (STRBUF_SIZE-2) ) {
throw Exception( __FILE__, __LINE__,
"bitrate does not fit string buffer", getBitRate());
}
sprintf( resp, "%d", getBitRate());
sink->write( resp, strlen( resp));
str = "\nice-public: ";
@ -209,6 +217,9 @@ IceCast2 :: sendLogin ( void ) throw ( Exception )
$Source$
$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
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 int processed = len - (len % sampleSize);
unsigned int nSamples = processed / sampleSize;
short int leftBuffer[nSamples];
short int rightBuffer[nSamples];
short int * leftBuffer = new short int[nSamples];
short int * rightBuffer = new short int[nSamples];
if ( bitsPerSample == 8 ) {
Util::conv8( b, processed, leftBuffer, rightBuffer, channels);
@ -293,6 +293,8 @@ LameLibEncoder :: write ( const void * buf,
channels,
isInBigEndian());
} else {
delete[] leftBuffer;
delete[] rightBuffer;
throw Exception( __FILE__, __LINE__,
"unsupported number of bits per sample for the encoder",
bitsPerSample );
@ -300,7 +302,7 @@ LameLibEncoder :: write ( const void * buf,
// data chunk size estimate according to lame documentation
unsigned int mp3Size = (unsigned int) (1.25 * nSamples + 7200);
unsigned char mp3Buf[mp3Size];
unsigned char * mp3Buf = new unsigned char[mp3Size];
int ret;
ret = lame_encode_buffer( lameGlobalFlags,
@ -309,7 +311,11 @@ LameLibEncoder :: write ( const void * buf,
nSamples,
mp3Buf,
mp3Size );
delete[] mp3Buf;
delete[] leftBuffer;
delete[] rightBuffer;
if ( ret < 0 ) {
reportEvent( 3, "lame encoding error", ret);
return 0;
@ -340,12 +346,14 @@ LameLibEncoder :: flush ( void )
// data chunk size estimate according to lame documentation
unsigned int mp3Size = 7200;
unsigned char mp3Buf[mp3Size];
unsigned char * mp3Buf = new unsigned char[mp3Size];
int ret;
ret = lame_encode_flush( lameGlobalFlags, mp3Buf, mp3Size );
unsigned int written = sink->write( mp3Buf, ret);
delete[] mp3Buf;
// just let go data that could not be written
if ( written < (unsigned int) ret ) {
reportEvent( 2,
@ -379,6 +387,9 @@ LameLibEncoder :: close ( void ) throw ( Exception )
$Source$
$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
added cbr, abr and vbr setting feature with encoding quality

View File

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

View File

@ -217,9 +217,10 @@ OssDspSource :: canRead ( unsigned int sec,
if ( !running ) {
/* 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);
delete[] b;
}
FD_ZERO( &fdset);
@ -284,6 +285,9 @@ OssDspSource :: close ( void ) throw ( Exception )
$Source$
$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
BSD port

View File

@ -29,7 +29,7 @@
/* ============================================================ include files */
#include <iostream.h>
#include <iostream>
#include "Reporter.h"
@ -49,7 +49,7 @@ static const char fileid[] = "$Id$";
* Initial values for static members of the class
*----------------------------------------------------------------------------*/
unsigned int Reporter::verbosity = 1;
ostream * Reporter::os = &cout;
std::ostream * Reporter::os = &std::cout;
/* =============================================== local function prototypes */
@ -64,6 +64,9 @@ ostream * Reporter::os = &cout;
$Source$
$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
added multiple verbosity-level event reporting and verbosity command
line option

View File

@ -53,7 +53,7 @@
#endif
#include <iostream.h>
#include <iostream>
#include "Exception.h"
@ -93,7 +93,7 @@ class Reporter
/**
* The output stream to report to.
*/
static ostream * os;
static std::ostream * os;
/**
* Print timestamp for every report only if verbosity level
@ -164,7 +164,7 @@ class Reporter
* @param os the output stream
*/
inline void
setReportOutputStream ( ostream & os ) throw ()
setReportOutputStream ( std::ostream & os ) throw ()
{
Reporter::os = &os;
}
@ -174,7 +174,7 @@ class Reporter
*
* @return the output stream
*/
inline ostream &
inline std::ostream &
getReportOutputStream ( void ) throw ()
{
return *(Reporter::os);
@ -196,7 +196,7 @@ class Reporter
{
if ( Reporter::verbosity >= verbosity ) {
printPrefix();
(*(Reporter::os)) << t << endl;
(*(Reporter::os)) << t << std::endl;
}
}
@ -221,7 +221,7 @@ class Reporter
if ( Reporter::verbosity >= verbosity ) {
printPrefix();
(*(Reporter::os)) << t << " "
<< u << endl;
<< u << std::endl;
}
}
@ -251,7 +251,7 @@ class Reporter
printPrefix();
(*(Reporter::os)) << t << " "
<< u << " "
<< v << endl;
<< v << std::endl;
}
}
@ -286,7 +286,7 @@ class Reporter
(*(Reporter::os)) << t << " "
<< u << " "
<< v << " "
<< w << endl;
<< w << std::endl;
}
}
};
@ -309,6 +309,9 @@ class Reporter
$Source$
$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
removed dependency on locally stored SGI STL header files
now compiler-supplied C++ library STL header files are used

View File

@ -45,6 +45,12 @@
#error need string.h
#endif
#ifdef HAVE_MATH_H
#include <math.h>
#else
#error need math.h
#endif
#include "Exception.h"
#include "Source.h"
@ -179,9 +185,11 @@ ShoutCast :: sendLogin ( void ) throw ( Exception )
str = "\nicy-br:";
sink->write( str, strlen( str));
if ( snprintf( resp, STRBUF_SIZE, "%d", getBitRate()) == -1 ) {
throw Exception( __FILE__, __LINE__, "snprintf overflow");
if ( log10(getBitRate()) >= (STRBUF_SIZE-2) ) {
throw Exception( __FILE__, __LINE__,
"bitrate does not fit string buffer", getBitRate());
}
sprintf( resp, "%d", getBitRate());
sink->write( resp, strlen( resp));
str = "\nicy-pub:";
@ -215,6 +223,9 @@ ShoutCast :: sendLogin ( void ) throw ( Exception )
$Source$
$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
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
// with channels still interleaved
unsigned int totalSamples = nSamples * channels;
short int shortBuffer[totalSamples];
short int * shortBuffer = new short int[totalSamples];
Util::conv( bitsPerSample, b, processed, shortBuffer, isInBigEndian());
if ( converter ) {
// resample if needed
int inCount = totalSamples;
int outCount = (int) (inCount * resampleRatio);
short int resampledBuffer[outCount * channels];
short int * resampledBuffer = new short int[outCount * channels];
int converted;
converted = converter->resample( inCount,
@ -217,6 +217,8 @@ VorbisLibEncoder :: write ( const void * buf,
vorbisBuffer = vorbis_analysis_buffer( &vorbisDspState,
converted / channels);
Util::conv( resampledBuffer, converted, vorbisBuffer, channels);
delete[] resampledBuffer;
vorbis_analysis_wrote( &vorbisDspState, converted / channels);
} else {
@ -226,6 +228,7 @@ VorbisLibEncoder :: write ( const void * buf,
vorbis_analysis_wrote( &vorbisDspState, nSamples);
}
delete[] shortBuffer;
vorbisBlocksOut();
return processed;
@ -316,6 +319,9 @@ VorbisLibEncoder :: close ( void ) throw ( Exception )
$Source$
$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
added cbr, abr and vbr setting feature with encoding quality

View File

@ -43,8 +43,8 @@
#error needs stdlib.h
#endif
#include <iostream.h>
#include <fstream.h>
#include <iostream>
#include <fstream>
#include "Ref.h"
#include "Exception.h"
@ -69,7 +69,7 @@ static const char fileid[] = "$Id$";
* Show program usage
*----------------------------------------------------------------------------*/
static void
showUsage ( ostream & os );
showUsage ( std::ostream & os );
/* ============================================================= module code */
@ -84,10 +84,11 @@ main (
{
int res = -1;
cout << "DarkIce " << VERSION
<< " live audio streamer, http://darkice.sourceforge.net" << endl;
cout << "Copyright (c) 2000-2002, Tyrell Hungary, http://tyrell.hu" << endl;
cout << endl;
std::cout << "DarkIce " << VERSION
<< " live audio streamer, http://darkice.sourceforge.net"
<< std::endl
<< "Copyright (c) 2000-2002, Tyrell Hungary, http://tyrell.hu"
<< std::endl << std::endl;
try {
const char * configFileName = 0;
@ -109,29 +110,29 @@ main (
case ':':
case '?':
case 'h':
showUsage( cout);
showUsage( std::cout);
return 1;
}
}
if ( !configFileName ) {
showUsage( cout);
showUsage( std::cout);
throw Exception( __FILE__, __LINE__,
"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);
Ref<DarkIce> di = new DarkIce( config);
di->setReportVerbosity( verbosity );
di->setReportOutputStream( cout );
di->setReportOutputStream( std::cout );
res = di->run();
} catch ( Exception & e ) {
cout << "DarkIce: " << e << endl << flush;
std::cout << "DarkIce: " << e << std::endl << std::flush;
}
return res;
@ -142,21 +143,21 @@ main (
* Show program usage
*----------------------------------------------------------------------------*/
static void
showUsage ( ostream & os )
showUsage ( std::ostream & os )
{
os
<< "usage: darkice [-v n] -c config.file"
<< endl
<< endl
<< std::endl
<< std::endl
<< "options:"
<< endl
<< std::endl
<< " -c config.file use configuration file config.file"
<< endl
<< std::endl
<< " -v n verbosity level (0 = silent, 10 = loud)"
<< endl
<< std::endl
<< " -h print this message and exit"
<< endl
<< endl;
<< std::endl
<< std::endl;
}
@ -165,6 +166,9 @@ showUsage ( ostream & os )
$Source$
$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
minor changes