Small tweak to progress updates.

This commit is contained in:
LoRd_MuldeR 2017-12-10 22:21:42 +01:00
parent 2a238280a8
commit c47a13a494
26 changed files with 30 additions and 79 deletions

View File

@ -73,7 +73,7 @@ bool AACDecoder::decode(const QString &sourceFile, const QString &outputFile, QA
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -67,15 +67,13 @@ bool AC3Decoder::decode(const QString &sourceFile, const QString &outputFile, QA
{ {
if (regExp.lastIndexIn(text) >= 0) if (regExp.lastIndexIn(text) >= 0)
{ {
qWarning("Found! [\"%s\"]", MUTILS_UTF8(regExp.cap(1)));
qint32 newProgress; qint32 newProgress;
if (MUtils::regexp_parse_int32(regExp, newProgress)) if (MUtils::regexp_parse_int32(regExp, newProgress))
{ {
qWarning("newProgress: %d", newProgress);
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -75,7 +75,7 @@ bool ADPCMDecoder::decode(const QString &sourceFile, const QString &outputFile,
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -76,7 +76,7 @@ bool ALACDecoder::decode(const QString &sourceFile, const QString &outputFile, Q
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -74,7 +74,7 @@ bool AvisynthDecoder::decode(const QString &sourceFile, const QString &outputFil
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -74,7 +74,7 @@ bool FLACDecoder::decode(const QString &sourceFile, const QString &outputFile, Q
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -74,7 +74,7 @@ bool MACDecoder::decode(const QString &sourceFile, const QString &outputFile, QA
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -83,7 +83,7 @@ bool MP3Decoder::decode(const QString &sourceFile, const QString &outputFile, QA
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
} }

View File

@ -75,7 +75,7 @@ bool MusepackDecoder::decode(const QString &sourceFile, const QString &outputFil
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -81,7 +81,7 @@ bool OpusDecoder::decode(const QString &sourceFile, const QString &outputFile, Q
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -62,57 +62,10 @@ bool ShortenDecoder::decode(const QString &sourceFile, const QString &outputFile
return false; return false;
} }
bool bTimeout = false;
bool bAborted = false;
//The Shorten Decoder doesn't actually send any status updates :-[ //The Shorten Decoder doesn't actually send any status updates :-[
emit statusUpdated(20 + (QUuid::createUuid().data1 % 80)); emit statusUpdated(20 + (QUuid::createUuid().data1 % 80));
while(process.state() != QProcess::NotRunning) return (awaitProcess(process, abortFlag) == RESULT_SUCCESS);
{
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;
} }
bool ShortenDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion) bool ShortenDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)

View File

@ -75,7 +75,7 @@ bool TTADecoder::decode(const QString &sourceFile, const QString &outputFile, QA
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -73,7 +73,7 @@ bool VorbisDecoder::decode(const QString &sourceFile, const QString &outputFile,
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -75,7 +75,7 @@ bool WMADecoder::decode(const QString &sourceFile, const QString &outputFile, QA
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -74,7 +74,7 @@ bool WavPackDecoder::decode(const QString &sourceFile, const QString &outputFile
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -210,7 +210,7 @@ bool AACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
int prevProgress = -1; int prevProgress = -1;
QRegExp regExp_sp(L1S("\\bprocessed\\s+(\\d+)\\s+seconds"), Qt::CaseInsensitive); 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) 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)) 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); 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) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;
@ -234,11 +234,11 @@ bool AACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
int timeElapsed; int timeElapsed;
if ((duration > 0) && MUtils::regexp_parse_int32(regExp_sp, 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) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -214,7 +214,7 @@ bool FDKAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -209,7 +209,7 @@ bool FHGAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -235,7 +235,7 @@ bool QAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -202,7 +202,7 @@ bool AC3Encoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -168,7 +168,7 @@ bool DCAEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -177,7 +177,7 @@ bool FLACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -174,7 +174,7 @@ bool MACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -250,7 +250,7 @@ bool MP3Encoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -219,7 +219,7 @@ bool OpusEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;

View File

@ -209,7 +209,7 @@ bool VorbisEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
if (newProgress > prevProgress) if (newProgress > prevProgress)
{ {
emit statusUpdated(newProgress); emit statusUpdated(newProgress);
prevProgress = qMin(newProgress + 2, 99); prevProgress = (newProgress < 99) ? (newProgress + 1) : newProgress;
} }
} }
return true; return true;