mirror of
				https://github.com/ElvishArtisan/rivendell.git
				synced 2025-10-31 14:13:52 +01:00 
			
		
		
		
	2018-08-10 Fred Gleason <fredg@paravelsystems.com>
* Fixed a regression in 'audio_convert_test' that caused a segfault on startup.
This commit is contained in:
		| @@ -17356,3 +17356,6 @@ | ||||
| 	* Added rdservice(8). | ||||
| 2018-08-10 Fred Gleason <fredg@paravelsystems.com> | ||||
| 	* Modified the boot system to use SystemD. | ||||
| 2018-08-10 Fred Gleason <fredg@paravelsystems.com> | ||||
| 	* Fixed a regression in 'audio_convert_test' that caused a segfault | ||||
| 	on startup. | ||||
|   | ||||
| @@ -20,8 +20,7 @@ | ||||
|  | ||||
| #include <qapplication.h> | ||||
|  | ||||
| #include <rddb.h> | ||||
| #include <rdcmd_switch.h> | ||||
| #include <rdapplication.h> | ||||
| #include <rdaudioconvert.h> | ||||
|  | ||||
| #include <audio_convert_test.h> | ||||
| @@ -29,7 +28,7 @@ | ||||
| MainObject::MainObject(QObject *parent) | ||||
|   :QObject(parent) | ||||
| { | ||||
|   int schema=0; | ||||
|   QString err_msg; | ||||
|  | ||||
|   destination_settings=new RDSettings(); | ||||
|   start_point=-1; | ||||
| @@ -39,38 +38,41 @@ MainObject::MainObject(QObject *parent) | ||||
|   RDAudioConvert::ErrorCode conv_err; | ||||
|  | ||||
|   // | ||||
|   // Read Command Options | ||||
|   // Open the Database | ||||
|   // | ||||
|   RDCmdSwitch *cmd= | ||||
|     new RDCmdSwitch(qApp->argc(),qApp->argv(),"audio_convert_test", | ||||
|   		    AUDIO_CONVERT_TEST_USAGE); | ||||
|   for(unsigned i=0;i<cmd->keys();i++) { | ||||
|     if(cmd->key(i)=="--source-file") { | ||||
|       source_filename=cmd->value(i); | ||||
|       cmd->setProcessed(i,true); | ||||
|   rda=new RDApplication("audio_convert_test","audio_convert_test", | ||||
| 			AUDIO_CONVERT_TEST_USAGE,this); | ||||
|   if(!rda->open(&err_msg)) { | ||||
|     fprintf(stderr,"audio_convert_test: %s\n",(const char *)err_msg.toUtf8()); | ||||
|     exit(1); | ||||
|   } | ||||
|   for(unsigned i=0;i<rda->cmdSwitch()->keys();i++) { | ||||
|     if(rda->cmdSwitch()->key(i)=="--source-file") { | ||||
|       source_filename=rda->cmdSwitch()->value(i); | ||||
|       rda->cmdSwitch()->setProcessed(i,true); | ||||
|     } | ||||
|     if(cmd->key(i)=="--destination-file") { | ||||
|       destination_filename=cmd->value(i); | ||||
|       cmd->setProcessed(i,true); | ||||
|     if(rda->cmdSwitch()->key(i)=="--destination-file") { | ||||
|       destination_filename=rda->cmdSwitch()->value(i); | ||||
|       rda->cmdSwitch()->setProcessed(i,true); | ||||
|     } | ||||
|     if(cmd->key(i)=="--start-point") { | ||||
|       start_point=cmd->value(i).toInt(&ok); | ||||
|     if(rda->cmdSwitch()->key(i)=="--start-point") { | ||||
|       start_point=rda->cmdSwitch()->value(i).toInt(&ok); | ||||
|       if(!ok) { | ||||
| 	fprintf(stderr,"audio_convert_test: invalid start point\n"); | ||||
| 	exit(256); | ||||
|       } | ||||
|       cmd->setProcessed(i,true); | ||||
|       rda->cmdSwitch()->setProcessed(i,true); | ||||
|     } | ||||
|     if(cmd->key(i)=="--end-point") { | ||||
|       end_point=cmd->value(i).toInt(&ok); | ||||
|     if(rda->cmdSwitch()->key(i)=="--end-point") { | ||||
|       end_point=rda->cmdSwitch()->value(i).toInt(&ok); | ||||
|       if(!ok) { | ||||
| 	fprintf(stderr,"audio_convert_test: invalid end point\n"); | ||||
| 	exit(256); | ||||
|       } | ||||
|       cmd->setProcessed(i,true); | ||||
|       rda->cmdSwitch()->setProcessed(i,true); | ||||
|     } | ||||
|     if(cmd->key(i)=="--destination-format") { | ||||
|       RDSettings::Format format=(RDSettings::Format)cmd->value(i).toInt(&ok); | ||||
|     if(rda->cmdSwitch()->key(i)=="--destination-format") { | ||||
|       RDSettings::Format format=(RDSettings::Format)rda->cmdSwitch()->value(i).toInt(&ok); | ||||
|       if(!ok) { | ||||
| 	fprintf(stderr,"audio_convert_test: invalid destination format\n"); | ||||
| 	exit(256); | ||||
| @@ -84,7 +86,7 @@ MainObject::MainObject(QObject *parent) | ||||
|       case RDSettings::Flac: | ||||
|       case RDSettings::OggVorbis: | ||||
| 	destination_settings->setFormat(format); | ||||
| 	cmd->setProcessed(i,true); | ||||
| 	rda->cmdSwitch()->setProcessed(i,true); | ||||
| 	break; | ||||
|  | ||||
|       default: | ||||
| @@ -93,58 +95,58 @@ MainObject::MainObject(QObject *parent) | ||||
|       } | ||||
|       destination_settings->setFormat(format); | ||||
|     } | ||||
|     if(cmd->key(i)=="--destination-channels") { | ||||
|       unsigned channels=cmd->value(i).toInt(&ok); | ||||
|     if(rda->cmdSwitch()->key(i)=="--destination-channels") { | ||||
|       unsigned channels=rda->cmdSwitch()->value(i).toInt(&ok); | ||||
|       if(!ok) { | ||||
| 	fprintf(stderr,"audio_convert_test: invalid destination channels\n"); | ||||
| 	exit(256); | ||||
|       } | ||||
|       destination_settings->setChannels(channels); | ||||
|       cmd->setProcessed(i,true); | ||||
|       rda->cmdSwitch()->setProcessed(i,true); | ||||
|     } | ||||
|     if(cmd->key(i)=="--destination-sample-rate") { | ||||
|       unsigned sample_rate=cmd->value(i).toInt(&ok); | ||||
|     if(rda->cmdSwitch()->key(i)=="--destination-sample-rate") { | ||||
|       unsigned sample_rate=rda->cmdSwitch()->value(i).toInt(&ok); | ||||
|       if(!ok) { | ||||
| 	fprintf(stderr,"audio_convert_test: invalid destination sample rate\n"); | ||||
| 	exit(256); | ||||
|       } | ||||
|       destination_settings->setSampleRate(sample_rate); | ||||
|       cmd->setProcessed(i,true); | ||||
|       rda->cmdSwitch()->setProcessed(i,true); | ||||
|     } | ||||
|     if(cmd->key(i)=="--destination-bit-rate") { | ||||
|       unsigned bit_rate=cmd->value(i).toInt(&ok); | ||||
|     if(rda->cmdSwitch()->key(i)=="--destination-bit-rate") { | ||||
|       unsigned bit_rate=rda->cmdSwitch()->value(i).toInt(&ok); | ||||
|       if(!ok) { | ||||
| 	fprintf(stderr,"audio_convert_test: invalid destination bit rate\n"); | ||||
| 	exit(256); | ||||
|       } | ||||
|       destination_settings->setBitRate(bit_rate); | ||||
|       cmd->setProcessed(i,true); | ||||
|       rda->cmdSwitch()->setProcessed(i,true); | ||||
|     } | ||||
|     if(cmd->key(i)=="--quality") { | ||||
|       unsigned quality=cmd->value(i).toInt(&ok); | ||||
|     if(rda->cmdSwitch()->key(i)=="--quality") { | ||||
|       unsigned quality=rda->cmdSwitch()->value(i).toInt(&ok); | ||||
|       if(!ok) { | ||||
| 	fprintf(stderr,"audio_convert_test: invalid destination quality\n"); | ||||
| 	exit(256); | ||||
|       } | ||||
|       destination_settings->setQuality(quality); | ||||
|       cmd->setProcessed(i,true); | ||||
|       rda->cmdSwitch()->setProcessed(i,true); | ||||
|     } | ||||
|     if(cmd->key(i)=="--normalization-level") { | ||||
|       int normalization_level=cmd->value(i).toInt(&ok); | ||||
|     if(rda->cmdSwitch()->key(i)=="--normalization-level") { | ||||
|       int normalization_level=rda->cmdSwitch()->value(i).toInt(&ok); | ||||
|       if((!ok)||(normalization_level>0)) { | ||||
| 	fprintf(stderr,"audio_convert_test: invalid normalization level\n"); | ||||
| 	exit(256); | ||||
|       } | ||||
|       destination_settings->setNormalizationLevel(normalization_level); | ||||
|       cmd->setProcessed(i,true); | ||||
|       rda->cmdSwitch()->setProcessed(i,true); | ||||
|     } | ||||
|     if(cmd->key(i)=="--speed-ratio") { | ||||
|       speed_ratio=cmd->value(i).toFloat(&ok); | ||||
|     if(rda->cmdSwitch()->key(i)=="--speed-ratio") { | ||||
|       speed_ratio=rda->cmdSwitch()->value(i).toFloat(&ok); | ||||
|       if((!ok)||(speed_ratio<=0)) { | ||||
| 	fprintf(stderr,"audio_convert_test: invalid speed-ratio\n"); | ||||
| 	exit(256); | ||||
|       } | ||||
|       cmd->setProcessed(i,true); | ||||
|       rda->cmdSwitch()->setProcessed(i,true); | ||||
|     } | ||||
|   } | ||||
|   if(source_filename.isEmpty()) { | ||||
| @@ -161,23 +163,6 @@ MainObject::MainObject(QObject *parent) | ||||
|     exit(256); | ||||
|   } | ||||
|  | ||||
|   // | ||||
|   // Read Configuration | ||||
|   // | ||||
|   rdconfig=new RDConfig(); | ||||
|   rdconfig->load(); | ||||
|   rdconfig->setModuleName("audio_convert_test"); | ||||
|  | ||||
|   // | ||||
|   // Open Database | ||||
|   // | ||||
|   QString err (tr("audio_convert_test: ")); | ||||
|   if(!RDOpenDb(&schema,&err,rdconfig)) { | ||||
|     fprintf(stderr,err.ascii()); | ||||
|     delete cmd; | ||||
|     exit(256); | ||||
|   } | ||||
|  | ||||
|   RDAudioConvert *conv=new RDAudioConvert(this); | ||||
|   conv->setSourceFile(source_filename); | ||||
|   conv->setDestinationFile(destination_filename); | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
| // | ||||
| // Test the Rivendell file format converter. | ||||
| // | ||||
| //   (C) Copyright 2010-2016 Fred Gleason <fredg@paravelsystems.com> | ||||
| //   (C) Copyright 2010-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 | ||||
| @@ -24,19 +24,11 @@ | ||||
| #include <list> | ||||
|  | ||||
| #include <qobject.h> | ||||
| #include <qsqldatabase.h> | ||||
|  | ||||
| #include <rdconfig.h> | ||||
| #include <rdsettings.h> | ||||
| #include <rdcmd_switch.cpp> | ||||
|  | ||||
| #define AUDIO_CONVERT_TEST_USAGE "[options]\n\nTest the Rivendell audio converter routines\n\nOptions are:\n--source-file=<filename>\n\n--destination-file=<filename>\n\n--start-point=<msecs>\n\n--end-point=<msecs>\n\n--destination-format=<fmt>\n     Supported formats are:\n        0 - PCM16 WAV\n        2 - MPEG Layer 2\n        3 - MPEG Layer 3\n        4 - FLAC\n        5 - OggVorbis\n        6 - MPEG Layer 2 WAV\n        7 - PCM24 WAV\n\n--destination-channels=<chans>\n\n--destination-sample-rate=<rate>\n\n--destination-bit-rate=<rate>\n\n--destination-quality=<qual>\n\n--normalization-level=<dbfs>\n\n--speed-ratio=<ratio>\n\n" | ||||
|  | ||||
| // | ||||
| // Global Variables | ||||
| // | ||||
| RDConfig *rdconfig; | ||||
|  | ||||
|  | ||||
| class MainObject : public QObject | ||||
| { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user