mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-25 17:08:13 +02:00
2019-12-04 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in rdconvert that caused a segfault at startup.
This commit is contained in:
parent
b501a4f9d9
commit
3c1a287469
@ -19302,3 +19302,5 @@
|
|||||||
to be inserted when generating a log.
|
to be inserted when generating a log.
|
||||||
2019-12-04 Fred Gleason <fredg@paravelsystems.com>
|
2019-12-04 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Incremented the package version to 3.2.0int2.
|
* Incremented the package version to 3.2.0int2.
|
||||||
|
2019-12-04 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Fixed a bug in rdconvert that caused a segfault at startup.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Rivendell file format converter.
|
// Rivendell file format converter.
|
||||||
//
|
//
|
||||||
// (C) Copyright 2017 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2017-2019 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
|
|
||||||
|
#include <rdapplication.h>
|
||||||
#include <rddb.h>
|
#include <rddb.h>
|
||||||
#include <rdcmd_switch.h>
|
#include <rdcmd_switch.h>
|
||||||
#include <rdaudioconvert.h>
|
#include <rdaudioconvert.h>
|
||||||
@ -29,7 +30,7 @@
|
|||||||
MainObject::MainObject(QObject *parent)
|
MainObject::MainObject(QObject *parent)
|
||||||
:QObject(parent)
|
:QObject(parent)
|
||||||
{
|
{
|
||||||
int schema=0;
|
QString err_msg;
|
||||||
|
|
||||||
destination_settings=new RDSettings();
|
destination_settings=new RDSettings();
|
||||||
start_point=-1;
|
start_point=-1;
|
||||||
@ -38,46 +39,46 @@ MainObject::MainObject(QObject *parent)
|
|||||||
bool ok=false;
|
bool ok=false;
|
||||||
RDAudioConvert::ErrorCode conv_err;
|
RDAudioConvert::ErrorCode conv_err;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Open the Database
|
||||||
|
//
|
||||||
|
rda=new RDApplication("rdconvert","rdconvert",RDCONVERT_USAGE,this);
|
||||||
|
if(!rda->open(&err_msg)) {
|
||||||
|
fprintf(stderr,"rdconvert: %s\n",(const char *)err_msg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read Command Options
|
// Read Command Options
|
||||||
//
|
//
|
||||||
RDCmdSwitch *cmd=
|
if(rda->cmdSwitch()->keys()<1) {
|
||||||
new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdconvert",
|
|
||||||
RDCONVERT_USAGE);
|
|
||||||
if(cmd->keys()<1) {
|
|
||||||
fprintf(stderr,"rdconvert: missing argument\n");
|
fprintf(stderr,"rdconvert: missing argument\n");
|
||||||
exit(256);
|
exit(256);
|
||||||
}
|
}
|
||||||
source_filename=cmd->key(cmd->keys()-1);
|
source_filename=rda->cmdSwitch()->key(rda->cmdSwitch()->keys()-1);
|
||||||
for(unsigned i=0;i<cmd->keys()-1;i++) {
|
for(unsigned i=0;i<rda->cmdSwitch()->keys()-1;i++) {
|
||||||
/*
|
if(rda->cmdSwitch()->key(i)=="--destination-file") {
|
||||||
if(cmd->key(i)=="--source-file") {
|
destination_filename=rda->cmdSwitch()->value(i);
|
||||||
source_filename=cmd->value(i);
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
cmd->setProcessed(i,true);
|
|
||||||
}
|
}
|
||||||
*/
|
if(rda->cmdSwitch()->key(i)=="--start-point") {
|
||||||
if(cmd->key(i)=="--destination-file") {
|
start_point=rda->cmdSwitch()->value(i).toInt(&ok);
|
||||||
destination_filename=cmd->value(i);
|
|
||||||
cmd->setProcessed(i,true);
|
|
||||||
}
|
|
||||||
if(cmd->key(i)=="--start-point") {
|
|
||||||
start_point=cmd->value(i).toInt(&ok);
|
|
||||||
if(!ok) {
|
if(!ok) {
|
||||||
fprintf(stderr,"rdconvert: invalid start point\n");
|
fprintf(stderr,"rdconvert: invalid start point\n");
|
||||||
exit(256);
|
exit(256);
|
||||||
}
|
}
|
||||||
cmd->setProcessed(i,true);
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
}
|
}
|
||||||
if(cmd->key(i)=="--end-point") {
|
if(rda->cmdSwitch()->key(i)=="--end-point") {
|
||||||
end_point=cmd->value(i).toInt(&ok);
|
end_point=rda->cmdSwitch()->value(i).toInt(&ok);
|
||||||
if(!ok) {
|
if(!ok) {
|
||||||
fprintf(stderr,"rdconvert: invalid end point\n");
|
fprintf(stderr,"rdconvert: invalid end point\n");
|
||||||
exit(256);
|
exit(256);
|
||||||
}
|
}
|
||||||
cmd->setProcessed(i,true);
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
}
|
}
|
||||||
if(cmd->key(i)=="--destination-format") {
|
if(rda->cmdSwitch()->key(i)=="--destination-format") {
|
||||||
RDSettings::Format format=(RDSettings::Format)cmd->value(i).toInt(&ok);
|
RDSettings::Format format=(RDSettings::Format)rda->cmdSwitch()->value(i).toInt(&ok);
|
||||||
if(!ok) {
|
if(!ok) {
|
||||||
fprintf(stderr,"rdconvert: invalid destination format\n");
|
fprintf(stderr,"rdconvert: invalid destination format\n");
|
||||||
exit(256);
|
exit(256);
|
||||||
@ -91,7 +92,7 @@ MainObject::MainObject(QObject *parent)
|
|||||||
case RDSettings::Flac:
|
case RDSettings::Flac:
|
||||||
case RDSettings::OggVorbis:
|
case RDSettings::OggVorbis:
|
||||||
destination_settings->setFormat(format);
|
destination_settings->setFormat(format);
|
||||||
cmd->setProcessed(i,true);
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -100,58 +101,58 @@ MainObject::MainObject(QObject *parent)
|
|||||||
}
|
}
|
||||||
destination_settings->setFormat(format);
|
destination_settings->setFormat(format);
|
||||||
}
|
}
|
||||||
if(cmd->key(i)=="--destination-channels") {
|
if(rda->cmdSwitch()->key(i)=="--destination-channels") {
|
||||||
unsigned channels=cmd->value(i).toInt(&ok);
|
unsigned channels=rda->cmdSwitch()->value(i).toInt(&ok);
|
||||||
if(!ok) {
|
if(!ok) {
|
||||||
fprintf(stderr,"rdconvert: invalid destination channels\n");
|
fprintf(stderr,"rdconvert: invalid destination channels\n");
|
||||||
exit(256);
|
exit(256);
|
||||||
}
|
}
|
||||||
destination_settings->setChannels(channels);
|
destination_settings->setChannels(channels);
|
||||||
cmd->setProcessed(i,true);
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
}
|
}
|
||||||
if(cmd->key(i)=="--destination-sample-rate") {
|
if(rda->cmdSwitch()->key(i)=="--destination-sample-rate") {
|
||||||
unsigned sample_rate=cmd->value(i).toInt(&ok);
|
unsigned sample_rate=rda->cmdSwitch()->value(i).toInt(&ok);
|
||||||
if(!ok) {
|
if(!ok) {
|
||||||
fprintf(stderr,"rdconvert: invalid destination sample rate\n");
|
fprintf(stderr,"rdconvert: invalid destination sample rate\n");
|
||||||
exit(256);
|
exit(256);
|
||||||
}
|
}
|
||||||
destination_settings->setSampleRate(sample_rate);
|
destination_settings->setSampleRate(sample_rate);
|
||||||
cmd->setProcessed(i,true);
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
}
|
}
|
||||||
if(cmd->key(i)=="--destination-bit-rate") {
|
if(rda->cmdSwitch()->key(i)=="--destination-bit-rate") {
|
||||||
unsigned bit_rate=cmd->value(i).toInt(&ok);
|
unsigned bit_rate=rda->cmdSwitch()->value(i).toInt(&ok);
|
||||||
if(!ok) {
|
if(!ok) {
|
||||||
fprintf(stderr,"rdconvert: invalid destination bit rate\n");
|
fprintf(stderr,"rdconvert: invalid destination bit rate\n");
|
||||||
exit(256);
|
exit(256);
|
||||||
}
|
}
|
||||||
destination_settings->setBitRate(bit_rate);
|
destination_settings->setBitRate(bit_rate);
|
||||||
cmd->setProcessed(i,true);
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
}
|
}
|
||||||
if(cmd->key(i)=="--quality") {
|
if(rda->cmdSwitch()->key(i)=="--quality") {
|
||||||
unsigned quality=cmd->value(i).toInt(&ok);
|
unsigned quality=rda->cmdSwitch()->value(i).toInt(&ok);
|
||||||
if(!ok) {
|
if(!ok) {
|
||||||
fprintf(stderr,"rdconvert: invalid destination quality\n");
|
fprintf(stderr,"rdconvert: invalid destination quality\n");
|
||||||
exit(256);
|
exit(256);
|
||||||
}
|
}
|
||||||
destination_settings->setQuality(quality);
|
destination_settings->setQuality(quality);
|
||||||
cmd->setProcessed(i,true);
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
}
|
}
|
||||||
if(cmd->key(i)=="--normalization-level") {
|
if(rda->cmdSwitch()->key(i)=="--normalization-level") {
|
||||||
int normalization_level=cmd->value(i).toInt(&ok);
|
int normalization_level=rda->cmdSwitch()->value(i).toInt(&ok);
|
||||||
if((!ok)||(normalization_level>0)) {
|
if((!ok)||(normalization_level>0)) {
|
||||||
fprintf(stderr,"rdconvert: invalid normalization level\n");
|
fprintf(stderr,"rdconvert: invalid normalization level\n");
|
||||||
exit(256);
|
exit(256);
|
||||||
}
|
}
|
||||||
destination_settings->setNormalizationLevel(normalization_level);
|
destination_settings->setNormalizationLevel(normalization_level);
|
||||||
cmd->setProcessed(i,true);
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
}
|
}
|
||||||
if(cmd->key(i)=="--speed-ratio") {
|
if(rda->cmdSwitch()->key(i)=="--speed-ratio") {
|
||||||
speed_ratio=cmd->value(i).toFloat(&ok);
|
speed_ratio=rda->cmdSwitch()->value(i).toFloat(&ok);
|
||||||
if((!ok)||(speed_ratio<=0)) {
|
if((!ok)||(speed_ratio<=0)) {
|
||||||
fprintf(stderr,"rdconvert: invalid speed-ratio\n");
|
fprintf(stderr,"rdconvert: invalid speed-ratio\n");
|
||||||
exit(256);
|
exit(256);
|
||||||
}
|
}
|
||||||
cmd->setProcessed(i,true);
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(source_filename.isEmpty()) {
|
if(source_filename.isEmpty()) {
|
||||||
@ -175,16 +176,6 @@ MainObject::MainObject(QObject *parent)
|
|||||||
rdconfig->load();
|
rdconfig->load();
|
||||||
rdconfig->setModuleName("rdconvert");
|
rdconfig->setModuleName("rdconvert");
|
||||||
|
|
||||||
//
|
|
||||||
// Open Database
|
|
||||||
//
|
|
||||||
QString err (tr("rdconvert: "));
|
|
||||||
if(!RDOpenDb(&schema,&err,rdconfig)) {
|
|
||||||
fprintf(stderr,err.ascii());
|
|
||||||
delete cmd;
|
|
||||||
exit(256);
|
|
||||||
}
|
|
||||||
|
|
||||||
RDAudioConvert *conv=new RDAudioConvert(this);
|
RDAudioConvert *conv=new RDAudioConvert(this);
|
||||||
conv->setSourceFile(source_filename);
|
conv->setSourceFile(source_filename);
|
||||||
conv->setDestinationFile(destination_filename);
|
conv->setDestinationFile(destination_filename);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user