From 11f054eeca43822471c5f2c0cbafc514435ffefb Mon Sep 17 00:00:00 2001 From: darkeye Date: Wed, 15 Nov 2000 18:08:43 +0000 Subject: [PATCH] added multiple verbosity-level event reporting and verbosity command line option --- darkice/trunk/src/BufferedSink.h | 9 ++++++++- darkice/trunk/src/Connector.cpp | 15 ++++++++++++--- darkice/trunk/src/Connector.h | 7 ++++++- darkice/trunk/src/DarkIce.cpp | 31 +++++++++++++++++++------------ darkice/trunk/src/DarkIce.h | 7 ++++++- darkice/trunk/src/Makefile.am | 2 ++ darkice/trunk/src/main.cpp | 22 +++++++++++++++++++--- 7 files changed, 72 insertions(+), 21 deletions(-) diff --git a/darkice/trunk/src/BufferedSink.h b/darkice/trunk/src/BufferedSink.h index e4f1bd2..7dc33b7 100644 --- a/darkice/trunk/src/BufferedSink.h +++ b/darkice/trunk/src/BufferedSink.h @@ -37,6 +37,7 @@ /* ============================================================ include files */ #include "Ref.h" +#include "Reporter.h" #include "Sink.h" @@ -57,7 +58,7 @@ * @author $Author$ * @version $Revision$ */ -class BufferedSink : public Sink +class BufferedSink : public Sink, public virtual Reporter { private: @@ -163,6 +164,8 @@ class BufferedSink : public Sink u = outp <= inp ? inp - outp : (bufferEnd - outp) + (inp - buffer); if ( peak < u ) { + reportEvent( 4, "BufferedSink, new peak:", peak); + reportEvent( 4, "BufferedSink, remaining:", bufferSize - peak); peak = u; } } @@ -388,6 +391,10 @@ class BufferedSink : public Sink $Source$ $Log$ + Revision 1.5 2000/11/15 18:08:42 darkeye + added multiple verbosity-level event reporting and verbosity command + line option + Revision 1.4 2000/11/11 12:33:13 darkeye added kdoc-style documentation diff --git a/darkice/trunk/src/Connector.cpp b/darkice/trunk/src/Connector.cpp index 4391a8b..51573e6 100644 --- a/darkice/trunk/src/Connector.cpp +++ b/darkice/trunk/src/Connector.cpp @@ -265,6 +265,8 @@ Connector :: transfer ( unsigned int bytes, return 0; } + reportEvent( 6, "Connector :: tranfer, bytes", bytes); + for ( b = 0; b < bytes; ) { unsigned int d = 0; unsigned int e = 0; @@ -274,7 +276,7 @@ Connector :: transfer ( unsigned int bytes, /* check for EOF */ if ( d == 0 ) { -cout << "Connector :: transfer, EOF" << endl; + reportEvent( 3, "Connector :: transfer, EOF"); break; } @@ -289,8 +291,11 @@ cout << "Connector :: transfer, EOF" << endl; * and the next sink comes to sinks[u] */ --u; + reportEvent( 5, + "Connector :: transfer, sink removed, remaining", u); + if ( numSinks == 0 ) { -cout << "Connector :: transfer, no more sinks" << endl; + reportEvent( 4, "Connector :: transfer, no more sinks"); break; } } @@ -298,7 +303,7 @@ cout << "Connector :: transfer, no more sinks" << endl; b += d; } else { -cout << "Connector :: transfer, can't read" << endl; + reportEvent( 3, "Connector :: transfer, can't read"); break; } } @@ -328,6 +333,10 @@ Connector :: close ( void ) throw ( Exception ) $Source$ $Log$ + Revision 1.3 2000/11/15 18:08:43 darkeye + added multiple verbosity-level event reporting and verbosity command + line option + Revision 1.2 2000/11/13 18:46:50 darkeye added kdoc-style documentation comments diff --git a/darkice/trunk/src/Connector.h b/darkice/trunk/src/Connector.h index cfc310b..2bbf284 100644 --- a/darkice/trunk/src/Connector.h +++ b/darkice/trunk/src/Connector.h @@ -38,6 +38,7 @@ #include "Referable.h" #include "Ref.h" +#include "Reporter.h" #include "Source.h" #include "Sink.h" @@ -56,7 +57,7 @@ * @author $Author$ * @version $Revision$ */ -class Connector : public virtual Referable +class Connector : public virtual Referable, public virtual Reporter { private: @@ -257,6 +258,10 @@ class Connector : public virtual Referable $Source$ $Log$ + Revision 1.3 2000/11/15 18:08:43 darkeye + added multiple verbosity-level event reporting and verbosity command + line option + Revision 1.2 2000/11/13 18:46:50 darkeye added kdoc-style documentation comments diff --git a/darkice/trunk/src/DarkIce.cpp b/darkice/trunk/src/DarkIce.cpp index 3928af1..76d82b7 100644 --- a/darkice/trunk/src/DarkIce.cpp +++ b/darkice/trunk/src/DarkIce.cpp @@ -225,9 +225,13 @@ DarkIce :: init ( const Config & config ) throw ( Exception ) } // encoder related stuff + unsigned int bs = bufferSecs * + (bitsPerSample / 8) * channel * sampleRate; outputs[i].encIn = new BufferedSink( outputs[i].encInPipe.get(), - bufferSecs * (bitsPerSample / 8) * channel * sampleRate, + bs, (bitsPerSample / 8) * channel ); + reportEvent( 6, "using buffer size", bs); + encConnector->attach( outputs[i].encIn.get()); outputs[i].encoder = new LameEncoder( encoder, outputs[i].encInPipe->getFileName(), @@ -268,6 +272,7 @@ DarkIce :: encode ( void ) throw ( Exception ) { unsigned int len; int i; + unsigned int bytes; for ( i = 0; i < noOutputs; ++i ) { outputs[i].encoder->start(); @@ -279,10 +284,12 @@ DarkIce :: encode ( void ) throw ( Exception ) throw Exception( __FILE__, __LINE__, "can't open connector"); } - len = encConnector->transfer( dsp->getSampleRate() * - (dsp->getBitsPerSample() / 8) * - dsp->getChannel() * - duration, + bytes = dsp->getSampleRate() * + (dsp->getBitsPerSample() / 8) * + dsp->getChannel() * + duration; + + len = encConnector->transfer( bytes, 4096, 1, 0 ); @@ -306,6 +313,7 @@ bool DarkIce :: shout ( unsigned int ix ) throw ( Exception ) { unsigned int len; + unsigned int bytes; if ( ix >= noOutputs ) { return false; @@ -315,13 +323,8 @@ DarkIce :: shout ( unsigned int ix ) throw ( Exception ) throw Exception( __FILE__, __LINE__, "can't open connector"); } - len = outputs[ix].shoutConnector->transfer ( - outputs[ix].encoder->getOutBitrate() - * (1024 / 8) - * duration, - 4096, - 10, - 0 ); + bytes = outputs[ix].encoder->getOutBitrate() * (1024 / 8) * duration; + len = outputs[ix].shoutConnector->transfer ( bytes, 4096, 10, 0 ); cout << len << " bytes transfered" << endl; @@ -384,6 +387,10 @@ DarkIce :: run ( void ) throw ( Exception ) $Source$ $Log$ + Revision 1.8 2000/11/15 18:08:43 darkeye + added multiple verbosity-level event reporting and verbosity command + line option + Revision 1.7 2000/11/13 19:38:55 darkeye moved command line parameter parsing from DarkIce.cpp to main.cpp diff --git a/darkice/trunk/src/DarkIce.h b/darkice/trunk/src/DarkIce.h index f54d9b0..15ebe29 100644 --- a/darkice/trunk/src/DarkIce.h +++ b/darkice/trunk/src/DarkIce.h @@ -49,6 +49,7 @@ #include #include "Referable.h" +#include "Reporter.h" #include "Exception.h" #include "Ref.h" #include "OssDspSource.h" @@ -76,7 +77,7 @@ * @author $Author$ * @version $Revision$ */ -class DarkIce : public virtual Referable +class DarkIce : public virtual Referable, public virtual Reporter { private: @@ -235,6 +236,10 @@ class DarkIce : public virtual Referable $Source$ $Log$ + Revision 1.6 2000/11/15 18:08:43 darkeye + added multiple verbosity-level event reporting and verbosity command + line option + Revision 1.5 2000/11/13 19:38:55 darkeye moved command line parameter parsing from DarkIce.cpp to main.cpp diff --git a/darkice/trunk/src/Makefile.am b/darkice/trunk/src/Makefile.am index 75d9b13..4da0f45 100644 --- a/darkice/trunk/src/Makefile.am +++ b/darkice/trunk/src/Makefile.am @@ -42,5 +42,7 @@ darkice_SOURCES = AudioEncoder.h\ ConfigSection.cpp\ Config.h\ Config.cpp\ + Reporter.h\ + Reporter.cpp\ main.cpp diff --git a/darkice/trunk/src/main.cpp b/darkice/trunk/src/main.cpp index 4a603e6..3dfe279 100644 --- a/darkice/trunk/src/main.cpp +++ b/darkice/trunk/src/main.cpp @@ -48,6 +48,7 @@ #include "Ref.h" #include "Exception.h" +#include "Util.h" #include "DarkIce.h" @@ -90,20 +91,27 @@ main ( try { const char * configFileName = 0; + unsigned int verbosity = 1; int i; + const char opts[] = "hc:v:"; static struct option long_options[] = { { "config", 1, 0, 'c'}, { "help", 0, 0, 'h'}, + { "verbosity", 1, 0, 'v'}, { 0, 0, 0, 0} }; - while ( (i = getopt_long( argc, argv, "hc:", long_options, 0)) != -1 ) { + while ( (i = getopt_long( argc, argv, opts, long_options, 0)) != -1 ) { switch ( i ) { case 'c': configFileName = optarg; break; + case 'v': + verbosity = Util::strToL( optarg); + break; + default: case ':': case '?': @@ -120,9 +128,11 @@ main ( cout << "Using config file: " << configFileName << endl; - ifstream configFile( configFileName); - Config config( configFile); + ifstream configFile( configFileName); + Config config( configFile); Ref di = new DarkIce( config); + di->setReportVerbosity( verbosity ); + di->setReportOutputStream( cout ); res = di->run(); @@ -148,6 +158,8 @@ showUsage ( ostream & os ) << endl << " -c, --config=config.file use configuration file config.file" << endl + << " -v, --verbosity=number verbosity level (0 = silent, 10 = loud)" + << endl << " -h, --help print this message and exit" << endl << endl; @@ -159,6 +171,10 @@ showUsage ( ostream & os ) $Source$ $Log$ + Revision 1.5 2000/11/15 18:08:43 darkeye + added multiple verbosity-level event reporting and verbosity command + line option + Revision 1.4 2000/11/13 20:21:29 darkeye added program version display on startup