Refactored all encoder classes to use awaitProcess() from Tool_Abstract base class.
This commit is contained in:
parent
7288244a27
commit
2a238280a8
@ -35,7 +35,7 @@
|
||||
#define VER_LAMEXP_MINOR_LO 6
|
||||
#define VER_LAMEXP_TYPE Beta
|
||||
#define VER_LAMEXP_PATCH 1
|
||||
#define VER_LAMEXP_BUILD 2068
|
||||
#define VER_LAMEXP_BUILD 2071
|
||||
#define VER_LAMEXP_CONFG 2002
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -70,7 +70,7 @@ bool WMADecoder::decode(const QString &sourceFile, const QString &outputFile, QA
|
||||
if (regExp.lastIndexIn(text) >= 0)
|
||||
{
|
||||
qint32 newProgress;
|
||||
if (MUtils::regexp_parse_int32(regExp, newProgress, 2U))
|
||||
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||
{
|
||||
if (newProgress > prevProgress)
|
||||
{
|
||||
|
@ -1594,7 +1594,7 @@ void MainWindow::windowShown(void)
|
||||
messageText += NOBR(tr("LameXP detected that your version of the Nero AAC encoder is outdated!")).append("<br>");
|
||||
messageText += NOBR(tr("The current version available is %1 (or later), but you still have version %2 installed.").arg(lamexp_version2string("?.?.?.?", lamexp_toolver_neroaac(), tr("n/a")), lamexp_version2string("?.?.?.?", lamexp_tools_version("neroAacEnc.exe"), tr("n/a")))).append("<br><br>");
|
||||
messageText += NOBR(tr("You can download the latest version of the Nero AAC encoder from the Nero website at:")).append("<br>");
|
||||
messageText += "<nobr><tt>" + LINK(AboutDialog::neroAacUrl) + "</tt></nobr><br><br>";
|
||||
messageText += QString("<nobr><tt>").append(LINK(AboutDialog::neroAacUrl)).append("</tt></nobr><br><br>");
|
||||
messageText += NOBR(tr("(Hint: Please ignore the name of the downloaded ZIP file and check the included 'changelog.txt' instead!)")).append("<br>");
|
||||
QMessageBox::information(this, tr("AAC Encoder Outdated"), messageText);
|
||||
}
|
||||
@ -1609,10 +1609,10 @@ void MainWindow::windowShown(void)
|
||||
QString messageText;
|
||||
messageText += NOBR(tr("The Nero AAC encoder could not be found. AAC encoding support will be disabled.")).append("<br>");
|
||||
messageText += NOBR(tr("Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory!")).append("<br><br>");
|
||||
messageText += NOBR(tr("Your LameXP directory is located here:")).append("<br>");
|
||||
messageText += QString("<b>").append(NOBR(tr("Your LameXP install directory is located here:"))).append("</b><br>");
|
||||
messageText += QString("<nobr><tt>%1</tt></nobr><br><br>").arg(FSLINK(QDir::toNativeSeparators(appPath)));
|
||||
messageText += NOBR(tr("You can download the Nero AAC encoder for free from the official Nero website at:")).append("<br>");
|
||||
messageText += "<nobr><tt>" + LINK(AboutDialog::neroAacUrl) + "</tt></nobr><br>";
|
||||
messageText += QString("<b>").append(NOBR(tr("You can download the Nero AAC encoder for free from this website:"))).append("</b><br>");
|
||||
messageText += QString("<nobr><tt>").append(LINK(AboutDialog::neroAacUrl)).append("</tt></nobr><br>");
|
||||
if(QMessageBox::information(this, tr("AAC Support Disabled"), messageText, tr("Discard"), tr("Don't Show Again")) == 1)
|
||||
{
|
||||
m_settings->neroAacNotificationsEnabled(false);
|
||||
|
@ -208,97 +208,45 @@ bool AACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bTimeout = false;
|
||||
bool bAborted = false;
|
||||
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(L1S("Processed\\s+(\\d+)\\s+seconds"));
|
||||
QRegExp regExp_pass1(L1S("First\\s+pass:\\s+processed\\s+(\\d+)\\s+seconds"));
|
||||
QRegExp regExp_pass2(L1S("Second\\s+pass:\\s+processed\\s+(\\d+)\\s+seconds"));
|
||||
|
||||
while(process.state() != QProcess::NotRunning)
|
||||
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, &duration, ®Exp_sp, ®Exp_mp](const QString &text)
|
||||
{
|
||||
if(checkFlag(abortFlag))
|
||||
if (regExp_mp.lastIndexIn(text) >= 0)
|
||||
{
|
||||
process.kill();
|
||||
bAborted = true;
|
||||
emit messageLogged(L1S("\nABORTED BY USER !!!"));
|
||||
break;
|
||||
}
|
||||
process.waitForReadyRead(m_processTimeoutInterval);
|
||||
if(!process.bytesAvailable() && process.state() == QProcess::Running)
|
||||
{
|
||||
process.kill();
|
||||
qWarning("NeroAacEnc process timed out <-- killing!");
|
||||
emit messageLogged(L1S("\nPROCESS TIMEOUT !!!"));
|
||||
bTimeout = true;
|
||||
break;
|
||||
}
|
||||
while(process.bytesAvailable() > 0)
|
||||
{
|
||||
QByteArray line = process.readLine();
|
||||
QString text = QString::fromUtf8(line.constData()).simplified();
|
||||
if(regExp_pass1.lastIndexIn(text) >= 0)
|
||||
int timeElapsed;
|
||||
if ((duration > 0) && MUtils::regexp_parse_int32(regExp_mp, timeElapsed, 2))
|
||||
{
|
||||
bool ok = false;
|
||||
int progress = regExp_pass1.cap(1).toInt(&ok);
|
||||
if(ok && (duration > 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));
|
||||
if (newProgress > prevProgress)
|
||||
{
|
||||
int newProgress = qRound((static_cast<double>(progress) / static_cast<double>(duration)) * 50.0);
|
||||
if(newProgress > prevProgress)
|
||||
{
|
||||
emit statusUpdated(newProgress);
|
||||
prevProgress = qMin(newProgress + 2, 99);
|
||||
}
|
||||
emit statusUpdated(newProgress);
|
||||
prevProgress = qMin(newProgress + 2, 99);
|
||||
}
|
||||
}
|
||||
else if(regExp_pass2.lastIndexIn(text) >= 0)
|
||||
{
|
||||
bool ok = false;
|
||||
int progress = regExp_pass2.cap(1).toInt(&ok);
|
||||
if(ok && (duration > 0))
|
||||
{
|
||||
int newProgress = qRound((static_cast<double>(progress) / static_cast<double>(duration)) * 50.0) + 50;
|
||||
if(newProgress > prevProgress)
|
||||
{
|
||||
emit statusUpdated(newProgress);
|
||||
prevProgress = qMin(newProgress + 2, 99);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(regExp.lastIndexIn(text) >= 0)
|
||||
{
|
||||
bool ok = false;
|
||||
int progress = regExp.cap(1).toInt(&ok);
|
||||
if(ok && (duration > 0))
|
||||
{
|
||||
int newProgress = qRound((static_cast<double>(progress) / static_cast<double>(duration)) * 100.0);
|
||||
if(newProgress > prevProgress)
|
||||
{
|
||||
emit statusUpdated(newProgress);
|
||||
prevProgress = qMin(newProgress + 2, 99);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!text.isEmpty())
|
||||
{
|
||||
emit messageLogged(text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (regExp_sp.lastIndexIn(text) >= 0)
|
||||
{
|
||||
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);
|
||||
if (newProgress > prevProgress)
|
||||
{
|
||||
emit statusUpdated(newProgress);
|
||||
prevProgress = qMin(newProgress + 2, 99);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
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)
|
||||
if(result != RESULT_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -327,52 +275,7 @@ bool AACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
bTimeout = false;
|
||||
|
||||
while(process.state() != QProcess::NotRunning)
|
||||
{
|
||||
if(checkFlag(abortFlag))
|
||||
{
|
||||
process.kill();
|
||||
bAborted = true;
|
||||
emit messageLogged(L1S("\nABORTED BY USER !!!"));
|
||||
break;
|
||||
}
|
||||
process.waitForReadyRead(m_processTimeoutInterval);
|
||||
if(!process.bytesAvailable() && process.state() == QProcess::Running)
|
||||
{
|
||||
process.kill();
|
||||
qWarning("NeroAacTag process timed out <-- killing!");
|
||||
emit messageLogged(L1S("\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 messageLogged(QString().sprintf("\nExited with code: 0x%04X", process.exitCode()));
|
||||
|
||||
if(bTimeout || bAborted || process.exitCode() != EXIT_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return (awaitProcess(process, abortFlag) == RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
bool AACEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
|
@ -201,67 +201,28 @@ bool FDKAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bTimeout = false;
|
||||
bool bAborted = false;
|
||||
int prevProgress = -1;
|
||||
|
||||
QRegExp regExp(L1S("\\[(\\d+)%\\]\\s+(\\d+):(\\d+)"));
|
||||
|
||||
while(process.state() != QProcess::NotRunning)
|
||||
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||
{
|
||||
if(checkFlag(abortFlag))
|
||||
if (regExp.lastIndexIn(text) >= 0)
|
||||
{
|
||||
process.kill();
|
||||
bAborted = true;
|
||||
emit messageLogged(L1S("\nABORTED BY USER !!!"));
|
||||
break;
|
||||
}
|
||||
process.waitForReadyRead(m_processTimeoutInterval);
|
||||
if(!process.bytesAvailable() && process.state() == QProcess::Running)
|
||||
{
|
||||
process.kill();
|
||||
qWarning("FDKAAC process timed out <-- killing!");
|
||||
emit messageLogged(L1S("\nPROCESS TIMEOUT !!!"));
|
||||
bTimeout = true;
|
||||
break;
|
||||
}
|
||||
while(process.bytesAvailable() > 0)
|
||||
{
|
||||
QByteArray line = process.readLine();
|
||||
QString text = QString::fromUtf8(line.constData()).simplified();
|
||||
if(regExp.lastIndexIn(text) >= 0)
|
||||
qint32 newProgress;
|
||||
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||
{
|
||||
bool ok = false;
|
||||
int progress = regExp.cap(1).toInt(&ok);
|
||||
if(ok && (progress > prevProgress))
|
||||
if (newProgress > prevProgress)
|
||||
{
|
||||
emit statusUpdated(progress);
|
||||
prevProgress = qMin(progress + 2, 99);
|
||||
emit statusUpdated(newProgress);
|
||||
prevProgress = qMin(newProgress + 2, 99);
|
||||
}
|
||||
}
|
||||
else if(!text.isEmpty())
|
||||
{
|
||||
emit messageLogged(text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
return (result == RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
bool FDKAACEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
|
@ -196,67 +196,28 @@ bool FHGAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bTimeout = false;
|
||||
bool bAborted = false;
|
||||
int prevProgress = -1;
|
||||
|
||||
QRegExp regExp(L1S("Progress:\\s*(\\d+)%"));
|
||||
|
||||
while(process.state() != QProcess::NotRunning)
|
||||
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||
{
|
||||
if (checkFlag(abortFlag))
|
||||
if (regExp.lastIndexIn(text) >= 0)
|
||||
{
|
||||
process.kill();
|
||||
bAborted = true;
|
||||
emit messageLogged(L1S("\nABORTED BY USER !!!"));
|
||||
break;
|
||||
}
|
||||
process.waitForReadyRead(m_processTimeoutInterval);
|
||||
if(!process.bytesAvailable() && process.state() == QProcess::Running)
|
||||
{
|
||||
process.kill();
|
||||
qWarning("FhgAacEnc process timed out <-- killing!");
|
||||
emit messageLogged(L1S("\nPROCESS TIMEOUT !!!"));
|
||||
bTimeout = true;
|
||||
break;
|
||||
}
|
||||
while(process.bytesAvailable() > 0)
|
||||
{
|
||||
QByteArray line = process.readLine();
|
||||
QString text = QString::fromUtf8(line.constData()).simplified();
|
||||
if(regExp.lastIndexIn(text) >= 0)
|
||||
qint32 newProgress;
|
||||
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||
{
|
||||
bool ok = false;
|
||||
int progress = regExp.cap(1).toInt(&ok);
|
||||
if(ok && (progress > prevProgress))
|
||||
if (newProgress > prevProgress)
|
||||
{
|
||||
emit statusUpdated(progress);
|
||||
prevProgress = qMin(progress + 2, 99);
|
||||
emit statusUpdated(newProgress);
|
||||
prevProgress = qMin(newProgress + 2, 99);
|
||||
}
|
||||
}
|
||||
else if(!text.isEmpty())
|
||||
{
|
||||
emit messageLogged(text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
return (result == RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
bool FHGAACEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
|
@ -222,67 +222,28 @@ bool QAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bTimeout = false;
|
||||
bool bAborted = false;
|
||||
int prevProgress = -1;
|
||||
|
||||
QRegExp regExp(L1S("\\[(\\d+)\\.(\\d)%\\]"));
|
||||
|
||||
while(process.state() != QProcess::NotRunning)
|
||||
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||
{
|
||||
if (checkFlag(abortFlag))
|
||||
if (regExp.lastIndexIn(text) >= 0)
|
||||
{
|
||||
process.kill();
|
||||
bAborted = true;
|
||||
emit messageLogged(L1S("\nABORTED BY USER !!!"));
|
||||
break;
|
||||
}
|
||||
process.waitForReadyRead(m_processTimeoutInterval);
|
||||
if(!process.bytesAvailable() && process.state() == QProcess::Running)
|
||||
{
|
||||
process.kill();
|
||||
qWarning("QAAC process timed out <-- killing!");
|
||||
emit messageLogged(L1S("\nPROCESS TIMEOUT !!!"));
|
||||
bTimeout = true;
|
||||
break;
|
||||
}
|
||||
while(process.bytesAvailable() > 0)
|
||||
{
|
||||
QByteArray line = process.readLine();
|
||||
QString text = QString::fromUtf8(line.constData()).simplified();
|
||||
if(regExp.lastIndexIn(text) >= 0)
|
||||
qint32 newProgress;
|
||||
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||
{
|
||||
bool ok = false;
|
||||
int progress = regExp.cap(1).toInt(&ok);
|
||||
if(ok && (progress > prevProgress))
|
||||
if (newProgress > prevProgress)
|
||||
{
|
||||
emit statusUpdated(progress);
|
||||
prevProgress = qMin(progress + 2, 99);
|
||||
emit statusUpdated(newProgress);
|
||||
prevProgress = qMin(newProgress + 2, 99);
|
||||
}
|
||||
}
|
||||
else if(!text.isEmpty())
|
||||
{
|
||||
emit messageLogged(text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
return (result == RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
bool QAACEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
|
@ -189,67 +189,28 @@ bool AC3Encoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bTimeout = false;
|
||||
bool bAborted = false;
|
||||
int prevProgress = -1;
|
||||
QRegExp regExp(L1S("progress:\\s+(\\d+)%"));
|
||||
|
||||
QRegExp regExp(L1S("progress:(\\s+)(\\d+)%(\\s+)\\|"));
|
||||
|
||||
while(process.state() != QProcess::NotRunning)
|
||||
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||
{
|
||||
if (checkFlag(abortFlag))
|
||||
if (regExp.lastIndexIn(text) >= 0)
|
||||
{
|
||||
process.kill();
|
||||
bAborted = true;
|
||||
emit messageLogged(L1S("\nABORTED BY USER !!!"));
|
||||
break;
|
||||
}
|
||||
process.waitForReadyRead(m_processTimeoutInterval);
|
||||
if(!process.bytesAvailable() && process.state() == QProcess::Running)
|
||||
{
|
||||
process.kill();
|
||||
qWarning("Aften process timed out <-- killing!");
|
||||
emit messageLogged(L1S("\nPROCESS TIMEOUT !!!"));
|
||||
bTimeout = true;
|
||||
break;
|
||||
}
|
||||
while(process.bytesAvailable() > 0)
|
||||
{
|
||||
QByteArray line = process.readLine();
|
||||
QString text = QString::fromUtf8(line.constData()).simplified();
|
||||
if(regExp.lastIndexIn(text) >= 0)
|
||||
qint32 newProgress;
|
||||
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||
{
|
||||
bool ok = false;
|
||||
int progress = regExp.cap(2).toInt(&ok);
|
||||
if(ok && (progress > prevProgress))
|
||||
if (newProgress > prevProgress)
|
||||
{
|
||||
emit statusUpdated(progress);
|
||||
prevProgress = qMin(progress + 2, 99);
|
||||
emit statusUpdated(newProgress);
|
||||
prevProgress = qMin(newProgress + 2, 99);
|
||||
}
|
||||
}
|
||||
else if(!text.isEmpty())
|
||||
{
|
||||
emit messageLogged(text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
return (result == RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
void AC3Encoder::setAudioCodingMode(int value)
|
||||
|
@ -155,67 +155,28 @@ bool DCAEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bTimeout = false;
|
||||
bool bAborted = false;
|
||||
int prevProgress = -1;
|
||||
|
||||
QRegExp regExp(L1S("\\[(\\d+)\\.(\\d+)%\\]"));
|
||||
|
||||
while(process.state() != QProcess::NotRunning)
|
||||
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||
{
|
||||
if (checkFlag(abortFlag))
|
||||
if (regExp.lastIndexIn(text) >= 0)
|
||||
{
|
||||
process.kill();
|
||||
bAborted = true;
|
||||
emit messageLogged(L1S("\nABORTED BY USER !!!"));
|
||||
break;
|
||||
}
|
||||
process.waitForReadyRead(m_processTimeoutInterval);
|
||||
if(!process.bytesAvailable() && process.state() == QProcess::Running)
|
||||
{
|
||||
process.kill();
|
||||
qWarning("DCAENC process timed out <-- killing!");
|
||||
emit messageLogged(L1S("\nPROCESS TIMEOUT !!!"));
|
||||
bTimeout = true;
|
||||
break;
|
||||
}
|
||||
while(process.bytesAvailable() > 0)
|
||||
{
|
||||
QByteArray line = process.readLine();
|
||||
QString text = QString::fromUtf8(line.constData()).simplified();
|
||||
if(regExp.lastIndexIn(text) >= 0)
|
||||
qint32 newProgress;
|
||||
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||
{
|
||||
bool ok = false;
|
||||
int progress = regExp.cap(1).toInt(&ok);
|
||||
if(ok && (progress > prevProgress))
|
||||
if (newProgress > prevProgress)
|
||||
{
|
||||
emit statusUpdated(progress);
|
||||
prevProgress = qMin(progress + 2, 99);
|
||||
emit statusUpdated(newProgress);
|
||||
prevProgress = qMin(newProgress + 2, 99);
|
||||
}
|
||||
}
|
||||
else if(!text.isEmpty())
|
||||
{
|
||||
emit messageLogged(text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
return (result == RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
bool DCAEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
|
@ -164,67 +164,28 @@ bool FLACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bTimeout = false;
|
||||
bool bAborted = false;
|
||||
int prevProgress = -1;
|
||||
|
||||
QRegExp regExp(L1S("\\b(\\d+)% complete"));
|
||||
|
||||
while(process.state() != QProcess::NotRunning)
|
||||
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||
{
|
||||
if(checkFlag(abortFlag))
|
||||
if (regExp.lastIndexIn(text) >= 0)
|
||||
{
|
||||
process.kill();
|
||||
bAborted = true;
|
||||
emit messageLogged(L1S("\nABORTED BY USER !!!"));
|
||||
break;
|
||||
}
|
||||
process.waitForReadyRead(m_processTimeoutInterval);
|
||||
if(!process.bytesAvailable() && process.state() == QProcess::Running)
|
||||
{
|
||||
process.kill();
|
||||
qWarning("FLAC process timed out <-- killing!");
|
||||
emit messageLogged(L1S("\nPROCESS TIMEOUT !!!"));
|
||||
bTimeout = true;
|
||||
break;
|
||||
}
|
||||
while(process.bytesAvailable() > 0)
|
||||
{
|
||||
QByteArray line = process.readLine().replace('\b', char(0x20));
|
||||
QString text = QString::fromUtf8(line.constData()).simplified();
|
||||
if(regExp.lastIndexIn(text) >= 0)
|
||||
qint32 newProgress;
|
||||
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||
{
|
||||
bool ok = false;
|
||||
int progress = regExp.cap(1).toInt(&ok);
|
||||
if(ok && (progress > prevProgress))
|
||||
if (newProgress > prevProgress)
|
||||
{
|
||||
emit statusUpdated(progress);
|
||||
prevProgress = qMin(progress + 2, 99);
|
||||
emit statusUpdated(newProgress);
|
||||
prevProgress = qMin(newProgress + 2, 99);
|
||||
}
|
||||
}
|
||||
else if(!text.isEmpty())
|
||||
{
|
||||
emit messageLogged(text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return (result == RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
bool FLACEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
|
@ -161,62 +161,28 @@ bool MACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bTimeout = false;
|
||||
bool bAborted = false;
|
||||
int prevProgress = -1;
|
||||
|
||||
QRegExp regExp(L1S("Progress: (\\d+).(\\d+)%"));
|
||||
|
||||
while(process.state() != QProcess::NotRunning)
|
||||
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||
{
|
||||
if (checkFlag(abortFlag))
|
||||
if (regExp.lastIndexIn(text) >= 0)
|
||||
{
|
||||
process.kill();
|
||||
bAborted = true;
|
||||
emit messageLogged(L1S("\nABORTED BY USER !!!"));
|
||||
break;
|
||||
}
|
||||
process.waitForReadyRead(m_processTimeoutInterval);
|
||||
if(!process.bytesAvailable() && process.state() == QProcess::Running)
|
||||
{
|
||||
process.kill();
|
||||
qWarning("MAC process timed out <-- killing!");
|
||||
emit messageLogged(L1S("\nPROCESS TIMEOUT !!!"));
|
||||
bTimeout = true;
|
||||
break;
|
||||
}
|
||||
while(process.bytesAvailable() > 0)
|
||||
{
|
||||
QByteArray line = process.readLine();
|
||||
QString text = QString::fromUtf8(line.constData()).simplified();
|
||||
if(regExp.lastIndexIn(text) >= 0)
|
||||
qint32 newProgress;
|
||||
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||
{
|
||||
bool ok = false;
|
||||
int progress = regExp.cap(1).toInt(&ok);
|
||||
if(ok && (progress > prevProgress))
|
||||
if (newProgress > prevProgress)
|
||||
{
|
||||
emit statusUpdated(progress);
|
||||
prevProgress = qMin(progress + 2, 99);
|
||||
emit statusUpdated(newProgress);
|
||||
prevProgress = qMin(newProgress + 2, 99);
|
||||
}
|
||||
}
|
||||
else if(!text.isEmpty())
|
||||
{
|
||||
emit messageLogged(text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
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)
|
||||
if(result != RESULT_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -246,52 +212,7 @@ bool MACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
bTimeout = false;
|
||||
|
||||
while(process.state() != QProcess::NotRunning)
|
||||
{
|
||||
if(checkFlag(abortFlag))
|
||||
{
|
||||
process.kill();
|
||||
bAborted = true;
|
||||
emit messageLogged(L1S("\nABORTED BY USER !!!"));
|
||||
break;
|
||||
}
|
||||
process.waitForReadyRead(m_processTimeoutInterval);
|
||||
if(!process.bytesAvailable() && process.state() == QProcess::Running)
|
||||
{
|
||||
process.kill();
|
||||
qWarning("Tag process timed out <-- killing!");
|
||||
emit messageLogged(L1S("\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 messageLogged(QString().sprintf("\nExited with code: 0x%04X", process.exitCode()));
|
||||
|
||||
if(bTimeout || bAborted || process.exitCode() != EXIT_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return (awaitProcess(process, abortFlag) == RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
bool MACEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
|
@ -237,67 +237,28 @@ bool MP3Encoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bTimeout = false;
|
||||
bool bAborted = false;
|
||||
int prevProgress = -1;
|
||||
|
||||
QRegExp regExp(L1S("\\(.*(\\d+)%\\)\\|"));
|
||||
|
||||
while(process.state() != QProcess::NotRunning)
|
||||
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||
{
|
||||
if (checkFlag(abortFlag))
|
||||
if (regExp.lastIndexIn(text) >= 0)
|
||||
{
|
||||
process.kill();
|
||||
bAborted = true;
|
||||
emit messageLogged(L1S("\nABORTED BY USER !!!"));
|
||||
break;
|
||||
}
|
||||
process.waitForReadyRead(m_processTimeoutInterval);
|
||||
if(!process.bytesAvailable() && process.state() == QProcess::Running)
|
||||
{
|
||||
process.kill();
|
||||
qWarning("LAME process timed out <-- killing!");
|
||||
emit messageLogged(L1S("\nPROCESS TIMEOUT !!!"));
|
||||
bTimeout = true;
|
||||
break;
|
||||
}
|
||||
while(process.bytesAvailable() > 0)
|
||||
{
|
||||
QByteArray line = process.readLine();
|
||||
QString text = QString::fromUtf8(line.constData()).simplified();
|
||||
if(regExp.lastIndexIn(text) >= 0)
|
||||
qint32 newProgress;
|
||||
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||
{
|
||||
bool ok = false;
|
||||
int progress = regExp.cap(1).toInt(&ok);
|
||||
if(ok && (progress > prevProgress))
|
||||
if (newProgress > prevProgress)
|
||||
{
|
||||
emit statusUpdated(progress);
|
||||
prevProgress = qMin(progress + 2, 99);
|
||||
emit statusUpdated(newProgress);
|
||||
prevProgress = qMin(newProgress + 2, 99);
|
||||
}
|
||||
}
|
||||
else if(!text.isEmpty())
|
||||
{
|
||||
emit messageLogged(text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return (result == RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
bool MP3Encoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
|
@ -206,67 +206,28 @@ bool OpusEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bTimeout = false;
|
||||
bool bAborted = false;
|
||||
int prevProgress = -1;
|
||||
|
||||
QRegExp regExp(L1S("\\((\\d+)%\\)"));
|
||||
|
||||
while(process.state() != QProcess::NotRunning)
|
||||
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||
{
|
||||
if (checkFlag(abortFlag))
|
||||
if (regExp.lastIndexIn(text) >= 0)
|
||||
{
|
||||
process.kill();
|
||||
bAborted = true;
|
||||
emit messageLogged(L1S("\nABORTED BY USER !!!"));
|
||||
break;
|
||||
}
|
||||
process.waitForReadyRead(m_processTimeoutInterval);
|
||||
if(!process.bytesAvailable() && process.state() == QProcess::Running)
|
||||
{
|
||||
process.kill();
|
||||
qWarning("Opus process timed out <-- killing!");
|
||||
emit messageLogged(L1S("\nPROCESS TIMEOUT !!!"));
|
||||
bTimeout = true;
|
||||
break;
|
||||
}
|
||||
while(process.bytesAvailable() > 0)
|
||||
{
|
||||
QByteArray line = process.readLine();
|
||||
QString text = QString::fromUtf8(line.constData()).simplified();
|
||||
if(regExp.lastIndexIn(text) >= 0)
|
||||
qint32 newProgress;
|
||||
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||
{
|
||||
bool ok = false;
|
||||
int progress = regExp.cap(1).toInt(&ok);
|
||||
if(ok && (progress > prevProgress))
|
||||
if (newProgress > prevProgress)
|
||||
{
|
||||
emit statusUpdated(progress);
|
||||
prevProgress = qMin(progress + 2, 99);
|
||||
emit statusUpdated(newProgress);
|
||||
prevProgress = qMin(newProgress + 2, 99);
|
||||
}
|
||||
}
|
||||
else if(!text.isEmpty())
|
||||
{
|
||||
emit messageLogged(text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
return (result == RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
QString OpusEncoder::detectMimeType(const QString &coverFile)
|
||||
|
@ -196,67 +196,28 @@ bool VorbisEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bTimeout = false;
|
||||
bool bAborted = false;
|
||||
int prevProgress = -1;
|
||||
|
||||
QRegExp regExp(L1S("\\[.*(\\d+)[.,](\\d+)%\\]"));
|
||||
|
||||
while(process.state() != QProcess::NotRunning)
|
||||
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||
{
|
||||
if(checkFlag(abortFlag))
|
||||
if (regExp.lastIndexIn(text) >= 0)
|
||||
{
|
||||
process.kill();
|
||||
bAborted = true;
|
||||
emit messageLogged(L1S("\nABORTED BY USER !!!"));
|
||||
break;
|
||||
}
|
||||
process.waitForReadyRead(m_processTimeoutInterval);
|
||||
if(!process.bytesAvailable() && process.state() == QProcess::Running)
|
||||
{
|
||||
process.kill();
|
||||
qWarning("OggEnc process timed out <-- killing!");
|
||||
emit messageLogged(L1S("\nPROCESS TIMEOUT !!!"));
|
||||
bTimeout = true;
|
||||
break;
|
||||
}
|
||||
while(process.bytesAvailable() > 0)
|
||||
{
|
||||
QByteArray line = process.readLine();
|
||||
QString text = QString::fromUtf8(line.constData()).simplified();
|
||||
if(regExp.lastIndexIn(text) >= 0)
|
||||
qint32 newProgress;
|
||||
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||
{
|
||||
bool ok = false;
|
||||
int progress = regExp.cap(1).toInt(&ok);
|
||||
if(ok && (progress > prevProgress))
|
||||
if (newProgress > prevProgress)
|
||||
{
|
||||
emit statusUpdated(progress);
|
||||
prevProgress = qMin(progress + 2, 99);
|
||||
emit statusUpdated(newProgress);
|
||||
prevProgress = qMin(newProgress + 2, 99);
|
||||
}
|
||||
}
|
||||
else if(!text.isEmpty())
|
||||
{
|
||||
emit messageLogged(text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
return (result == RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
bool VorbisEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
|
@ -156,6 +156,14 @@ bool AbstractTool::startProcess(QProcess &process, const QString &program, const
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait for process to terminate while processing its output
|
||||
*/
|
||||
AbstractTool::result_t AbstractTool::awaitProcess(QProcess &process, QAtomicInt &abortFlag, int *const exitCode)
|
||||
{
|
||||
return awaitProcess(process, abortFlag, [](const QString &text) { return false; }, exitCode);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait for process to terminate while processing its output
|
||||
*/
|
||||
@ -223,8 +231,8 @@ AbstractTool::result_t AbstractTool::awaitProcess(QProcess &process, QAtomicInt
|
||||
*exitCode = process.exitCode();
|
||||
}
|
||||
|
||||
emit statusUpdated(100);
|
||||
emit messageLogged(QString().sprintf("\nExited with code: 0x%04X", process.exitCode()));
|
||||
if (!(bAborted || bTimeout)) emit statusUpdated(100);
|
||||
|
||||
if (bAborted || bTimeout || (process.exitCode() != EXIT_SUCCESS))
|
||||
{
|
||||
|
@ -67,6 +67,7 @@ protected:
|
||||
static QString commandline2string(const QString &program, const QStringList &arguments);
|
||||
|
||||
bool startProcess(QProcess &process, const QString &program, const QStringList &args, const QString &workingDir = QString());
|
||||
result_t awaitProcess(QProcess &process, QAtomicInt &abortFlag, int *const exitCode = NULL);
|
||||
result_t awaitProcess(QProcess &process, QAtomicInt &abortFlag, std::function<bool(const QString &text)> &&handler, int *const exitCode = NULL);
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user