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

* Refactored the RDAudioExport class to use RDApplication.
This commit is contained in:
Fred Gleason
2018-02-04 06:49:12 -05:00
parent f932a66cee
commit 69817c1941
9 changed files with 79 additions and 95 deletions

View File

@@ -2,7 +2,7 @@
//
// Export an Audio File using the RdXport Web Service
//
// (C) Copyright 2010,2016-2017 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010,2016-2018 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -31,6 +31,7 @@
#include <qapplication.h>
#include <rd.h>
#include <rdapplication.h>
#include <rdxport_interface.h>
#include <rdformpost.h>
#include <rdaudioexport.h>
@@ -51,12 +52,9 @@ int ExportProgressCallback(void *clientp,double dltotal,double dlnow,
}
RDAudioExport::RDAudioExport(RDStation *station,RDConfig *config,
QObject *parent)
RDAudioExport::RDAudioExport(QObject *parent)
: QObject(parent)
{
conv_station=station;
conv_config=config;
conv_cart_number=0;
conv_cut_number=0;
conv_start_point=-1;
@@ -170,13 +168,13 @@ RDAudioExport::ErrorCode RDAudioExport::runExport(const QString &username,
// otherwise some versions of LibCurl will throw a 'bad/illegal format'
// error.
//
strncpy(url,conv_station->webServiceUrl(conv_config),1024);
strncpy(url,rda->station()->webServiceUrl(rda->config()),1024);
curl_easy_setopt(curl,CURLOPT_URL,url);
curl_easy_setopt(curl,CURLOPT_WRITEDATA,f);
curl_easy_setopt(curl,CURLOPT_POST,1);
curl_easy_setopt(curl,CURLOPT_POSTFIELDS,(const char *)post);
curl_easy_setopt(curl,CURLOPT_USERAGENT,
(const char *)conv_config->userAgent());
(const char *)rda->config()->userAgent());
curl_easy_setopt(curl,CURLOPT_TIMEOUT,RD_CURL_TIMEOUT);
curl_easy_setopt(curl,CURLOPT_PROGRESSFUNCTION,ExportProgressCallback);
curl_easy_setopt(curl,CURLOPT_PROGRESSDATA,this);

View File

@@ -2,7 +2,7 @@
//
// Export an Audio File using the RdXport Web Service
//
// (C) Copyright 2010,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010,2016-2018 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -23,8 +23,6 @@
#include <qobject.h>
#include <rdconfig.h>
#include <rdstation.h>
#include <rdsettings.h>
#include <rdaudioconvert.h>
@@ -36,7 +34,7 @@ class RDAudioExport : public QObject
ErrorNoDestination=3,ErrorInternal=5,ErrorUrlInvalid=7,
ErrorService=8,ErrorInvalidUser=9,ErrorAborted=10,
ErrorConverter=11};
RDAudioExport(RDStation *station,RDConfig *config,QObject *parent=0);
RDAudioExport(QObject *parent=0);
unsigned cartNumber() const;
void setCartNumber(unsigned cartnum);
unsigned cutNumber() const;
@@ -61,8 +59,6 @@ class RDAudioExport : public QObject
void strobe();
private:
RDStation *conv_station;
RDConfig *conv_config;
unsigned conv_cart_number;
unsigned conv_cut_number;
QString conv_dst_filename;

View File

@@ -556,7 +556,7 @@ unsigned RDFeed::postCut(RDUser *user,RDStation *station,
*err=RDFeed::ErrorCannotOpenFile;
return 0;
}
RDAudioExport *conv=new RDAudioExport(station,config,this);
RDAudioExport *conv=new RDAudioExport(this);
conv->setCartNumber(cut->cartNumber());
conv->setCutNumber(cut->cutNumber());
conv->setDestinationFile(tmpfile);

View File

@@ -618,7 +618,7 @@ void RDImportAudio::Export()
StartBar();
RDCut *cut=new RDCut(import_cutname);
import_settings->setNormalizationLevel(import_normalize_spin->value());
import_export_conv=new RDAudioExport(import_station,import_config,this);
import_export_conv=new RDAudioExport(this);
import_export_conv->setCartNumber(cut->cartNumber());
import_export_conv->setCutNumber(cut->cutNumber());
import_export_conv->setDestinationFile(import_dest_filename);

View File

@@ -184,7 +184,7 @@ 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(rda->station(),rda->config());
RDAudioExport *conv=new RDAudioExport();
conv->setDestinationFile(*dest_filename);
conv->setCartNumber(RDCut::cartNumber(cutname));
conv->setCutNumber(RDCut::cutNumber(cutname));