Switch to using QAtomicInc for abort flags.

This commit is contained in:
LoRd_MuldeR 2017-04-18 21:05:28 +02:00
parent 59d99afe8e
commit a0992d475e
81 changed files with 171 additions and 171 deletions

View File

@ -35,7 +35,7 @@
#define VER_LAMEXP_MINOR_LO 5
#define VER_LAMEXP_TYPE Beta
#define VER_LAMEXP_PATCH 4
#define VER_LAMEXP_BUILD 1978
#define VER_LAMEXP_BUILD 1981
#define VER_LAMEXP_CONFG 1934
///////////////////////////////////////////////////////////////////////////////

View File

@ -47,7 +47,7 @@ AACDecoder::~AACDecoder(void)
{
}
bool AACDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool AACDecoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -67,7 +67,7 @@ bool AACDecoder::decode(const QString &sourceFile, const QString &outputFile, vo
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
AACDecoder(void);
~AACDecoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -47,7 +47,7 @@ AC3Decoder::~AC3Decoder(void)
{
}
bool AC3Decoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool AC3Decoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -67,7 +67,7 @@ bool AC3Decoder::decode(const QString &sourceFile, const QString &outputFile, vo
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
AC3Decoder(void);
~AC3Decoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -47,7 +47,7 @@ ADPCMDecoder::~ADPCMDecoder(void)
{
}
bool ADPCMDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool ADPCMDecoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -69,7 +69,7 @@ bool ADPCMDecoder::decode(const QString &sourceFile, const QString &outputFile,
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
ADPCMDecoder(void);
~ADPCMDecoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -48,7 +48,7 @@ ALACDecoder::~ALACDecoder(void)
{
}
bool ALACDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool ALACDecoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -72,7 +72,7 @@ bool ALACDecoder::decode(const QString &sourceFile, const QString &outputFile, v
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
ALACDecoder(void);
~ALACDecoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -36,7 +36,7 @@ public:
typedef struct { const char *const name; const char *const *const exts; } supportedType_t;
//Internal decoder API
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag) = 0;
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag) = 0;
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static bool isDecoderAvailable(void);
static const supportedType_t *supportedTypes(void);

View File

@ -48,7 +48,7 @@ AvisynthDecoder::~AvisynthDecoder(void)
{
}
bool AvisynthDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool AvisynthDecoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -68,7 +68,7 @@ bool AvisynthDecoder::decode(const QString &sourceFile, const QString &outputFil
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
AvisynthDecoder(void);
~AvisynthDecoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -47,7 +47,7 @@ FLACDecoder::~FLACDecoder(void)
{
}
bool FLACDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool FLACDecoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -68,7 +68,7 @@ bool FLACDecoder::decode(const QString &sourceFile, const QString &outputFile, v
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
FLACDecoder(void);
~FLACDecoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -47,7 +47,7 @@ MACDecoder::~MACDecoder(void)
{
}
bool MACDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool MACDecoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -69,7 +69,7 @@ bool MACDecoder::decode(const QString &sourceFile, const QString &outputFile, vo
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
MACDecoder(void);
~MACDecoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -48,7 +48,7 @@ MP3Decoder::~MP3Decoder(void)
{
}
bool MP3Decoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool MP3Decoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -69,7 +69,7 @@ bool MP3Decoder::decode(const QString &sourceFile, const QString &outputFile, vo
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
MP3Decoder(void);
~MP3Decoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -48,7 +48,7 @@ MusepackDecoder::~MusepackDecoder(void)
{
}
bool MusepackDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool MusepackDecoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -70,7 +70,7 @@ bool MusepackDecoder::decode(const QString &sourceFile, const QString &outputFil
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
MusepackDecoder(void);
~MusepackDecoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -50,7 +50,7 @@ OpusDecoder::~OpusDecoder(void)
{
}
bool OpusDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool OpusDecoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -76,7 +76,7 @@ bool OpusDecoder::decode(const QString &sourceFile, const QString &outputFile, v
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
OpusDecoder(void);
~OpusDecoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -48,7 +48,7 @@ ShortenDecoder::~ShortenDecoder(void)
{
}
bool ShortenDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool ShortenDecoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -70,7 +70,7 @@ bool ShortenDecoder::decode(const QString &sourceFile, const QString &outputFile
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
ShortenDecoder(void);
~ShortenDecoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -47,7 +47,7 @@ SpeexDecoder::~SpeexDecoder(void)
{
}
bool SpeexDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool SpeexDecoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -68,7 +68,7 @@ bool SpeexDecoder::decode(const QString &sourceFile, const QString &outputFile,
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
SpeexDecoder(void);
~SpeexDecoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -48,7 +48,7 @@ TTADecoder::~TTADecoder(void)
{
}
bool TTADecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool TTADecoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -69,7 +69,7 @@ bool TTADecoder::decode(const QString &sourceFile, const QString &outputFile, vo
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
TTADecoder(void);
~TTADecoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -47,7 +47,7 @@ VorbisDecoder::~VorbisDecoder(void)
{
}
bool VorbisDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool VorbisDecoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -68,7 +68,7 @@ bool VorbisDecoder::decode(const QString &sourceFile, const QString &outputFile,
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
VorbisDecoder(void);
~VorbisDecoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -49,7 +49,7 @@ WMADecoder::~WMADecoder(void)
{
}
bool WMADecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool WMADecoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -69,7 +69,7 @@ bool WMADecoder::decode(const QString &sourceFile, const QString &outputFile, vo
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -32,7 +32,7 @@ public:
WMADecoder(void);
~WMADecoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -47,7 +47,7 @@ WavPackDecoder::~WavPackDecoder(void)
{
}
bool WavPackDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool WavPackDecoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -69,7 +69,7 @@ bool WavPackDecoder::decode(const QString &sourceFile, const QString &outputFile
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
WavPackDecoder(void);
~WavPackDecoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -31,12 +31,12 @@
#include <QDir>
//Type
typedef struct _ProgressData
typedef struct _callback_t
{
WaveDecoder *const instance;
volatile bool *const abrtFlag;
WaveDecoder *const pInstance;
QAtomicInt *const abortFlag;
}
ProgressData;
callback_t;
WaveDecoder::WaveDecoder(void)
{
@ -46,12 +46,12 @@ WaveDecoder::~WaveDecoder(void)
{
}
bool WaveDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
bool WaveDecoder::decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag)
{
emit messageLogged(QString("Copy file \"%1\" to \"%2\"").arg(QDir::toNativeSeparators(sourceFile), QDir::toNativeSeparators(outputFile)));
emit statusUpdated(0);
ProgressData progressData = { this, abortFlag };
callback_t progressData = { this, &abortFlag };
const bool okay = MUtils::OS::copy_file(sourceFile, outputFile, true, progressHandler, &progressData);
emit statusUpdated(100);
@ -68,13 +68,12 @@ bool WaveDecoder::decode(const QString &sourceFile, const QString &outputFile, v
return okay;
}
bool WaveDecoder::progressHandler(const double &progress, void *const data)
bool WaveDecoder::progressHandler(const double &progress, void *const userData)
{
if(data)
if(const callback_t *const ptr = reinterpret_cast<callback_t*>(userData))
{
//qWarning("Copy progress: %.2f", progress);
reinterpret_cast<ProgressData*>(data)->instance->updateProgress(progress);
return (!(*reinterpret_cast<ProgressData*>(data)->abrtFlag));
ptr->pInstance->updateProgress(progress);
return ptr->abortFlag->operator!();
}
return true;
}

View File

@ -30,7 +30,7 @@ public:
WaveDecoder(void);
~WaveDecoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
virtual bool decode(const QString &sourceFile, const QString &outputFile, QAtomicInt &abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static const supportedType_t *supportedTypes(void);

View File

@ -146,7 +146,7 @@ AACEncoder::~AACEncoder(void)
{
}
bool AACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag)
bool AACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -219,7 +219,7 @@ bool AACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;
@ -331,7 +331,7 @@ bool AACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -34,7 +34,7 @@ public:
AACEncoder(void);
~AACEncoder(void);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag);
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
virtual const bool needsTimingInfo(void);

View File

@ -148,7 +148,7 @@ FDKAACEncoder::~FDKAACEncoder(void)
{
}
bool FDKAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag)
bool FDKAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -209,7 +209,7 @@ bool FDKAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -34,7 +34,7 @@ public:
FDKAACEncoder(void);
~FDKAACEncoder(void);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag);
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
//Advanced options

View File

@ -146,7 +146,7 @@ FHGAACEncoder::~FHGAACEncoder(void)
{
}
bool FHGAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag)
bool FHGAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -204,7 +204,7 @@ bool FHGAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if (checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -34,7 +34,7 @@ public:
FHGAACEncoder(void);
~FHGAACEncoder(void);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag);
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
virtual const unsigned int *supportedChannelCount(void);
virtual const unsigned int *supportedBitdepths(void);

View File

@ -157,7 +157,7 @@ QAACEncoder::~QAACEncoder(void)
{
}
bool QAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag)
bool QAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag)
{
const QString qaac_bin = m_binary_qaac64.isEmpty() ? m_binary_qaac32 : m_binary_qaac64;
@ -230,7 +230,7 @@ bool QAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if (checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -34,7 +34,7 @@ public:
QAACEncoder(void);
~QAACEncoder(void);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag);
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
//Advanced options

View File

@ -144,7 +144,7 @@ AC3Encoder::~AC3Encoder(void)
{
}
bool AC3Encoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag)
bool AC3Encoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -197,7 +197,7 @@ bool AC3Encoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if (checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -34,7 +34,7 @@ public:
AC3Encoder(void);
~AC3Encoder(void);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag);
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
virtual const unsigned int *supportedChannelCount(void);
virtual const unsigned int *supportedSamplerates(void);

View File

@ -66,7 +66,7 @@ public:
virtual ~AbstractEncoder(void);
//Internal encoder API
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag) = 0;
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag) = 0;
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion) = 0;
virtual const unsigned int *supportedSamplerates(void);
virtual const unsigned int *supportedChannelCount(void);

View File

@ -141,7 +141,7 @@ DCAEncoder::~DCAEncoder(void)
{
}
bool DCAEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag)
bool DCAEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -163,7 +163,7 @@ bool DCAEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if (checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -34,7 +34,7 @@ public:
DCAEncoder(void);
~DCAEncoder(void);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag);
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
virtual const unsigned int *supportedChannelCount(void);
virtual const unsigned int *supportedBitdepths(void);

View File

@ -135,7 +135,7 @@ FLACEncoder::~FLACEncoder(void)
{
}
bool FLACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag)
bool FLACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -172,7 +172,7 @@ bool FLACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -34,7 +34,7 @@ public:
FLACEncoder(void);
~FLACEncoder(void);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag);
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
virtual const unsigned int *supportedChannelCount(void);
virtual const unsigned int *supportedBitdepths(void);

View File

@ -136,7 +136,7 @@ MACEncoder::~MACEncoder(void)
{
}
bool MACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag)
bool MACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -169,7 +169,7 @@ bool MACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if (checkFlag(abortFlag))
{
process.kill();
bAborted = true;
@ -250,7 +250,7 @@ bool MACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -34,7 +34,7 @@ public:
MACEncoder(void);
~MACEncoder(void);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag);
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
//Encoder info

View File

@ -146,7 +146,7 @@ MP3Encoder::~MP3Encoder(void)
{
}
bool MP3Encoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag)
bool MP3Encoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -241,7 +241,7 @@ bool MP3Encoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if (checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -34,7 +34,7 @@ public:
MP3Encoder(void);
~MP3Encoder(void);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag);
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
virtual const unsigned int *supportedChannelCount(void);

View File

@ -140,7 +140,7 @@ OpusEncoder::~OpusEncoder(void)
{
}
bool OpusEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag)
bool OpusEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -214,7 +214,7 @@ bool OpusEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if (checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -34,7 +34,7 @@ public:
OpusEncoder(void);
~OpusEncoder(void);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag);
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
virtual const unsigned int *supportedChannelCount(void);
virtual const unsigned int *supportedBitdepths(void);

View File

@ -141,7 +141,7 @@ VorbisEncoder::~VorbisEncoder(void)
{
}
bool VorbisEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag)
bool VorbisEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -204,7 +204,7 @@ bool VorbisEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -34,7 +34,7 @@ public:
VorbisEncoder(void);
~VorbisEncoder(void);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag);
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
virtual void setBitrateLimits(int minimumBitrate, int maximumBitrate);

View File

@ -30,8 +30,8 @@
typedef struct _callback_t
{
WaveEncoder *pInstance;
volatile bool *abortFlag;
WaveEncoder *const pInstance;
QAtomicInt *const abortFlag;
}
callback_t;
@ -132,13 +132,11 @@ WaveEncoder::~WaveEncoder(void)
{
}
bool WaveEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag)
bool WaveEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag)
{
emit messageLogged(QString("Copy file \"%1\" to \"%2\"\n").arg(sourceFile, outputFile));
callback_t callbackData;
callbackData.abortFlag = abortFlag;
callbackData.pInstance = this;
callback_t callbackData = { this, &abortFlag };
emit statusUpdated(0);
const bool success = MUtils::OS::copy_file(sourceFile, outputFile, true, progressCallback, &callbackData);
@ -150,7 +148,7 @@ bool WaveEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
}
else
{
emit messageLogged((*abortFlag) ? L1S("Operation cancelled by user!") : L1S("Error: Failed to copy file!"));
emit messageLogged(checkFlag(abortFlag) ? L1S("Operation cancelled by user!") : L1S("Error: Failed to copy file!"));
}
return success;
@ -158,12 +156,11 @@ bool WaveEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
bool WaveEncoder::progressCallback(const double &progress, void *const userData)
{
const callback_t *const ptr = reinterpret_cast<callback_t*>(userData);
if (*(ptr->abortFlag))
if (const callback_t *const ptr = reinterpret_cast<callback_t*>(userData))
{
return false; /*user aborted*/
}
ptr->pInstance->updateProgress(progress);
return ptr->abortFlag->operator!();
}
return true;
}

View File

@ -34,7 +34,7 @@ public:
WaveEncoder(void);
~WaveEncoder(void);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, volatile bool *abortFlag);
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const unsigned int channels, const QString &outputFile, QAtomicInt &abortFlag);
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
//Encoder info

View File

@ -43,6 +43,6 @@ public:
};
//Internal decoder API
virtual FilterResult apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag) = 0;
virtual FilterResult apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, QAtomicInt &abortFlag) = 0;
};

View File

@ -51,7 +51,7 @@ DownmixFilter::~DownmixFilter(void)
{
}
AbstractFilter::FilterResult DownmixFilter::apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag)
AbstractFilter::FilterResult DownmixFilter::apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, QAtomicInt &abortFlag)
{
unsigned int channels = formatInfo->audioChannels();
emit messageLogged(QString().sprintf("--> Number of channels is: %d\n", channels));
@ -112,7 +112,7 @@ AbstractFilter::FilterResult DownmixFilter::apply(const QString &sourceFile, con
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -32,7 +32,7 @@ public:
DownmixFilter(void);
~DownmixFilter(void);
virtual FilterResult apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag);
virtual FilterResult apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, QAtomicInt &abortFlag);
private:
const QString m_binary;

View File

@ -57,7 +57,7 @@ NormalizeFilter::~NormalizeFilter(void)
{
}
AbstractFilter::FilterResult NormalizeFilter::apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag)
AbstractFilter::FilterResult NormalizeFilter::apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -96,7 +96,7 @@ AbstractFilter::FilterResult NormalizeFilter::apply(const QString &sourceFile, c
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
NormalizeFilter(const int &peakVolume = -50, const bool &dnyAudNorm = false, const bool &channelsCoupled = true, const int &filterSize = 31);
~NormalizeFilter(void);
virtual FilterResult apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag);
virtual FilterResult apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, QAtomicInt &abortFlag);
private:
const QString m_binary;

View File

@ -61,7 +61,7 @@ ResampleFilter::~ResampleFilter(void)
{
}
AbstractFilter::FilterResult ResampleFilter::apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag)
AbstractFilter::FilterResult ResampleFilter::apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -109,7 +109,7 @@ AbstractFilter::FilterResult ResampleFilter::apply(const QString &sourceFile, co
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
ResampleFilter(int samplingRate = 0, int bitDepth = 0);
~ResampleFilter(void);
virtual FilterResult apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag);
virtual FilterResult apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, QAtomicInt &abortFlag);
private:
const QString m_binary;

View File

@ -51,7 +51,7 @@ ToneAdjustFilter::~ToneAdjustFilter(void)
{
}
AbstractFilter::FilterResult ToneAdjustFilter::apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag)
AbstractFilter::FilterResult ToneAdjustFilter::apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -82,7 +82,7 @@ AbstractFilter::FilterResult ToneAdjustFilter::apply(const QString &sourceFile,
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -30,7 +30,7 @@ public:
ToneAdjustFilter(int bass = 0, int treble = 0);
~ToneAdjustFilter(void);
virtual FilterResult apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag);
virtual FilterResult apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, QAtomicInt &abortFlag);
private:
const QString m_binary;

View File

@ -47,6 +47,9 @@
#include <float.h>
#include <limits>
//Utils
#define IS_ABORTED (!(!m_abortFlag))
////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////
@ -95,7 +98,6 @@ void CueSplitter::run()
{
m_bSuccess = false;
m_bAborted = false;
m_abortFlag = false;
m_nTracksSuccess = 0;
m_nTracksSkipped = 0;
m_decompressedFiles.clear();
@ -130,7 +132,7 @@ void CueSplitter::run()
QString tempFile = QString("%1/~%2.wav").arg(m_outputDir, MUtils::next_rand_str());
connect(decoder, SIGNAL(statusUpdated(int)), this, SLOT(handleUpdate(int)), Qt::DirectConnection);
if(decoder->decode(inputFileList.at(i), tempFile, &m_abortFlag))
if(decoder->decode(inputFileList.at(i), tempFile, m_abortFlag))
{
m_decompressedFiles.insert(inputFileList.at(i), tempFile);
m_tempFiles.append(tempFile);
@ -154,7 +156,7 @@ void CueSplitter::run()
m_decompressedFiles.insert(inputFileList.at(i), inputFileList.at(i));
}
if(m_abortFlag)
if(IS_ABORTED)
{
m_bAborted = true;
qWarning("The user has requested to abort the process!");
@ -219,7 +221,7 @@ void CueSplitter::run()
splitFile(outputFile, trackNo, trackFile, trackOffset, trackLength, trackMetaInfo, nTracksComplete);
emit progressValChanged(nTracksComplete += 10);
if(m_abortFlag)
if(IS_ABORTED)
{
m_bAborted = true;
qWarning("The user has requested to abort the process!");
@ -320,7 +322,7 @@ void CueSplitter::splitFile(const QString &output, const int trackNo, const QStr
while(process.state() != QProcess::NotRunning)
{
if(m_abortFlag)
if(IS_ABORTED)
{
process.kill();
qWarning("Process was aborted on user request!");

View File

@ -61,7 +61,7 @@ private slots:
void handleUpdate(int progress);
public slots:
void abortProcess(void) { m_abortFlag = true; }
void abortProcess(void) { m_abortFlag.ref(); }
private:
void splitFile(const QString &output, const int trackNo, const QString &file, const double offset, const double length, const AudioFileModel_MetaInfo &metaInfo, const int baseProgress);
@ -79,7 +79,7 @@ private:
bool m_bAborted;
bool m_bSuccess;
volatile bool m_abortFlag;
QAtomicInt m_abortFlag;
CueSheetModel *m_model;
QMap<QString,AudioFileModel> m_inputFilesInfo;

View File

@ -56,6 +56,9 @@ static inline void SAFE_APPEND_STRING(QStringList &list, const QString &str)
}
}
//Utils
#define IS_ABORTED (!(!m_bAborted))
////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////
@ -68,9 +71,6 @@ FileAnalyzer::FileAnalyzer(const QStringList &inputFiles)
m_templateFile(NULL),
m_pool(NULL)
{
m_bSuccess = false;
m_bAborted = false;
m_filesAccepted = 0;
m_filesRejected = 0;
m_filesDenied = 0;
@ -144,7 +144,7 @@ const char *FileAnalyzer::g_tags_aud[] =
void FileAnalyzer::run()
{
m_bSuccess = false;
m_bSuccess.fetchAndStoreOrdered(0);
m_tasksCounterNext = 0;
m_tasksCounterDone = 0;
@ -207,7 +207,7 @@ void FileAnalyzer::run()
m_pool->waitForDone();
//Was opertaion aborted?
if(m_bAborted)
if(IS_ABORTED)
{
qWarning("Operation cancelled by user!");
return;
@ -228,8 +228,7 @@ void FileAnalyzer::run()
}
qDebug("All files added.\n");
m_bSuccess = true;
m_bSuccess.fetchAndStoreOrdered(1);
QThread::msleep(333);
}
@ -239,7 +238,7 @@ void FileAnalyzer::run()
bool FileAnalyzer::analyzeNextFile(void)
{
if(!(m_inputFiles.isEmpty() || m_bAborted))
if(!(m_inputFiles.isEmpty() || IS_ABORTED))
{
const unsigned int taskId = m_tasksCounterNext++;
const QString currentFile = QDir::fromNativeSeparators(m_inputFiles.takeFirst());
@ -250,7 +249,7 @@ bool FileAnalyzer::analyzeNextFile(void)
m_timer->restart();
}
AnalyzeTask *task = new AnalyzeTask(taskId, currentFile, m_templateFile->filePath(), &m_bAborted);
AnalyzeTask *task = new AnalyzeTask(taskId, currentFile, m_templateFile->filePath(), m_bAborted);
connect(task, SIGNAL(fileAnalyzed(const unsigned int, const int, AudioFileModel)), this, SLOT(taskFileAnalyzed(unsigned int, const int, AudioFileModel)), Qt::QueuedConnection);
connect(task, SIGNAL(taskCompleted(const unsigned int)), this, SLOT(taskThreadFinish(const unsigned int)), Qt::QueuedConnection);
m_runningTaskIds.insert(taskId); m_pool->start(task);

View File

@ -49,7 +49,7 @@ public:
FileAnalyzer(const QStringList &inputFiles);
~FileAnalyzer(void);
void run();
bool getSuccess(void) { return (!isRunning()) && (!m_bAborted) && m_bSuccess; }
bool getSuccess(void) { return (!isRunning()) && (!m_bAborted) && (!(!m_bSuccess)); }
unsigned int filesAccepted(void);
unsigned int filesRejected(void);
@ -64,7 +64,7 @@ signals:
void progressMaxChanged(unsigned int);
public slots:
void abortProcess(void) { m_bAborted = true; exit(-1); }
void abortProcess(void) { m_bAborted.ref(); exit(-1); }
private slots:
void initializeTasks(void);
@ -99,6 +99,6 @@ private:
static const char *g_tags_gen[];
static const char *g_tags_aud[];
volatile bool m_bAborted;
volatile bool m_bSuccess;
QAtomicInt m_bAborted;
QAtomicInt m_bSuccess;
};

View File

@ -54,12 +54,13 @@
#define IS_KEY(KEY) (key.compare(KEY, Qt::CaseInsensitive) == 0)
#define IS_SEC(SEC) (key.startsWith((SEC "_"), Qt::CaseInsensitive))
#define FIRST_TOK(STR) (STR.split(" ", QString::SkipEmptyParts).first())
#define IS_ABORTED (!(!m_abortFlag))
////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////
AnalyzeTask::AnalyzeTask(const int taskId, const QString &inputFile, const QString &templateFile, volatile bool *abortFlag)
AnalyzeTask::AnalyzeTask(const int taskId, const QString &inputFile, const QString &templateFile, QAtomicInt &abortFlag)
:
m_taskId(taskId),
m_inputFile(inputFile),
@ -109,7 +110,7 @@ void AnalyzeTask::run_ex(void)
AudioFileModel file = analyzeFile(currentFile, &fileType);
if(*m_abortFlag)
if(IS_ABORTED)
{
qWarning("Operation cancelled by user!");
return;
@ -203,7 +204,7 @@ const AudioFileModel AnalyzeTask::analyzeFile(const QString &filePath, int *type
while(process.state() != QProcess::NotRunning)
{
if(*m_abortFlag)
if(IS_ABORTED)
{
process.kill();
qWarning("Process was aborted on user request!");
@ -530,7 +531,7 @@ bool AnalyzeTask::analyzeAvisynthFile(const QString &filePath, AudioFileModel &i
while(process.state() != QProcess::NotRunning)
{
if(*m_abortFlag)
if(IS_ABORTED)
{
process.kill();
qWarning("Process was aborted on user request!");

View File

@ -45,7 +45,7 @@ class AnalyzeTask: public QObject, public QRunnable
Q_OBJECT
public:
AnalyzeTask(const int taskId, const QString &inputFile, const QString &templateFile, volatile bool *abortFlag);
AnalyzeTask(const int taskId, const QString &inputFile, const QString &templateFile, QAtomicInt &abortFlag);
~AnalyzeTask(void);
enum fileType_t
@ -81,5 +81,5 @@ private:
const QString m_templateFile;
const QString m_inputFile;
volatile bool *m_abortFlag;
QAtomicInt &m_abortFlag;
};

View File

@ -56,6 +56,7 @@
#define DIFF(X,Y) ((X > Y) ? (X-Y) : (Y-X))
#define IS_WAVE(X) ((X.containerType().compare("Wave", Qt::CaseInsensitive) == 0) && (X.audioType().compare("PCM", Qt::CaseInsensitive) == 0))
#define IS_ABORTED (!(!m_aborted))
#define STRDEF(STR,DEF) ((!STR.isEmpty()) ? STR : DEF)
////////////////////////////////////////////////////////////
@ -74,7 +75,6 @@ ProcessThread::ProcessThread(const AudioFileModel &audioFile, const QString &out
m_overwriteMode(OverwriteMode_KeepBoth),
m_keepDateTime(false),
m_initialized(-1),
m_aborted(false),
m_propDetect(new WaveProperties())
{
connect(m_encoder, SIGNAL(statusUpdated(int)), this, SLOT(handleUpdate(int)), Qt::DirectConnection);
@ -110,10 +110,8 @@ ProcessThread::~ProcessThread(void)
bool ProcessThread::init(void)
{
if(m_initialized < 0)
if(m_initialized.testAndSetOrdered((-1), 0))
{
m_initialized = 0;
//Initialize job status
qDebug("Process thread %s has started.", m_jobId.toString().toLatin1().constData());
emit processStateInitialized(m_jobId, QFileInfo(m_audioFile.filePath()).fileName(), tr("Starting..."), ProgressModel::JobRunning);
@ -137,11 +135,10 @@ bool ProcessThread::start(QThreadPool *const pool)
MUTILS_THROW("Object not initialized yet!");
}
if(m_initialized < 1)
if (m_initialized.testAndSetOrdered(0, 1))
{
m_initialized = 1;
m_outFileName.clear();
m_aborted.fetchAndStoreOrdered(0);
bool bSuccess = false;
//Generate output file name
@ -228,7 +225,7 @@ void ProcessThread::processFile()
connect(decoder, SIGNAL(statusUpdated(int)), this, SLOT(handleUpdate(int)), Qt::DirectConnection);
connect(decoder, SIGNAL(messageLogged(QString)), this, SLOT(handleMessage(QString)), Qt::DirectConnection);
bSuccess = decoder->decode(sourceFile, tempFile, &m_aborted);
bSuccess = decoder->decode(sourceFile, tempFile, m_aborted);
MUTILS_DELETE(decoder);
if(bSuccess)
@ -259,12 +256,12 @@ void ProcessThread::processFile()
// Update audio properties after decode
//-----------------------------------------------------
if(bSuccess && !m_aborted && IS_WAVE(m_audioFile.techInfo()))
if(bSuccess && (!m_aborted) && IS_WAVE(m_audioFile.techInfo()))
{
if(m_encoder->supportedSamplerates() || m_encoder->supportedBitdepths() || m_encoder->supportedChannelCount() || m_encoder->needsTimingInfo() || !m_filters.isEmpty())
{
m_currentStep = AnalyzeStep;
bSuccess = m_propDetect->detect(sourceFile, &m_audioFile.techInfo(), &m_aborted);
bSuccess = m_propDetect->detect(sourceFile, &m_audioFile.techInfo(), m_aborted);
if(bSuccess)
{
@ -301,7 +298,7 @@ void ProcessThread::processFile()
connect(poFilter, SIGNAL(statusUpdated(int)), this, SLOT(handleUpdate(int)), Qt::DirectConnection);
connect(poFilter, SIGNAL(messageLogged(QString)), this, SLOT(handleMessage(QString)), Qt::DirectConnection);
const AbstractFilter::FilterResult filterResult = poFilter->apply(sourceFile, tempFile, &m_audioFile.techInfo(), &m_aborted);
const AbstractFilter::FilterResult filterResult = poFilter->apply(sourceFile, tempFile, &m_audioFile.techInfo(), m_aborted);
switch (filterResult)
{
case AbstractFilter::FILTER_SUCCESS:
@ -320,14 +317,14 @@ void ProcessThread::processFile()
// Encode audio file
//-----------------------------------------------------
if(bSuccess && !m_aborted)
if(bSuccess && (!m_aborted))
{
m_currentStep = EncodingStep;
bSuccess = m_encoder->encode(sourceFile, m_audioFile.metaInfo(), m_audioFile.techInfo().duration(), m_audioFile.techInfo().audioChannels(), m_outFileName, &m_aborted);
bSuccess = m_encoder->encode(sourceFile, m_audioFile.metaInfo(), m_audioFile.techInfo().duration(), m_audioFile.techInfo().audioChannels(), m_outFileName, m_aborted);
}
//Clean-up
if((!bSuccess) || m_aborted)
if((!bSuccess) || IS_ABORTED)
{
QFileInfo fileInfo(m_outFileName);
if(fileInfo.exists() && (fileInfo.size() < 1024))
@ -355,7 +352,7 @@ void ProcessThread::processFile()
MUtils::OS::sleep_ms(12);
//Report result
emit processStateChanged(m_jobId, (m_aborted ? tr("Aborted!") : (bSuccess ? tr("Done.") : tr("Failed!"))), ((bSuccess && !m_aborted) ? ProgressModel::JobComplete : ProgressModel::JobFailed));
emit processStateChanged(m_jobId, (IS_ABORTED ? tr("Aborted!") : (bSuccess ? tr("Done.") : tr("Failed!"))), ((bSuccess && (!m_aborted)) ? ProgressModel::JobComplete : ProgressModel::JobFailed));
emit processStateFinished(m_jobId, m_outFileName, (bSuccess ? 1 : 0));
qDebug("Process thread is done.");

View File

@ -54,7 +54,7 @@ public:
void addFilter(AbstractFilter *filter);
public slots:
void abort(void) { m_aborted = true; }
void abort(void) { m_aborted.ref(); }
private slots:
void handleUpdate(int progress);
@ -96,8 +96,8 @@ private:
bool insertDownsampleFilter(const unsigned int *const supportedSamplerates, const unsigned int *const supportedBitdepths);
bool updateFileTime(const QString &originalFile, const QString &modifiedFile);
volatile bool m_aborted;
volatile int m_initialized;
QAtomicInt m_aborted;
QAtomicInt m_initialized;
const QUuid m_jobId;
AudioFileModel m_audioFile;

View File

@ -51,6 +51,11 @@ signals:
protected:
static const int m_processTimeoutInterval = 600000;
static __forceinline bool checkFlag(QAtomicInt &flag)
{
return (!(!flag));
}
private:
static QScopedPointer<MUtils::JobObject> s_jobObjectInstance;
static QScopedPointer<QElapsedTimer> s_startProcessTimer;

View File

@ -47,7 +47,7 @@ WaveProperties::~WaveProperties(void)
{
}
bool WaveProperties::detect(const QString &sourceFile, AudioFileModel_TechInfo *info, volatile bool *abortFlag)
bool WaveProperties::detect(const QString &sourceFile, AudioFileModel_TechInfo *info, QAtomicInt &abortFlag)
{
QProcess process;
QStringList args;
@ -72,7 +72,7 @@ bool WaveProperties::detect(const QString &sourceFile, AudioFileModel_TechInfo *
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
if(checkFlag(abortFlag))
{
process.kill();
bAborted = true;

View File

@ -33,7 +33,7 @@ public:
WaveProperties(void);
~WaveProperties(void);
bool detect(const QString &sourceFile, AudioFileModel_TechInfo *info, volatile bool *abortFlag);
bool detect(const QString &sourceFile, AudioFileModel_TechInfo *info, QAtomicInt &abortFlag);
private:
const QString m_binary;