added multiple verbosity-level event reporting and verbosity command

line option
This commit is contained in:
darkeye 2000-11-15 18:08:43 +00:00
parent 199799c61d
commit 11f054eeca
7 changed files with 72 additions and 21 deletions

View File

@ -37,6 +37,7 @@
/* ============================================================ include files */ /* ============================================================ include files */
#include "Ref.h" #include "Ref.h"
#include "Reporter.h"
#include "Sink.h" #include "Sink.h"
@ -57,7 +58,7 @@
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class BufferedSink : public Sink class BufferedSink : public Sink, public virtual Reporter
{ {
private: private:
@ -163,6 +164,8 @@ class BufferedSink : public Sink
u = outp <= inp ? inp - outp : (bufferEnd - outp) + (inp - buffer); u = outp <= inp ? inp - outp : (bufferEnd - outp) + (inp - buffer);
if ( peak < u ) { if ( peak < u ) {
reportEvent( 4, "BufferedSink, new peak:", peak);
reportEvent( 4, "BufferedSink, remaining:", bufferSize - peak);
peak = u; peak = u;
} }
} }
@ -388,6 +391,10 @@ class BufferedSink : public Sink
$Source$ $Source$
$Log$ $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 Revision 1.4 2000/11/11 12:33:13 darkeye
added kdoc-style documentation added kdoc-style documentation

View File

@ -265,6 +265,8 @@ Connector :: transfer ( unsigned int bytes,
return 0; return 0;
} }
reportEvent( 6, "Connector :: tranfer, bytes", bytes);
for ( b = 0; b < bytes; ) { for ( b = 0; b < bytes; ) {
unsigned int d = 0; unsigned int d = 0;
unsigned int e = 0; unsigned int e = 0;
@ -274,7 +276,7 @@ Connector :: transfer ( unsigned int bytes,
/* check for EOF */ /* check for EOF */
if ( d == 0 ) { if ( d == 0 ) {
cout << "Connector :: transfer, EOF" << endl; reportEvent( 3, "Connector :: transfer, EOF");
break; break;
} }
@ -289,8 +291,11 @@ cout << "Connector :: transfer, EOF" << endl;
* and the next sink comes to sinks[u] */ * and the next sink comes to sinks[u] */
--u; --u;
reportEvent( 5,
"Connector :: transfer, sink removed, remaining", u);
if ( numSinks == 0 ) { if ( numSinks == 0 ) {
cout << "Connector :: transfer, no more sinks" << endl; reportEvent( 4, "Connector :: transfer, no more sinks");
break; break;
} }
} }
@ -298,7 +303,7 @@ cout << "Connector :: transfer, no more sinks" << endl;
b += d; b += d;
} else { } else {
cout << "Connector :: transfer, can't read" << endl; reportEvent( 3, "Connector :: transfer, can't read");
break; break;
} }
} }
@ -328,6 +333,10 @@ Connector :: close ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $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 Revision 1.2 2000/11/13 18:46:50 darkeye
added kdoc-style documentation comments added kdoc-style documentation comments

View File

@ -38,6 +38,7 @@
#include "Referable.h" #include "Referable.h"
#include "Ref.h" #include "Ref.h"
#include "Reporter.h"
#include "Source.h" #include "Source.h"
#include "Sink.h" #include "Sink.h"
@ -56,7 +57,7 @@
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class Connector : public virtual Referable class Connector : public virtual Referable, public virtual Reporter
{ {
private: private:
@ -257,6 +258,10 @@ class Connector : public virtual Referable
$Source$ $Source$
$Log$ $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 Revision 1.2 2000/11/13 18:46:50 darkeye
added kdoc-style documentation comments added kdoc-style documentation comments

View File

@ -225,9 +225,13 @@ DarkIce :: init ( const Config & config ) throw ( Exception )
} }
// encoder related stuff // encoder related stuff
unsigned int bs = bufferSecs *
(bitsPerSample / 8) * channel * sampleRate;
outputs[i].encIn = new BufferedSink( outputs[i].encInPipe.get(), outputs[i].encIn = new BufferedSink( outputs[i].encInPipe.get(),
bufferSecs * (bitsPerSample / 8) * channel * sampleRate, bs,
(bitsPerSample / 8) * channel ); (bitsPerSample / 8) * channel );
reportEvent( 6, "using buffer size", bs);
encConnector->attach( outputs[i].encIn.get()); encConnector->attach( outputs[i].encIn.get());
outputs[i].encoder = new LameEncoder( encoder, outputs[i].encoder = new LameEncoder( encoder,
outputs[i].encInPipe->getFileName(), outputs[i].encInPipe->getFileName(),
@ -268,6 +272,7 @@ DarkIce :: encode ( void ) throw ( Exception )
{ {
unsigned int len; unsigned int len;
int i; int i;
unsigned int bytes;
for ( i = 0; i < noOutputs; ++i ) { for ( i = 0; i < noOutputs; ++i ) {
outputs[i].encoder->start(); outputs[i].encoder->start();
@ -279,10 +284,12 @@ DarkIce :: encode ( void ) throw ( Exception )
throw Exception( __FILE__, __LINE__, "can't open connector"); throw Exception( __FILE__, __LINE__, "can't open connector");
} }
len = encConnector->transfer( dsp->getSampleRate() * bytes = dsp->getSampleRate() *
(dsp->getBitsPerSample() / 8) * (dsp->getBitsPerSample() / 8) *
dsp->getChannel() * dsp->getChannel() *
duration, duration;
len = encConnector->transfer( bytes,
4096, 4096,
1, 1,
0 ); 0 );
@ -306,6 +313,7 @@ bool
DarkIce :: shout ( unsigned int ix ) throw ( Exception ) DarkIce :: shout ( unsigned int ix ) throw ( Exception )
{ {
unsigned int len; unsigned int len;
unsigned int bytes;
if ( ix >= noOutputs ) { if ( ix >= noOutputs ) {
return false; return false;
@ -315,13 +323,8 @@ DarkIce :: shout ( unsigned int ix ) throw ( Exception )
throw Exception( __FILE__, __LINE__, "can't open connector"); throw Exception( __FILE__, __LINE__, "can't open connector");
} }
len = outputs[ix].shoutConnector->transfer ( bytes = outputs[ix].encoder->getOutBitrate() * (1024 / 8) * duration;
outputs[ix].encoder->getOutBitrate() len = outputs[ix].shoutConnector->transfer ( bytes, 4096, 10, 0 );
* (1024 / 8)
* duration,
4096,
10,
0 );
cout << len << " bytes transfered" << endl; cout << len << " bytes transfered" << endl;
@ -384,6 +387,10 @@ DarkIce :: run ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $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 Revision 1.7 2000/11/13 19:38:55 darkeye
moved command line parameter parsing from DarkIce.cpp to main.cpp moved command line parameter parsing from DarkIce.cpp to main.cpp

View File

@ -49,6 +49,7 @@
#include <iostream.h> #include <iostream.h>
#include "Referable.h" #include "Referable.h"
#include "Reporter.h"
#include "Exception.h" #include "Exception.h"
#include "Ref.h" #include "Ref.h"
#include "OssDspSource.h" #include "OssDspSource.h"
@ -76,7 +77,7 @@
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class DarkIce : public virtual Referable class DarkIce : public virtual Referable, public virtual Reporter
{ {
private: private:
@ -235,6 +236,10 @@ class DarkIce : public virtual Referable
$Source$ $Source$
$Log$ $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 Revision 1.5 2000/11/13 19:38:55 darkeye
moved command line parameter parsing from DarkIce.cpp to main.cpp moved command line parameter parsing from DarkIce.cpp to main.cpp

View File

@ -42,5 +42,7 @@ darkice_SOURCES = AudioEncoder.h\
ConfigSection.cpp\ ConfigSection.cpp\
Config.h\ Config.h\
Config.cpp\ Config.cpp\
Reporter.h\
Reporter.cpp\
main.cpp main.cpp

View File

@ -48,6 +48,7 @@
#include "Ref.h" #include "Ref.h"
#include "Exception.h" #include "Exception.h"
#include "Util.h"
#include "DarkIce.h" #include "DarkIce.h"
@ -90,20 +91,27 @@ main (
try { try {
const char * configFileName = 0; const char * configFileName = 0;
unsigned int verbosity = 1;
int i; int i;
const char opts[] = "hc:v:";
static struct option long_options[] = { static struct option long_options[] = {
{ "config", 1, 0, 'c'}, { "config", 1, 0, 'c'},
{ "help", 0, 0, 'h'}, { "help", 0, 0, 'h'},
{ "verbosity", 1, 0, 'v'},
{ 0, 0, 0, 0} { 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 ) { switch ( i ) {
case 'c': case 'c':
configFileName = optarg; configFileName = optarg;
break; break;
case 'v':
verbosity = Util::strToL( optarg);
break;
default: default:
case ':': case ':':
case '?': case '?':
@ -123,6 +131,8 @@ main (
ifstream configFile( configFileName); 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->setReportOutputStream( cout );
res = di->run(); res = di->run();
@ -148,6 +158,8 @@ showUsage ( ostream & os )
<< endl << endl
<< " -c, --config=config.file use configuration file config.file" << " -c, --config=config.file use configuration file config.file"
<< endl << endl
<< " -v, --verbosity=number verbosity level (0 = silent, 10 = loud)"
<< endl
<< " -h, --help print this message and exit" << " -h, --help print this message and exit"
<< endl << endl
<< endl; << endl;
@ -159,6 +171,10 @@ showUsage ( ostream & os )
$Source$ $Source$
$Log$ $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 Revision 1.4 2000/11/13 20:21:29 darkeye
added program version display on startup added program version display on startup