diff --git a/src/Config.h b/src/Config.h index bf92a5e0..c23a69e9 100644 --- a/src/Config.h +++ b/src/Config.h @@ -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 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Decoder_AAC.cpp b/src/Decoder_AAC.cpp index ae5412dc..bb55e999 100644 --- a/src/Decoder_AAC.cpp +++ b/src/Decoder_AAC.cpp @@ -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; diff --git a/src/Decoder_AAC.h b/src/Decoder_AAC.h index c2de0d9a..8b342036 100644 --- a/src/Decoder_AAC.h +++ b/src/Decoder_AAC.h @@ -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); diff --git a/src/Decoder_AC3.cpp b/src/Decoder_AC3.cpp index c3093de8..26eee171 100644 --- a/src/Decoder_AC3.cpp +++ b/src/Decoder_AC3.cpp @@ -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; diff --git a/src/Decoder_AC3.h b/src/Decoder_AC3.h index 9f7a0900..8eb856bc 100644 --- a/src/Decoder_AC3.h +++ b/src/Decoder_AC3.h @@ -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); diff --git a/src/Decoder_ADPCM.cpp b/src/Decoder_ADPCM.cpp index 8189630b..a7d42d01 100644 --- a/src/Decoder_ADPCM.cpp +++ b/src/Decoder_ADPCM.cpp @@ -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; diff --git a/src/Decoder_ADPCM.h b/src/Decoder_ADPCM.h index 05049e65..92c27bc6 100644 --- a/src/Decoder_ADPCM.h +++ b/src/Decoder_ADPCM.h @@ -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); diff --git a/src/Decoder_ALAC.cpp b/src/Decoder_ALAC.cpp index 90d6355b..14ecff8a 100644 --- a/src/Decoder_ALAC.cpp +++ b/src/Decoder_ALAC.cpp @@ -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; diff --git a/src/Decoder_ALAC.h b/src/Decoder_ALAC.h index 4ed857a9..3ce22afa 100644 --- a/src/Decoder_ALAC.h +++ b/src/Decoder_ALAC.h @@ -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); diff --git a/src/Decoder_Abstract.h b/src/Decoder_Abstract.h index 827cff9d..d1e45560 100644 --- a/src/Decoder_Abstract.h +++ b/src/Decoder_Abstract.h @@ -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); diff --git a/src/Decoder_Avisynth.cpp b/src/Decoder_Avisynth.cpp index 73d3c7d3..bac63bac 100644 --- a/src/Decoder_Avisynth.cpp +++ b/src/Decoder_Avisynth.cpp @@ -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; diff --git a/src/Decoder_Avisynth.h b/src/Decoder_Avisynth.h index ee98ab03..c3987973 100644 --- a/src/Decoder_Avisynth.h +++ b/src/Decoder_Avisynth.h @@ -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); diff --git a/src/Decoder_FLAC.cpp b/src/Decoder_FLAC.cpp index 6c870822..bf6022eb 100644 --- a/src/Decoder_FLAC.cpp +++ b/src/Decoder_FLAC.cpp @@ -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; diff --git a/src/Decoder_FLAC.h b/src/Decoder_FLAC.h index 87e80370..029847b3 100644 --- a/src/Decoder_FLAC.h +++ b/src/Decoder_FLAC.h @@ -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); diff --git a/src/Decoder_MAC.cpp b/src/Decoder_MAC.cpp index b8cf9859..d7ad04b5 100644 --- a/src/Decoder_MAC.cpp +++ b/src/Decoder_MAC.cpp @@ -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; diff --git a/src/Decoder_MAC.h b/src/Decoder_MAC.h index 5a2af66d..4af2c44d 100644 --- a/src/Decoder_MAC.h +++ b/src/Decoder_MAC.h @@ -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); diff --git a/src/Decoder_MP3.cpp b/src/Decoder_MP3.cpp index 30e19635..4be6d42b 100644 --- a/src/Decoder_MP3.cpp +++ b/src/Decoder_MP3.cpp @@ -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; diff --git a/src/Decoder_MP3.h b/src/Decoder_MP3.h index a94f47f9..3ac0b8fd 100644 --- a/src/Decoder_MP3.h +++ b/src/Decoder_MP3.h @@ -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); diff --git a/src/Decoder_Musepack.cpp b/src/Decoder_Musepack.cpp index 31d85d48..3ea31263 100644 --- a/src/Decoder_Musepack.cpp +++ b/src/Decoder_Musepack.cpp @@ -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; diff --git a/src/Decoder_Musepack.h b/src/Decoder_Musepack.h index 9a3b2219..4592f202 100644 --- a/src/Decoder_Musepack.h +++ b/src/Decoder_Musepack.h @@ -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); diff --git a/src/Decoder_Opus.cpp b/src/Decoder_Opus.cpp index f2c27041..3fe50345 100644 --- a/src/Decoder_Opus.cpp +++ b/src/Decoder_Opus.cpp @@ -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; diff --git a/src/Decoder_Opus.h b/src/Decoder_Opus.h index 1f03997b..ffa4a93d 100644 --- a/src/Decoder_Opus.h +++ b/src/Decoder_Opus.h @@ -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); diff --git a/src/Decoder_Shorten.cpp b/src/Decoder_Shorten.cpp index 30439098..c7f616e4 100644 --- a/src/Decoder_Shorten.cpp +++ b/src/Decoder_Shorten.cpp @@ -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; diff --git a/src/Decoder_Shorten.h b/src/Decoder_Shorten.h index cd6cb313..88360c62 100644 --- a/src/Decoder_Shorten.h +++ b/src/Decoder_Shorten.h @@ -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); diff --git a/src/Decoder_Speex.cpp b/src/Decoder_Speex.cpp index f4c7c814..f19248d2 100644 --- a/src/Decoder_Speex.cpp +++ b/src/Decoder_Speex.cpp @@ -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; diff --git a/src/Decoder_Speex.h b/src/Decoder_Speex.h index 7aae83f4..221462a5 100644 --- a/src/Decoder_Speex.h +++ b/src/Decoder_Speex.h @@ -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); diff --git a/src/Decoder_TTA.cpp b/src/Decoder_TTA.cpp index b8d5c366..55c4f091 100644 --- a/src/Decoder_TTA.cpp +++ b/src/Decoder_TTA.cpp @@ -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; diff --git a/src/Decoder_TTA.h b/src/Decoder_TTA.h index b2306a4a..e77e2cb5 100644 --- a/src/Decoder_TTA.h +++ b/src/Decoder_TTA.h @@ -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); diff --git a/src/Decoder_Vorbis.cpp b/src/Decoder_Vorbis.cpp index bf09783b..85a4e2e3 100644 --- a/src/Decoder_Vorbis.cpp +++ b/src/Decoder_Vorbis.cpp @@ -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; diff --git a/src/Decoder_Vorbis.h b/src/Decoder_Vorbis.h index 50599bc7..843ae48d 100644 --- a/src/Decoder_Vorbis.h +++ b/src/Decoder_Vorbis.h @@ -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); diff --git a/src/Decoder_WMA.cpp b/src/Decoder_WMA.cpp index 8e3fdef8..1551b33f 100644 --- a/src/Decoder_WMA.cpp +++ b/src/Decoder_WMA.cpp @@ -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; diff --git a/src/Decoder_WMA.h b/src/Decoder_WMA.h index 7f44b277..403ff945 100644 --- a/src/Decoder_WMA.h +++ b/src/Decoder_WMA.h @@ -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); diff --git a/src/Decoder_WavPack.cpp b/src/Decoder_WavPack.cpp index d43774be..25639f71 100644 --- a/src/Decoder_WavPack.cpp +++ b/src/Decoder_WavPack.cpp @@ -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; diff --git a/src/Decoder_WavPack.h b/src/Decoder_WavPack.h index 1f9c734d..7bd7b801 100644 --- a/src/Decoder_WavPack.h +++ b/src/Decoder_WavPack.h @@ -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); diff --git a/src/Decoder_Wave.cpp b/src/Decoder_Wave.cpp index 639b2905..1ee2b591 100644 --- a/src/Decoder_Wave.cpp +++ b/src/Decoder_Wave.cpp @@ -31,12 +31,12 @@ #include //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(userData)) { - //qWarning("Copy progress: %.2f", progress); - reinterpret_cast(data)->instance->updateProgress(progress); - return (!(*reinterpret_cast(data)->abrtFlag)); + ptr->pInstance->updateProgress(progress); + return ptr->abortFlag->operator!(); } return true; } diff --git a/src/Decoder_Wave.h b/src/Decoder_Wave.h index 48a9fb05..7eeb328d 100644 --- a/src/Decoder_Wave.h +++ b/src/Decoder_Wave.h @@ -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); diff --git a/src/Encoder_AAC.cpp b/src/Encoder_AAC.cpp index d0d4d67d..91919f57 100644 --- a/src/Encoder_AAC.cpp +++ b/src/Encoder_AAC.cpp @@ -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; diff --git a/src/Encoder_AAC.h b/src/Encoder_AAC.h index 097a95b8..cbd8c7ec 100644 --- a/src/Encoder_AAC.h +++ b/src/Encoder_AAC.h @@ -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); diff --git a/src/Encoder_AAC_FDK.cpp b/src/Encoder_AAC_FDK.cpp index c3f9fbdf..07b29b95 100644 --- a/src/Encoder_AAC_FDK.cpp +++ b/src/Encoder_AAC_FDK.cpp @@ -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; diff --git a/src/Encoder_AAC_FDK.h b/src/Encoder_AAC_FDK.h index 0c2ab6be..a6b01a49 100644 --- a/src/Encoder_AAC_FDK.h +++ b/src/Encoder_AAC_FDK.h @@ -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 diff --git a/src/Encoder_AAC_FHG.cpp b/src/Encoder_AAC_FHG.cpp index d2e47208..1c0e2528 100644 --- a/src/Encoder_AAC_FHG.cpp +++ b/src/Encoder_AAC_FHG.cpp @@ -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; diff --git a/src/Encoder_AAC_FHG.h b/src/Encoder_AAC_FHG.h index b54deb71..f59128d3 100644 --- a/src/Encoder_AAC_FHG.h +++ b/src/Encoder_AAC_FHG.h @@ -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); diff --git a/src/Encoder_AAC_QAAC.cpp b/src/Encoder_AAC_QAAC.cpp index 8c0a7493..ef7a70d5 100644 --- a/src/Encoder_AAC_QAAC.cpp +++ b/src/Encoder_AAC_QAAC.cpp @@ -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; diff --git a/src/Encoder_AAC_QAAC.h b/src/Encoder_AAC_QAAC.h index f585b1b4..095d8ed3 100644 --- a/src/Encoder_AAC_QAAC.h +++ b/src/Encoder_AAC_QAAC.h @@ -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 diff --git a/src/Encoder_AC3.cpp b/src/Encoder_AC3.cpp index da16e1fd..b9348a44 100644 --- a/src/Encoder_AC3.cpp +++ b/src/Encoder_AC3.cpp @@ -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; diff --git a/src/Encoder_AC3.h b/src/Encoder_AC3.h index 0d0e03f7..640f334a 100644 --- a/src/Encoder_AC3.h +++ b/src/Encoder_AC3.h @@ -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); diff --git a/src/Encoder_Abstract.h b/src/Encoder_Abstract.h index e2058836..604c0b6b 100644 --- a/src/Encoder_Abstract.h +++ b/src/Encoder_Abstract.h @@ -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); diff --git a/src/Encoder_DCA.cpp b/src/Encoder_DCA.cpp index 1dc3fc8f..218d9551 100644 --- a/src/Encoder_DCA.cpp +++ b/src/Encoder_DCA.cpp @@ -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; diff --git a/src/Encoder_DCA.h b/src/Encoder_DCA.h index 2a2533df..8658fd81 100644 --- a/src/Encoder_DCA.h +++ b/src/Encoder_DCA.h @@ -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); diff --git a/src/Encoder_FLAC.cpp b/src/Encoder_FLAC.cpp index a14d40e4..94f2b9cc 100644 --- a/src/Encoder_FLAC.cpp +++ b/src/Encoder_FLAC.cpp @@ -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; diff --git a/src/Encoder_FLAC.h b/src/Encoder_FLAC.h index b3cfcece..5c53be5b 100644 --- a/src/Encoder_FLAC.h +++ b/src/Encoder_FLAC.h @@ -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); diff --git a/src/Encoder_MAC.cpp b/src/Encoder_MAC.cpp index 593b2f20..2df14854 100644 --- a/src/Encoder_MAC.cpp +++ b/src/Encoder_MAC.cpp @@ -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; diff --git a/src/Encoder_MAC.h b/src/Encoder_MAC.h index ef8f6a7b..251c41c4 100644 --- a/src/Encoder_MAC.h +++ b/src/Encoder_MAC.h @@ -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 diff --git a/src/Encoder_MP3.cpp b/src/Encoder_MP3.cpp index 5d4a6996..5884a037 100644 --- a/src/Encoder_MP3.cpp +++ b/src/Encoder_MP3.cpp @@ -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; diff --git a/src/Encoder_MP3.h b/src/Encoder_MP3.h index f99ce172..461fe20a 100644 --- a/src/Encoder_MP3.h +++ b/src/Encoder_MP3.h @@ -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); diff --git a/src/Encoder_Opus.cpp b/src/Encoder_Opus.cpp index 18c8617b..9b6ac922 100644 --- a/src/Encoder_Opus.cpp +++ b/src/Encoder_Opus.cpp @@ -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; diff --git a/src/Encoder_Opus.h b/src/Encoder_Opus.h index f4cf4358..4024253c 100644 --- a/src/Encoder_Opus.h +++ b/src/Encoder_Opus.h @@ -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); diff --git a/src/Encoder_Vorbis.cpp b/src/Encoder_Vorbis.cpp index 6ce8323e..058f33ae 100644 --- a/src/Encoder_Vorbis.cpp +++ b/src/Encoder_Vorbis.cpp @@ -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; diff --git a/src/Encoder_Vorbis.h b/src/Encoder_Vorbis.h index 1d0db80b..e1eb24b4 100644 --- a/src/Encoder_Vorbis.h +++ b/src/Encoder_Vorbis.h @@ -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); diff --git a/src/Encoder_Wave.cpp b/src/Encoder_Wave.cpp index 8d729421..5e87a677 100644 --- a/src/Encoder_Wave.cpp +++ b/src/Encoder_Wave.cpp @@ -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(userData); - if (*(ptr->abortFlag)) + if (const callback_t *const ptr = reinterpret_cast(userData)) { - return false; /*user aborted*/ + ptr->pInstance->updateProgress(progress); + return ptr->abortFlag->operator!(); } - ptr->pInstance->updateProgress(progress); return true; } diff --git a/src/Encoder_Wave.h b/src/Encoder_Wave.h index 976d34d7..ff666589 100644 --- a/src/Encoder_Wave.h +++ b/src/Encoder_Wave.h @@ -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 diff --git a/src/Filter_Abstract.h b/src/Filter_Abstract.h index 6ced3c96..1772a7da 100644 --- a/src/Filter_Abstract.h +++ b/src/Filter_Abstract.h @@ -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; }; diff --git a/src/Filter_Downmix.cpp b/src/Filter_Downmix.cpp index 5894d4b1..7b6958da 100644 --- a/src/Filter_Downmix.cpp +++ b/src/Filter_Downmix.cpp @@ -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; diff --git a/src/Filter_Downmix.h b/src/Filter_Downmix.h index 74a0d9bc..0be51d29 100644 --- a/src/Filter_Downmix.h +++ b/src/Filter_Downmix.h @@ -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; diff --git a/src/Filter_Normalize.cpp b/src/Filter_Normalize.cpp index 3c3e62c5..e385e061 100644 --- a/src/Filter_Normalize.cpp +++ b/src/Filter_Normalize.cpp @@ -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; diff --git a/src/Filter_Normalize.h b/src/Filter_Normalize.h index 58df6428..172482d3 100644 --- a/src/Filter_Normalize.h +++ b/src/Filter_Normalize.h @@ -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; diff --git a/src/Filter_Resample.cpp b/src/Filter_Resample.cpp index b8535026..f692fb45 100644 --- a/src/Filter_Resample.cpp +++ b/src/Filter_Resample.cpp @@ -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; diff --git a/src/Filter_Resample.h b/src/Filter_Resample.h index 0159d036..9fbb3dfc 100644 --- a/src/Filter_Resample.h +++ b/src/Filter_Resample.h @@ -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; diff --git a/src/Filter_ToneAdjust.cpp b/src/Filter_ToneAdjust.cpp index 750a7c73..bdcd0e29 100644 --- a/src/Filter_ToneAdjust.cpp +++ b/src/Filter_ToneAdjust.cpp @@ -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; diff --git a/src/Filter_ToneAdjust.h b/src/Filter_ToneAdjust.h index 57ccaeb3..c9f55b2e 100644 --- a/src/Filter_ToneAdjust.h +++ b/src/Filter_ToneAdjust.h @@ -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; diff --git a/src/Thread_CueSplitter.cpp b/src/Thread_CueSplitter.cpp index 3aebeedb..8c3cf9f7 100644 --- a/src/Thread_CueSplitter.cpp +++ b/src/Thread_CueSplitter.cpp @@ -47,6 +47,9 @@ #include #include +//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!"); diff --git a/src/Thread_CueSplitter.h b/src/Thread_CueSplitter.h index d6fd6e75..24237993 100644 --- a/src/Thread_CueSplitter.h +++ b/src/Thread_CueSplitter.h @@ -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 m_inputFilesInfo; diff --git a/src/Thread_FileAnalyzer.cpp b/src/Thread_FileAnalyzer.cpp index 9ac8940e..97a4e8e0 100644 --- a/src/Thread_FileAnalyzer.cpp +++ b/src/Thread_FileAnalyzer.cpp @@ -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); diff --git a/src/Thread_FileAnalyzer.h b/src/Thread_FileAnalyzer.h index 4bc3ee39..652a0cfc 100644 --- a/src/Thread_FileAnalyzer.h +++ b/src/Thread_FileAnalyzer.h @@ -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; }; diff --git a/src/Thread_FileAnalyzer_Task.cpp b/src/Thread_FileAnalyzer_Task.cpp index 6e8d7920..82b39975 100644 --- a/src/Thread_FileAnalyzer_Task.cpp +++ b/src/Thread_FileAnalyzer_Task.cpp @@ -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!"); diff --git a/src/Thread_FileAnalyzer_Task.h b/src/Thread_FileAnalyzer_Task.h index d41717a8..ef47a156 100644 --- a/src/Thread_FileAnalyzer_Task.h +++ b/src/Thread_FileAnalyzer_Task.h @@ -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; }; diff --git a/src/Thread_Process.cpp b/src/Thread_Process.cpp index e315094e..10e2b57d 100644 --- a/src/Thread_Process.cpp +++ b/src/Thread_Process.cpp @@ -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); @@ -132,16 +130,15 @@ bool ProcessThread::init(void) bool ProcessThread::start(QThreadPool *const pool) { //Make sure object was initialized correctly - if(m_initialized < 0) + if (m_initialized < 0) { 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."); diff --git a/src/Thread_Process.h b/src/Thread_Process.h index 4dc359b1..7a6dae6e 100644 --- a/src/Thread_Process.h +++ b/src/Thread_Process.h @@ -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; diff --git a/src/Tool_Abstract.h b/src/Tool_Abstract.h index 3ffe9894..da6dab27 100644 --- a/src/Tool_Abstract.h +++ b/src/Tool_Abstract.h @@ -50,6 +50,11 @@ signals: protected: static const int m_processTimeoutInterval = 600000; + + static __forceinline bool checkFlag(QAtomicInt &flag) + { + return (!(!flag)); + } private: static QScopedPointer s_jobObjectInstance; diff --git a/src/Tool_WaveProperties.cpp b/src/Tool_WaveProperties.cpp index 8f585e64..9a5f46c5 100644 --- a/src/Tool_WaveProperties.cpp +++ b/src/Tool_WaveProperties.cpp @@ -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; diff --git a/src/Tool_WaveProperties.h b/src/Tool_WaveProperties.h index 0d3734e6..44b06aa6 100644 --- a/src/Tool_WaveProperties.h +++ b/src/Tool_WaveProperties.h @@ -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;