2010-11-18 00:32:46 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// LameXP - Audio Encoder Front-End
|
2013-02-08 23:50:51 +01:00
|
|
|
// Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
|
2010-11-18 00:32:46 +01:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
// http://www.gnu.org/licenses/gpl-2.0.txt
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2013-10-09 03:14:38 +02:00
|
|
|
#include <QRunnable>
|
2010-11-18 22:37:35 +01:00
|
|
|
#include <QUuid>
|
2010-12-01 23:14:47 +01:00
|
|
|
#include <QStringList>
|
2010-11-18 00:32:46 +01:00
|
|
|
|
2010-11-19 21:11:54 +01:00
|
|
|
#include "Model_AudioFile.h"
|
2010-11-20 02:14:22 +01:00
|
|
|
#include "Encoder_Abstract.h"
|
2010-11-19 21:11:54 +01:00
|
|
|
|
2011-01-25 23:12:56 +01:00
|
|
|
class AbstractFilter;
|
2011-12-22 00:06:34 +01:00
|
|
|
class WaveProperties;
|
2013-10-09 16:11:58 +02:00
|
|
|
class QThreadPool;
|
|
|
|
class QCoreApplication;
|
2010-11-20 22:14:10 +01:00
|
|
|
|
2013-10-09 03:14:38 +02:00
|
|
|
class ProcessThread: public QObject, public QRunnable
|
2010-11-18 00:32:46 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2011-02-25 22:03:39 +01:00
|
|
|
ProcessThread(const AudioFileModel &audioFile, const QString &outputDirectory, const QString &tempDirectory, AbstractEncoder *encoder, const bool prependRelativeSourcePath);
|
2010-11-18 00:32:46 +01:00
|
|
|
~ProcessThread(void);
|
2010-11-26 00:29:53 +01:00
|
|
|
|
2013-10-11 20:43:31 +02:00
|
|
|
bool init(void);
|
|
|
|
bool start(QThreadPool *pool);
|
2010-11-26 00:29:53 +01:00
|
|
|
|
2013-10-09 03:14:38 +02:00
|
|
|
QUuid getId(void) { return m_jobId; }
|
2011-08-04 23:26:38 +02:00
|
|
|
void setRenamePattern(const QString &pattern);
|
2012-11-08 21:19:45 +01:00
|
|
|
void setOverwriteMode(const bool bSkipExistingFile, const bool ReplacesExisting = false);
|
2011-01-25 23:12:56 +01:00
|
|
|
void addFilter(AbstractFilter *filter);
|
2010-11-18 00:32:46 +01:00
|
|
|
|
2013-10-09 03:14:38 +02:00
|
|
|
public slots:
|
|
|
|
void abort(void) { m_aborted = true; }
|
|
|
|
|
2010-11-20 02:14:22 +01:00
|
|
|
private slots:
|
|
|
|
void handleUpdate(int progress);
|
2010-11-22 21:45:00 +01:00
|
|
|
void handleMessage(const QString &line);
|
2010-11-20 02:14:22 +01:00
|
|
|
|
2010-11-18 00:32:46 +01:00
|
|
|
signals:
|
2010-11-18 22:37:35 +01:00
|
|
|
void processStateInitialized(const QUuid &jobId, const QString &jobName, const QString &jobInitialStatus, int jobInitialState);
|
|
|
|
void processStateChanged(const QUuid &jobId, const QString &newStatus, int newState);
|
2012-11-11 18:33:55 +01:00
|
|
|
void processStateFinished(const QUuid &jobId, const QString &outFileName, int success);
|
2010-11-22 21:45:00 +01:00
|
|
|
void processMessageLogged(const QUuid &jobId, const QString &line);
|
2013-10-09 03:14:38 +02:00
|
|
|
void processFinished(void);
|
2010-11-18 00:32:46 +01:00
|
|
|
|
2013-10-09 16:11:58 +02:00
|
|
|
protected:
|
|
|
|
virtual void run(void);
|
|
|
|
|
2010-11-18 00:32:46 +01:00
|
|
|
private:
|
2010-12-01 23:14:47 +01:00
|
|
|
enum ProcessStep
|
|
|
|
{
|
|
|
|
DecodingStep = 0,
|
2011-12-22 00:06:34 +01:00
|
|
|
AnalyzeStep = 1,
|
|
|
|
FilteringStep = 2,
|
|
|
|
EncodingStep = 3,
|
|
|
|
UnknownStep = 4
|
2010-12-01 23:14:47 +01:00
|
|
|
};
|
|
|
|
|
2010-11-26 00:29:53 +01:00
|
|
|
void processFile();
|
2012-11-08 21:19:45 +01:00
|
|
|
int generateOutFileName(QString &outFileName);
|
2013-10-12 22:55:41 +02:00
|
|
|
QString applyRenamePattern(const QString &baseName, const AudioFileModel_MetaInfo &metaInfo);
|
2010-12-01 23:14:47 +01:00
|
|
|
QString generateTempFileName(void);
|
2011-08-06 18:56:09 +02:00
|
|
|
void insertDownmixFilter(void);
|
2013-10-09 16:11:58 +02:00
|
|
|
void insertDownsampleFilter(void);
|
|
|
|
|
|
|
|
volatile bool m_aborted;
|
2013-10-11 20:43:31 +02:00
|
|
|
volatile int m_initialized;
|
2013-10-09 16:11:58 +02:00
|
|
|
|
2010-11-18 22:37:35 +01:00
|
|
|
const QUuid m_jobId;
|
2010-11-19 21:11:54 +01:00
|
|
|
AudioFileModel m_audioFile;
|
2010-11-20 02:14:22 +01:00
|
|
|
AbstractEncoder *m_encoder;
|
|
|
|
const QString m_outputDirectory;
|
2011-02-25 22:03:39 +01:00
|
|
|
const QString m_tempDirectory;
|
2010-12-01 23:14:47 +01:00
|
|
|
ProcessStep m_currentStep;
|
|
|
|
QStringList m_tempFiles;
|
2010-12-14 01:25:13 +01:00
|
|
|
const bool m_prependRelativeSourcePath;
|
2011-01-25 23:12:56 +01:00
|
|
|
QList<AbstractFilter*> m_filters;
|
2011-08-04 23:26:38 +02:00
|
|
|
QString m_renamePattern;
|
2012-11-08 21:19:45 +01:00
|
|
|
bool m_overwriteSkipExistingFile;
|
|
|
|
bool m_overwriteReplacesExisting;
|
2011-12-22 00:06:34 +01:00
|
|
|
WaveProperties *m_propDetect;
|
2013-10-09 16:11:58 +02:00
|
|
|
QString m_outFileName;
|
2010-11-18 00:32:46 +01:00
|
|
|
};
|