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

* Refactored the RDRenderer class to use RDApplication.
This commit is contained in:
Fred Gleason 2018-02-03 05:12:10 -05:00
parent 7a7e3c9b6b
commit fb4dc43033
5 changed files with 46 additions and 50 deletions

View File

@ -16661,3 +16661,5 @@
* Converted wings_filter(1) to use RDApplication.
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug that broke command processing in rdimport(1).
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
* Refactored the RDRenderer class to use RDApplication.

View File

@ -21,6 +21,7 @@
#include <errno.h>
#include <math.h>
#include "rdapplication.h"
#include "rdaudioconvert.h"
#include "rdaudioexport.h"
#include "rdaudioimport.h"
@ -31,18 +32,16 @@
#include "rdrenderer.h"
__RDRenderLogLine::__RDRenderLogLine(RDLogLine *ll,RDUser *user,
RDStation *station,RDSystem *sys,
RDConfig *config,unsigned chans)
__RDRenderLogLine::__RDRenderLogLine(RDLogLine *ll,unsigned chans)
: RDLogLine(*ll)
{
ll_cart=NULL;
ll_cut=NULL;
ll_handle=NULL;
ll_user=user;
ll_station=station;
ll_system=sys;
ll_config=config;
// ll_user=user;
// ll_station=station;
// ll_system=sys;
// ll_config=config;
ll_channels=chans;
ll_ramp_level=0.0;
ll_ramp_rate=0.0;
@ -185,20 +184,20 @@ bool __RDRenderLogLine::GetCutFile(const QString &cutname,int start_pt,
strncpy(tempdir,RDTempDirectory::basePath()+"/rdrenderXXXXXX",PATH_MAX);
*dest_filename=QString(mkdtemp(tempdir))+"/"+cutname+".wav";
RDAudioExport *conv=new RDAudioExport(ll_station,ll_config);
RDAudioExport *conv=new RDAudioExport(rda->station(),rda->config());
conv->setDestinationFile(*dest_filename);
conv->setCartNumber(RDCut::cartNumber(cutname));
conv->setCutNumber(RDCut::cutNumber(cutname));
RDSettings s;
s.setFormat(RDSettings::Pcm16);
s.setSampleRate(ll_system->sampleRate());
s.setSampleRate(rda->system()->sampleRate());
s.setChannels(ll_channels);
s.setNormalizationLevel(0);
conv->setDestinationSettings(&s);
conv->setRange(start_pt,end_pt);
conv->setEnableMetadata(false);
switch(export_err=conv->runExport(ll_user->name(),
ll_user->password(),&conv_err)) {
switch(export_err=conv->runExport(rda->user()->name(),
rda->user()->password(),&conv_err)) {
case RDAudioExport::ErrorOk:
ret=true;
break;
@ -226,20 +225,19 @@ void __RDRenderLogLine::DeleteCutFile(const QString &dest_filename) const
uint64_t __RDRenderLogLine::FramesFromMsec(uint64_t msec)
{
return msec*ll_system->sampleRate()/1000;
return msec*rda->system()->sampleRate()/1000;
}
RDRenderer::RDRenderer(RDUser *user,RDStation *station,RDSystem *system,
RDConfig *config,QObject *parent)
RDRenderer::RDRenderer(QObject *parent)
: QObject(parent)
{
render_user=user;
render_station=station;
render_system=system;
render_config=config;
// render_user=user;
// render_station=station;
// render_system=system;
// render_config=config;
render_total_passes=0;
}
@ -419,7 +417,7 @@ bool RDRenderer::Render(const QString &outfile,RDLogEvent *log,RDSettings *s,
SNDFILE *sf_out;
memset(&sf_info,0,sizeof(sf_info));
sf_info.samplerate=render_system->sampleRate();
sf_info.samplerate=rda->system()->sampleRate();
sf_info.channels=s->channels();
if(s->format()==RDSettings::Pcm16) {
sf_info.format=SF_FORMAT_WAV|SF_FORMAT_PCM_16;
@ -439,9 +437,7 @@ bool RDRenderer::Render(const QString &outfile,RDLogEvent *log,RDSettings *s,
//
std::vector<__RDRenderLogLine *> lls;
for(int i=0;i<log->size();i++) {
lls.push_back(new __RDRenderLogLine(log->logLine(i),render_user,
render_station,render_system,
render_config,s->channels()));
lls.push_back(new __RDRenderLogLine(log->logLine(i),s->channels()));
if(ignore_stops&&(lls.back()->transType()==RDLogLine::Stop)) {
lls.back()->setTransType(RDLogLine::Play);
}
@ -470,9 +466,7 @@ bool RDRenderer::Render(const QString &outfile,RDLogEvent *log,RDSettings *s,
if(!err_msg->isEmpty()) {
return false;
}
lls.push_back(new __RDRenderLogLine(new RDLogLine(),render_user,
render_station,render_system,
render_config,s->channels()));
lls.push_back(new __RDRenderLogLine(new RDLogLine(),s->channels()));
lls.back()->setTransType(RDLogLine::Play);
if((!first_time.isNull())&&(first_line==-1)) {
first_line=log->size();
@ -586,7 +580,7 @@ bool RDRenderer::ConvertAudio(const QString &srcfile,const QString &dstfile,
{
RDAudioConvert::ErrorCode err_code;
RDAudioConvert *conv=new RDAudioConvert(render_station->name(),this);
RDAudioConvert *conv=new RDAudioConvert(rda->station()->name(),this);
conv->setSourceFile(srcfile);
conv->setDestinationFile(dstfile);
conv->setDestinationSettings(s);
@ -608,14 +602,14 @@ bool RDRenderer::ImportCart(const QString &srcfile,unsigned cartnum,int cutnum,
settings.setChannels(chans);
settings.setNormalizationLevel(0);
RDAudioImport *conv=new RDAudioImport(render_station,render_config,this);
RDAudioImport *conv=new RDAudioImport(rda->station(),rda->config(),this);
conv->setCartNumber(cartnum);
conv->setCutNumber(cutnum);
conv->setSourceFile(srcfile);
conv->setUseMetadata(false);
conv->setDestinationSettings(&settings);
err_import_code=
conv->runImport(render_user->name(),render_user->password(),&err_conv_code);
conv->runImport(rda->user()->name(),rda->user()->password(),&err_conv_code);
*err_msg=RDAudioImport::errorText(err_import_code,err_conv_code);
delete conv;
return err_import_code==RDAudioImport::ErrorOk;
@ -633,7 +627,7 @@ void RDRenderer::DeleteTempFile(const QString &filename) const
uint64_t RDRenderer::FramesFromMsec(uint64_t msec) const
{
return msec*render_system->sampleRate()/1000;
return msec*rda->system()->sampleRate()/1000;
}

View File

@ -28,18 +28,19 @@
#include <qobject.h>
#include <qstringlist.h>
#include <rdconfig.h>
//#include <rdconfig.h>
#include <rdlog_event.h>
#include <rdsettings.h>
#include <rdstation.h>
#include <rdsystem.h>
#include <rduser.h>
//#include <rdstation.h>
//#include <rdsystem.h>
//#include <rduser.h>
class __RDRenderLogLine : public RDLogLine
{
public:
__RDRenderLogLine(RDLogLine *ll,RDUser *user,RDStation *station,RDSystem *sys,
RDConfig *config,unsigned chans);
__RDRenderLogLine(RDLogLine *ll,unsigned chans);
// __RDRenderLogLine(RDLogLine *ll,RDUser *user,RDStation *station,RDSystem *sys,
// RDConfig *config,unsigned chans);
RDCart *cart() const;
RDCut *cut() const;
SNDFILE *handle() const;
@ -61,10 +62,10 @@ class __RDRenderLogLine : public RDLogLine
RDCut *ll_cut;
SNDFILE *ll_handle;
RDLogLine *ll_logline;
RDUser *ll_user;
RDStation *ll_station;
RDSystem *ll_system;
RDConfig *ll_config;
// RDUser *ll_user;
// RDStation *ll_station;
// RDSystem *ll_system;
// RDConfig *ll_config;
unsigned ll_channels;
double ll_ramp_level;
double ll_ramp_rate;
@ -77,8 +78,9 @@ class RDRenderer : public QObject
{
Q_OBJECT;
public:
RDRenderer(RDUser *user,RDStation *station,RDSystem *system,RDConfig *config,
QObject *parent=0);
RDRenderer(QObject *parent=0);
// RDRenderer(RDUser *user,RDStation *station,RDSystem *system,RDConfig *config,
// QObject *parent=0);
~RDRenderer();
bool renderToFile(const QString &outfile,RDLogEvent *log,RDSettings *s,
const QTime &start_time,bool ignore_stops,
@ -115,10 +117,10 @@ class RDRenderer : public QObject
void ProgressMessage(const QString &msg);
void ProgressMessage(const QTime &time,int line,const QString &trans,
const QString &msg);
RDUser *render_user;
RDStation *render_station;
RDSystem *render_system;
RDConfig *render_config;
// RDUser *render_user;
// RDStation *render_station;
// RDSystem *render_system;
// RDConfig *render_config;
QStringList render_warnings;
bool render_abort;
int render_total_passes;

View File

@ -280,8 +280,7 @@ void RenderDialog::renderData()
if(render_starttime_box->currentItem()) {
start_time=render_starttime_edit->time();
}
RDRenderer *r=
new RDRenderer(render_user,render_station,render_system,render_config,this);
RDRenderer *r=new RDRenderer(this);
connect(r,SIGNAL(lineStarted(int,int)),
render_progress_dialog,SLOT(setProgress(int,int)));
connect(render_progress_dialog,SIGNAL(cancelled()),r,SLOT(abort()));

View File

@ -82,7 +82,7 @@ MainObject::MainObject(QObject *parent)
fprintf(stderr,"rdrender: you must specify a logname\n");
exit(256);
}
for(unsigned i=0;i<rda->cmdSwitch()->keys();i++) {
for(unsigned i=0;i<rda->cmdSwitch()->keys()-1;i++) {
bool ok=false;
if(rda->cmdSwitch()->key(i)=="--verbose") {
render_verbose=true;
@ -296,8 +296,7 @@ void MainObject::userData()
// Render It
//
QString err_msg;
RDRenderer *r=new RDRenderer(rda->user(),rda->station(),rda->system(),
rda->config(),this);
RDRenderer *r=new RDRenderer(this);
connect(r,SIGNAL(progressMessageSent(const QString &)),
this,SLOT(printProgressMessage(const QString &)));
if(render_to_file.isEmpty()) {