OSDN Git Service

Small tweak to progress updates.
authorLoRd_MuldeR <mulder2@gmx.de>
Sun, 10 Dec 2017 21:21:42 +0000 (22:21 +0100)
committerLoRd_MuldeR <mulder2@gmx.de>
Sun, 10 Dec 2017 21:21:42 +0000 (22:21 +0100)
26 files changed:
src/Decoder_AAC.cpp
src/Decoder_AC3.cpp
src/Decoder_ADPCM.cpp
src/Decoder_ALAC.cpp
src/Decoder_Avisynth.cpp
src/Decoder_FLAC.cpp
src/Decoder_MAC.cpp
src/Decoder_MP3.cpp
src/Decoder_Musepack.cpp
src/Decoder_Opus.cpp
src/Decoder_Shorten.cpp
src/Decoder_TTA.cpp
src/Decoder_Vorbis.cpp
src/Decoder_WMA.cpp
src/Decoder_WavPack.cpp
src/Encoder_AAC.cpp
src/Encoder_AAC_FDK.cpp
src/Encoder_AAC_FHG.cpp
src/Encoder_AAC_QAAC.cpp
src/Encoder_AC3.cpp
src/Encoder_DCA.cpp
src/Encoder_FLAC.cpp
src/Encoder_MAC.cpp
src/Encoder_MP3.cpp
src/Encoder_Opus.cpp
src/Encoder_Vorbis.cpp

index 6a65395..0daa84d 100644 (file)
@@ -73,7 +73,7 @@ bool AACDecoder::decode(const QString &sourceFile, const QString &outputFile, QA
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 51bffa5..03a17de 100644 (file)
@@ -67,15 +67,13 @@ bool AC3Decoder::decode(const QString &sourceFile, const QString &outputFile, QA
        {
                if (regExp.lastIndexIn(text) >= 0)
                {
-                       qWarning("Found! [\"%s\"]", MUTILS_UTF8(regExp.cap(1)));
                        qint32 newProgress;
                        if (MUtils::regexp_parse_int32(regExp, newProgress))
                        {
-                               qWarning("newProgress: %d", newProgress);
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index a1487fc..fada591 100644 (file)
@@ -75,7 +75,7 @@ bool ADPCMDecoder::decode(const QString &sourceFile, const QString &outputFile,
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 19523d2..093698f 100644 (file)
@@ -76,7 +76,7 @@ bool ALACDecoder::decode(const QString &sourceFile, const QString &outputFile, Q
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index ee119cc..05c7b34 100644 (file)
@@ -74,7 +74,7 @@ bool AvisynthDecoder::decode(const QString &sourceFile, const QString &outputFil
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index a426a20..bae418c 100644 (file)
@@ -74,7 +74,7 @@ bool FLACDecoder::decode(const QString &sourceFile, const QString &outputFile, Q
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 02135ec..9d81d22 100644 (file)
@@ -74,7 +74,7 @@ bool MACDecoder::decode(const QString &sourceFile, const QString &outputFile, QA
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 220a1cd..13d0387 100644 (file)
@@ -83,7 +83,7 @@ bool MP3Decoder::decode(const QString &sourceFile, const QString &outputFile, QA
                                        if (newProgress > prevProgress)
                                        {
                                                emit statusUpdated(newProgress);
-                                               prevProgress = qMin(newProgress + 2, 99);
+                                               prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                        }
                                }
                        }
index c11ee97..f994ef8 100644 (file)
@@ -75,7 +75,7 @@ bool MusepackDecoder::decode(const QString &sourceFile, const QString &outputFil
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 73a9e9e..4256ae1 100644 (file)
@@ -81,7 +81,7 @@ bool OpusDecoder::decode(const QString &sourceFile, const QString &outputFile, Q
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index c7f616e..65cc747 100644 (file)
@@ -62,57 +62,10 @@ bool ShortenDecoder::decode(const QString &sourceFile, const QString &outputFile
                return false;
        }
 
-       bool bTimeout = false;
-       bool bAborted = false;
-
        //The Shorten Decoder doesn't actually send any status updates :-[
        emit statusUpdated(20 + (QUuid::createUuid().data1 % 80));
 
-       while(process.state() != QProcess::NotRunning)
-       {
-               if(checkFlag(abortFlag))
-               {
-                       process.kill();
-                       bAborted = true;
-                       emit messageLogged("\nABORTED BY USER !!!");
-                       break;
-               }
-               process.waitForReadyRead(m_processTimeoutInterval);
-               if(!process.bytesAvailable() && process.state() == QProcess::Running)
-               {
-                       process.kill();
-                       qWarning("Shorten process timed out <-- killing!");
-                       emit messageLogged("\nPROCESS TIMEOUT !!!");
-                       bTimeout = true;
-                       break;
-               }
-               while(process.bytesAvailable() > 0)
-               {
-                       QByteArray line = process.readLine();
-                       QString text = QString::fromUtf8(line.constData()).simplified();
-                       if(!text.isEmpty())
-                       {
-                               emit messageLogged(text);
-                       }
-               }
-       }
-
-       process.waitForFinished();
-       if(process.state() != QProcess::NotRunning)
-       {
-               process.kill();
-               process.waitForFinished(-1);
-       }
-       
-       emit statusUpdated(100);
-       emit messageLogged(QString().sprintf("\nExited with code: 0x%04X", process.exitCode()));
-
-       if(bTimeout || bAborted || process.exitCode() != EXIT_SUCCESS || QFileInfo(outputFile).size() == 0)
-       {
-               return false;
-       }
-       
-       return true;
+       return (awaitProcess(process, abortFlag) == RESULT_SUCCESS);
 }
 
 bool ShortenDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
index 8e4d318..df6102d 100644 (file)
@@ -75,7 +75,7 @@ bool TTADecoder::decode(const QString &sourceFile, const QString &outputFile, QA
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 78ea56d..bd2588e 100644 (file)
@@ -73,7 +73,7 @@ bool VorbisDecoder::decode(const QString &sourceFile, const QString &outputFile,
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index aae6ef8..948c9ed 100644 (file)
@@ -75,7 +75,7 @@ bool WMADecoder::decode(const QString &sourceFile, const QString &outputFile, QA
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 81173a8..e07f75b 100644 (file)
@@ -74,7 +74,7 @@ bool WavPackDecoder::decode(const QString &sourceFile, const QString &outputFile
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 37ed646..a9386cd 100644 (file)
@@ -210,7 +210,7 @@ bool AACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
 
        int prevProgress = -1;
        QRegExp regExp_sp(L1S("\\bprocessed\\s+(\\d+)\\s+seconds"), Qt::CaseInsensitive);
-       QRegExp regExp_mp(L1S("(\\w+)\\s+pass:\\s+processed\\s+(\\d+)\\s+seconds"), Qt::CaseInsensitive);
+       QRegExp regExp_mp(L1S("\\b(\\w+)\\s+pass:\\s+processed\\s+(\\d+)\\s+seconds"), Qt::CaseInsensitive);
 
        const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, &duration, &regExp_sp, &regExp_mp](const QString &text)
        {
@@ -220,11 +220,11 @@ bool AACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
                        if ((duration > 0) && MUtils::regexp_parse_int32(regExp_mp, timeElapsed, 2))
                        {
                                const bool second_pass = (regExp_mp.cap(1).compare(L1S("second"), Qt::CaseInsensitive) == 0);
-                               int newProgress = qRound((second_pass ? 50.0 : 0.0) + ((static_cast<double>(timeElapsed) / static_cast<double>(duration)) * 50.0));
+                               const int newProgress = qRound((second_pass ? 50.0 : 0.0) + ((static_cast<double>(timeElapsed) / static_cast<double>(duration)) * 50.0));
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
@@ -234,11 +234,11 @@ bool AACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
                        int timeElapsed;
                        if ((duration > 0) && MUtils::regexp_parse_int32(regExp_sp, timeElapsed))
                        {
-                               int newProgress = qRound((static_cast<double>(timeElapsed) / static_cast<double>(duration)) * 100.0);
+                               const int newProgress = qRound((static_cast<double>(timeElapsed) / static_cast<double>(duration)) * 100.0);
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 2140874..59d2b85 100644 (file)
@@ -214,7 +214,7 @@ bool FDKAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 7f80ea7..de62a09 100644 (file)
@@ -209,7 +209,7 @@ bool FHGAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 4e291b9..e0e6e57 100644 (file)
@@ -235,7 +235,7 @@ bool QAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 1703aa5..d78cad0 100644 (file)
@@ -202,7 +202,7 @@ bool AC3Encoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 08c5a22..0c101f0 100644 (file)
@@ -168,7 +168,7 @@ bool DCAEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index eeb034e..ba3ceb3 100644 (file)
@@ -177,7 +177,7 @@ bool FLACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 33bd88c..3dd0cc1 100644 (file)
@@ -174,7 +174,7 @@ bool MACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 68e120c..6f75f87 100644 (file)
@@ -250,7 +250,7 @@ bool MP3Encoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 3f3d143..a14000f 100644 (file)
@@ -219,7 +219,7 @@ bool OpusEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;
index 5170ae2..96c6ef6 100644 (file)
@@ -209,7 +209,7 @@ bool VorbisEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
                                if (newProgress > prevProgress)
                                {
                                        emit statusUpdated(newProgress);
-                                       prevProgress = qMin(newProgress + 2, 99);
+                                       prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
                                }
                        }
                        return true;