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

View File

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

View File

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

View File

@ -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() *
bytes = dsp->getSampleRate() *
(dsp->getBitsPerSample() / 8) *
dsp->getChannel() *
duration,
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

View File

@ -49,6 +49,7 @@
#include <iostream.h>
#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

View File

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

View File

@ -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 '?':
@ -123,6 +131,8 @@ main (
ifstream configFile( configFileName);
Config config( configFile);
Ref<DarkIce> 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