2018-02-04 Fred Gleason <fredg@paravelsystems.com>

* Refactored the RDAudioConvert class to use RDApplication.
	* Converted rdcatchd(8) to use RDApplication.
This commit is contained in:
Fred Gleason
2018-02-04 06:18:52 -05:00
parent fb4dc43033
commit e305344e6b
15 changed files with 160 additions and 206 deletions

View File

@@ -39,6 +39,7 @@
#include <qsignalmapper.h>
#include <qsessionmanager.h>
#include <rdapplication.h>
#include <rdaudioconvert.h>
#include <rdcatchd_socket.h>
#include <rdcatchd.h>
@@ -99,7 +100,7 @@ void MainObject::RunBatch(RDCmdSwitch *cmd)
{
bool ok=false;
int id=-1;
unsigned schema=0;
// unsigned schema=0;
//
// Set Process Priority
@@ -134,19 +135,6 @@ void MainObject::RunBatch(RDCmdSwitch *cmd)
//
catch_temp_dir=RDTempDirectory::basePath();
//
// Open Database
//
QString err (tr("ERROR rdcatchd aborting - "));
catch_db=RDInitDb (&schema,&err);
if(!catch_db) {
printf(err.ascii());
exit(1);
}
connect (RDDbStatus(),SIGNAL(logText(RDConfig::LogPriority,const QString &)),
this,SLOT(log(RDConfig::LogPriority,const QString &)));
//
// Load Event
//
@@ -157,7 +145,7 @@ void MainObject::RunBatch(RDCmdSwitch *cmd)
fprintf(stderr,"rdcatchd: id %d not found\n",id);
exit(256);
}
batch_event=new CatchEvent(catch_rdstation,RDConfiguration());
batch_event=new CatchEvent(rda->station(),RDConfiguration());
LoadEvent(q,batch_event,false);
delete q;
@@ -168,7 +156,7 @@ void MainObject::RunBatch(RDCmdSwitch *cmd)
connect(catch_connect,SIGNAL(connected(int,bool)),
this,SLOT(catchConnectedData(int,bool)));
catch_connect->
connectHost("localhost",RDCATCHD_TCP_PORT,catch_config->password());
connectHost("localhost",RDCATCHD_TCP_PORT,rda->config()->password());
}
@@ -187,7 +175,7 @@ void MainObject::RunDownload(CatchEvent *evt)
//
// Resolve Wildcards
//
RDStation *station=new RDStation(catch_config->stationName());
RDStation *station=new RDStation(rda->config()->stationName());
evt->resolveUrl(station->timeOffset());
delete station;
@@ -200,7 +188,7 @@ void MainObject::RunDownload(CatchEvent *evt)
(const char *)evt->resolvedUrl(),
(const char *)evt->tempName(),
evt->id()));
RDDownload *conv=new RDDownload(catch_config,this);
RDDownload *conv=new RDDownload(rda->config(),this);
conv->setSourceUrl(RDUrlEscape(evt->resolvedUrl()));
conv->setDestinationFile(evt->tempName());
@@ -212,7 +200,7 @@ void MainObject::RunDownload(CatchEvent *evt)
url_password=QString(RD_ANON_FTP_PASSWORD)+"-"+VERSION;
}
switch((conv_err=conv->runDownload(url_username,url_password,
catch_config->logXloadDebugData()))) {
rda->config()->logXloadDebugData()))) {
case RDDownload::ErrorOk:
LogLine(RDConfig::LogInfo,QString().
sprintf("finished download of %s to %s, id=%d",
@@ -269,7 +257,7 @@ void MainObject::RunUpload(CatchEvent *evt)
//
// Resolve Wildcards
//
RDStation *station=new RDStation(catch_config->stationName());
RDStation *station=new RDStation(rda->config()->stationName());
evt->resolveUrl(station->timeOffset());
delete station;
@@ -322,7 +310,7 @@ void MainObject::RunUpload(CatchEvent *evt)
(const char *)evt->
resolvedUrl(),
evt->id()));
RDUpload *conv=new RDUpload(catch_config,this);
RDUpload *conv=new RDUpload(rda->config(),this);
conv->setSourceFile(evt->tempName());
conv->setDestinationUrl(evt->resolvedUrl());
QString url_username=evt->urlUsername();
@@ -333,7 +321,7 @@ void MainObject::RunUpload(CatchEvent *evt)
url_password=QString(RD_ANON_FTP_PASSWORD)+"-"+VERSION;
}
switch((conv_err=conv->runUpload(url_username,url_password,
catch_config->logXloadDebugData()))) {
rda->config()->logXloadDebugData()))) {
case RDUpload::ErrorOk:
catch_connect->setExitCode(evt->id(),RDRecording::Ok,tr("Ok"));
qApp->processEvents();
@@ -380,8 +368,8 @@ void MainObject::RunUpload(CatchEvent *evt)
(const char *)evt->tempName()));
}
else {
chown(evt->tempName(),catch_config->uid(),
catch_config->gid());
chown(evt->tempName(),rda->config()->uid(),
rda->config()->gid());
}
}
@@ -400,7 +388,7 @@ bool MainObject::Export(CatchEvent *evt)
return false;
}
RDCart *cart=new RDCart(cut->cartNumber());
RDAudioConvert *conv=new RDAudioConvert(catch_config->stationName(),this);
RDAudioConvert *conv=new RDAudioConvert(this);
conv->setSourceFile(RDCut::pathName(evt->cutName()));
conv->setRange(cut->startPoint(),cut->endPoint());
conv->setDestinationFile(RDEscapeString(evt->tempName()));
@@ -472,7 +460,7 @@ bool MainObject::Import(CatchEvent *evt)
unsigned msecs=wave->getExtTimeLength();
delete wave;
RDCart *cart=new RDCart(cut->cartNumber());
RDAudioConvert *conv=new RDAudioConvert(catch_config->stationName(),this);
RDAudioConvert *conv=new RDAudioConvert(this);
conv->setSourceFile(RDEscapeString(evt->tempName()));
conv->setDestinationFile(RDCut::pathName(evt->cutName()));
RDSettings *settings=new RDSettings();
@@ -492,7 +480,7 @@ bool MainObject::Import(CatchEvent *evt)
break;
}
settings->setChannels(evt->channels());
settings->setSampleRate(catch_system->sampleRate());
settings->setSampleRate(rda->system()->sampleRate());
settings->setBitRate(evt->bitrate());
settings->setNormalizationLevel(evt->normalizeLevel()/100);
LogLine(RDConfig::LogInfo,QString().