Refactored all decoder classes to use awaitProcess() from Tool_Abstract base class.
This commit is contained in:
parent
4d7b7a766a
commit
7288244a27
@ -35,7 +35,7 @@
|
|||||||
#define VER_LAMEXP_MINOR_LO 6
|
#define VER_LAMEXP_MINOR_LO 6
|
||||||
#define VER_LAMEXP_TYPE Beta
|
#define VER_LAMEXP_TYPE Beta
|
||||||
#define VER_LAMEXP_PATCH 1
|
#define VER_LAMEXP_PATCH 1
|
||||||
#define VER_LAMEXP_BUILD 2066
|
#define VER_LAMEXP_BUILD 2068
|
||||||
#define VER_LAMEXP_CONFG 2002
|
#define VER_LAMEXP_CONFG 2002
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -60,63 +60,29 @@ bool AACDecoder::decode(const QString &sourceFile, const QString &outputFile, QA
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bTimeout = false;
|
int prevProgress = -1;
|
||||||
bool bAborted = false;
|
|
||||||
|
|
||||||
QRegExp regExp("\\[(\\d+)%\\]\\s+decoding\\s+");
|
QRegExp regExp("\\[(\\d+)%\\]\\s+decoding\\s+");
|
||||||
|
|
||||||
while(process.state() != QProcess::NotRunning)
|
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||||
{
|
{
|
||||||
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("FAAD 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 (regExp.lastIndexIn(text) >= 0)
|
if (regExp.lastIndexIn(text) >= 0)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
qint32 newProgress;
|
||||||
int progress = regExp.cap(1).toInt(&ok);
|
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||||
if(ok) emit statusUpdated(progress);
|
|
||||||
}
|
|
||||||
else if(!text.isEmpty())
|
|
||||||
{
|
{
|
||||||
emit messageLogged(text);
|
if (newProgress > prevProgress)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
process.waitForFinished();
|
|
||||||
if(process.state() != QProcess::NotRunning)
|
|
||||||
{
|
{
|
||||||
process.kill();
|
emit statusUpdated(newProgress);
|
||||||
process.waitForFinished(-1);
|
prevProgress = qMin(newProgress + 2, 99);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (result == RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
bool AACDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
bool AACDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
{
|
{
|
||||||
|
@ -53,70 +53,38 @@ bool AC3Decoder::decode(const QString &sourceFile, const QString &outputFile, QA
|
|||||||
QStringList args;
|
QStringList args;
|
||||||
|
|
||||||
args << QDir::toNativeSeparators(sourceFile);
|
args << QDir::toNativeSeparators(sourceFile);
|
||||||
args << "-i" << "-w" << QDir::toNativeSeparators(outputFile);
|
args << "-w" << QDir::toNativeSeparators(outputFile);
|
||||||
|
|
||||||
if(!startProcess(process, m_binary, args))
|
if(!startProcess(process, m_binary, args))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bTimeout = false;
|
int prevProgress = -1;
|
||||||
bool bAborted = false;
|
QRegExp regExp("\\b\\s*(\\d+)\\.(\\d+)?%(\\s+)Frames", Qt::CaseInsensitive);
|
||||||
|
|
||||||
QRegExp regExp("\\b(\\s*)(\\d+)\\.(\\d+)%(\\s+)Frames");
|
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||||
|
|
||||||
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("Valdec 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 (regExp.lastIndexIn(text) >= 0)
|
if (regExp.lastIndexIn(text) >= 0)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
qWarning("Found! [\"%s\"]", MUTILS_UTF8(regExp.cap(1)));
|
||||||
int progress = regExp.cap(2).toInt(&ok);
|
qint32 newProgress;
|
||||||
if(ok) emit statusUpdated(progress);
|
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||||
}
|
|
||||||
else if(!text.isEmpty())
|
|
||||||
{
|
{
|
||||||
emit messageLogged(text);
|
qWarning("newProgress: %d", newProgress);
|
||||||
}
|
if (newProgress > prevProgress)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
process.waitForFinished();
|
|
||||||
if(process.state() != QProcess::NotRunning)
|
|
||||||
{
|
{
|
||||||
process.kill();
|
emit statusUpdated(newProgress);
|
||||||
process.waitForFinished(-1);
|
prevProgress = qMin(newProgress + 2, 99);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (result == RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
bool AC3Decoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
bool AC3Decoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
{
|
{
|
||||||
|
@ -62,63 +62,29 @@ bool ADPCMDecoder::decode(const QString &sourceFile, const QString &outputFile,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bTimeout = false;
|
int prevProgress = -1;
|
||||||
bool bAborted = false;
|
|
||||||
|
|
||||||
QRegExp regExp("In:(\\d+)(\\.\\d+)*%");
|
QRegExp regExp("In:(\\d+)(\\.\\d+)*%");
|
||||||
|
|
||||||
while(process.state() != QProcess::NotRunning)
|
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||||
{
|
{
|
||||||
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("Sox 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 (regExp.lastIndexIn(text) >= 0)
|
if (regExp.lastIndexIn(text) >= 0)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
qint32 newProgress;
|
||||||
int progress = regExp.cap(1).toInt(&ok);
|
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||||
if(ok) emit statusUpdated(progress);
|
|
||||||
}
|
|
||||||
else if(!text.isEmpty())
|
|
||||||
{
|
{
|
||||||
emit messageLogged(text);
|
if (newProgress > prevProgress)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
process.waitForFinished();
|
|
||||||
if(process.state() != QProcess::NotRunning)
|
|
||||||
{
|
{
|
||||||
process.kill();
|
emit statusUpdated(newProgress);
|
||||||
process.waitForFinished(-1);
|
prevProgress = qMin(newProgress + 2, 99);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (result == RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
bool ADPCMDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
bool ADPCMDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
{
|
{
|
||||||
|
@ -62,76 +62,30 @@ bool ALACDecoder::decode(const QString &sourceFile, const QString &outputFile, Q
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bTimeout = false;
|
|
||||||
bool bAborted = false;
|
|
||||||
int prevProgress = -1;
|
int prevProgress = -1;
|
||||||
|
|
||||||
//The ALAC Decoder doesn't actually send any status updates :-[
|
|
||||||
//emit statusUpdated(20 + (QUuid::createUuid().data1 % 60));
|
|
||||||
QRegExp regExp("\\[(\\d+)\\.(\\d)%\\]");
|
QRegExp regExp("\\[(\\d+)\\.(\\d)%\\]");
|
||||||
|
|
||||||
while(process.state() != QProcess::NotRunning)
|
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||||
{
|
{
|
||||||
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("ALAC 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 (regExp.lastIndexIn(text) >= 0)
|
if (regExp.lastIndexIn(text) >= 0)
|
||||||
{
|
{
|
||||||
bool ok[2] = {false, false};
|
qint32 intVal[2];
|
||||||
int intVal[2] = {0, 0};
|
if (MUtils::regexp_parse_int32(regExp, intVal, 2))
|
||||||
intVal[0] = regExp.cap(1).toInt(&ok[0]);
|
|
||||||
intVal[1] = regExp.cap(2).toInt(&ok[1]);
|
|
||||||
if(ok[0] && ok[1])
|
|
||||||
{
|
{
|
||||||
int progress = qRound(static_cast<double>(intVal[0]) + (static_cast<double>(intVal[1]) / 10.0));
|
const int newProgress = qRound(static_cast<double>(intVal[0]) + (static_cast<double>(intVal[1]) / 10.0));
|
||||||
if(progress > prevProgress)
|
if (newProgress > prevProgress)
|
||||||
{
|
{
|
||||||
emit statusUpdated(progress);
|
emit statusUpdated(newProgress);
|
||||||
prevProgress = qMin(progress + 2, 99);
|
prevProgress = qMin(newProgress + 2, 99);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else 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 true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (result == RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
bool ALACDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
bool ALACDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
{
|
{
|
||||||
|
@ -61,63 +61,29 @@ bool AvisynthDecoder::decode(const QString &sourceFile, const QString &outputFil
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bTimeout = false;
|
int prevProgress = -1;
|
||||||
bool bAborted = false;
|
QRegExp regExp("\\d+/\\d+ \\[(\\d+)%\\]");
|
||||||
|
|
||||||
QRegExp regExp("(\\d+)/(\\d+) \\[(\\d+)%\\]");
|
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||||
|
|
||||||
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("AVS2WAV 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 (regExp.lastIndexIn(text) >= 0)
|
if (regExp.lastIndexIn(text) >= 0)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
qint32 newProgress;
|
||||||
int progress = regExp.cap(3).toInt(&ok);
|
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||||
if(ok) emit statusUpdated(progress);
|
|
||||||
}
|
|
||||||
else if(!text.isEmpty())
|
|
||||||
{
|
{
|
||||||
emit messageLogged(text);
|
if (newProgress > prevProgress)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
process.waitForFinished();
|
|
||||||
if(process.state() != QProcess::NotRunning)
|
|
||||||
{
|
{
|
||||||
process.kill();
|
emit statusUpdated(newProgress);
|
||||||
process.waitForFinished(-1);
|
prevProgress = qMin(newProgress + 2, 99);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (result == RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
bool AvisynthDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
bool AvisynthDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
{
|
{
|
||||||
|
@ -61,63 +61,29 @@ bool FLACDecoder::decode(const QString &sourceFile, const QString &outputFile, Q
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bTimeout = false;
|
int prevProgress = -1;
|
||||||
bool bAborted = false;
|
|
||||||
|
|
||||||
QRegExp regExp("\\b(\\d+)% complete");
|
QRegExp regExp("\\b(\\d+)% complete");
|
||||||
|
|
||||||
while(process.state() != QProcess::NotRunning)
|
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||||
{
|
{
|
||||||
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("FLAC process timed out <-- killing!");
|
|
||||||
emit messageLogged("\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)
|
if (regExp.lastIndexIn(text) >= 0)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
qint32 newProgress;
|
||||||
int progress = regExp.cap(1).toInt(&ok);
|
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||||
if(ok) emit statusUpdated(progress);
|
|
||||||
}
|
|
||||||
else if(!text.isEmpty())
|
|
||||||
{
|
{
|
||||||
emit messageLogged(text);
|
if (newProgress > prevProgress)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
process.waitForFinished();
|
|
||||||
if(process.state() != QProcess::NotRunning)
|
|
||||||
{
|
{
|
||||||
process.kill();
|
emit statusUpdated(newProgress);
|
||||||
process.waitForFinished(-1);
|
prevProgress = qMin(newProgress + 2, 99);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (result == RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
bool FLACDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
bool FLACDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
{
|
{
|
||||||
|
@ -61,68 +61,29 @@ bool MACDecoder::decode(const QString &sourceFile, const QString &outputFile, QA
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bTimeout = false;
|
|
||||||
bool bAborted = false;
|
|
||||||
int prevProgress = -1;
|
int prevProgress = -1;
|
||||||
|
|
||||||
QRegExp regExp("Progress: (\\d+).(\\d+)%");
|
QRegExp regExp("Progress: (\\d+).(\\d+)%");
|
||||||
|
|
||||||
while(process.state() != QProcess::NotRunning)
|
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||||
{
|
{
|
||||||
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("MAC 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 (regExp.lastIndexIn(text) >= 0)
|
if (regExp.lastIndexIn(text) >= 0)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
qint32 newProgress;
|
||||||
int progress = regExp.cap(1).toInt(&ok);
|
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||||
if(ok && (progress > prevProgress))
|
|
||||||
{
|
{
|
||||||
emit statusUpdated(progress);
|
if (newProgress > prevProgress)
|
||||||
prevProgress = qMin(progress + 2, 99);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(!text.isEmpty())
|
|
||||||
{
|
{
|
||||||
emit messageLogged(text);
|
emit statusUpdated(newProgress);
|
||||||
|
prevProgress = qMin(newProgress + 2, 99);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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 true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (result == RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
bool MACDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
bool MACDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
{
|
{
|
||||||
|
@ -66,35 +66,11 @@ bool MP3Decoder::decode(const QString &sourceFile, const QString &outputFile, QA
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bTimeout = false;
|
|
||||||
bool bAborted = false;
|
|
||||||
int prevProgress = -1;
|
int prevProgress = -1;
|
||||||
|
|
||||||
//QRegExp regExp("\\b\\d+\\+\\d+\\s+(\\d+):(\\d+)\\.(\\d+)\\+(\\d+):(\\d+)\\.(\\d+)\\b");
|
|
||||||
QRegExp regExp("[_=>]\\s+(\\d+)\\+(\\d+)\\s+");
|
QRegExp regExp("[_=>]\\s+(\\d+)\\+(\\d+)\\s+");
|
||||||
|
|
||||||
while(process.state() != QProcess::NotRunning)
|
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||||
{
|
{
|
||||||
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("mpg123 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 (regExp.lastIndexIn(text) >= 0)
|
if (regExp.lastIndexIn(text) >= 0)
|
||||||
{
|
{
|
||||||
quint32 values[2];
|
quint32 values[2];
|
||||||
@ -111,31 +87,13 @@ bool MP3Decoder::decode(const QString &sourceFile, const QString &outputFile, QA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else 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)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (result == RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
bool MP3Decoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
bool MP3Decoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
{
|
{
|
||||||
|
@ -62,68 +62,29 @@ bool MusepackDecoder::decode(const QString &sourceFile, const QString &outputFil
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bTimeout = false;
|
|
||||||
bool bAborted = false;
|
|
||||||
int prevProgress = -1;
|
int prevProgress = -1;
|
||||||
|
|
||||||
QRegExp regExp("Decoding progress: (\\d+)\\.(\\d+)%");
|
QRegExp regExp("Decoding progress: (\\d+)\\.(\\d+)%");
|
||||||
|
|
||||||
while(process.state() != QProcess::NotRunning)
|
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||||
{
|
{
|
||||||
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("MpcDec 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 (regExp.lastIndexIn(text) >= 0)
|
if (regExp.lastIndexIn(text) >= 0)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
qint32 newProgress;
|
||||||
int progress = regExp.cap(1).toInt(&ok);
|
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||||
if(ok && (progress > prevProgress))
|
|
||||||
{
|
{
|
||||||
emit statusUpdated(progress);
|
if (newProgress > prevProgress)
|
||||||
prevProgress = qMin(progress + 2, 99);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(!text.isEmpty())
|
|
||||||
{
|
{
|
||||||
emit messageLogged(text);
|
emit statusUpdated(newProgress);
|
||||||
|
prevProgress = qMin(newProgress + 2, 99);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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 true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (result == RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
bool MusepackDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
bool MusepackDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
{
|
{
|
||||||
|
@ -68,68 +68,29 @@ bool OpusDecoder::decode(const QString &sourceFile, const QString &outputFile, Q
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bTimeout = false;
|
|
||||||
bool bAborted = false;
|
|
||||||
int prevProgress = -1;
|
int prevProgress = -1;
|
||||||
|
|
||||||
QRegExp regExp("\\((\\d+)%\\)");
|
QRegExp regExp("\\((\\d+)%\\)");
|
||||||
|
|
||||||
while(process.state() != QProcess::NotRunning)
|
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||||
{
|
{
|
||||||
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("opusdec 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 (regExp.lastIndexIn(text) >= 0)
|
if (regExp.lastIndexIn(text) >= 0)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
qint32 newProgress;
|
||||||
int progress = regExp.cap(1).toInt(&ok);
|
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||||
if(ok && (progress > prevProgress))
|
|
||||||
{
|
{
|
||||||
emit statusUpdated(progress);
|
if (newProgress > prevProgress)
|
||||||
prevProgress = qMin(progress + 2, 99);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(!text.isEmpty())
|
|
||||||
{
|
{
|
||||||
emit messageLogged(text);
|
emit statusUpdated(newProgress);
|
||||||
|
prevProgress = qMin(newProgress + 2, 99);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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 true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (result == RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
bool OpusDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
bool OpusDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
{
|
{
|
||||||
|
@ -61,61 +61,19 @@ bool SpeexDecoder::decode(const QString &sourceFile, const QString &outputFile,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bTimeout = false;
|
|
||||||
bool bAborted = false;
|
|
||||||
|
|
||||||
QRegExp regExp("Working\\.\\.\\. (.)");
|
QRegExp regExp("Working\\.\\.\\. (.)");
|
||||||
|
|
||||||
while(process.state() != QProcess::NotRunning)
|
const result_t result = awaitProcess(process, abortFlag, [this, ®Exp](const QString &text)
|
||||||
{
|
{
|
||||||
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("SpeexDec 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 (regExp.lastIndexIn(text) >= 0)
|
if (regExp.lastIndexIn(text) >= 0)
|
||||||
{
|
{
|
||||||
/* qDebug("Status: %s", regExp.cap(1).toLatin1().constData()); */
|
|
||||||
}
|
|
||||||
else 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 true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (result == RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
bool SpeexDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
bool SpeexDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
{
|
{
|
||||||
|
@ -62,63 +62,29 @@ bool TTADecoder::decode(const QString &sourceFile, const QString &outputFile, QA
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bTimeout = false;
|
int prevProgress = -1;
|
||||||
bool bAborted = false;
|
|
||||||
|
|
||||||
QRegExp regExp("Progress: (\\d+)%");
|
QRegExp regExp("Progress: (\\d+)%");
|
||||||
|
|
||||||
while(process.state() != QProcess::NotRunning)
|
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||||
{
|
{
|
||||||
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("TTAEnc 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 (regExp.lastIndexIn(text) >= 0)
|
if (regExp.lastIndexIn(text) >= 0)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
qint32 newProgress;
|
||||||
int progress = regExp.cap(1).toInt(&ok);
|
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||||
if(ok) emit statusUpdated(progress);
|
|
||||||
}
|
|
||||||
else if(!text.isEmpty())
|
|
||||||
{
|
{
|
||||||
emit messageLogged(text);
|
if (newProgress > prevProgress)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
process.waitForFinished();
|
|
||||||
if(process.state() != QProcess::NotRunning)
|
|
||||||
{
|
{
|
||||||
process.kill();
|
emit statusUpdated(newProgress);
|
||||||
process.waitForFinished(-1);
|
prevProgress = qMin(newProgress + 2, 99);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (result == RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
bool TTADecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
bool TTADecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
{
|
{
|
||||||
|
@ -60,68 +60,29 @@ bool VorbisDecoder::decode(const QString &sourceFile, const QString &outputFile,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bTimeout = false;
|
|
||||||
bool bAborted = false;
|
|
||||||
int prevProgress = -1;
|
int prevProgress = -1;
|
||||||
|
QRegExp regExp("\\s+(\\d+)% decoded.");
|
||||||
|
|
||||||
QRegExp regExp(" (\\d+)% decoded.");
|
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||||
|
|
||||||
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("OggDec 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 (regExp.lastIndexIn(text) >= 0)
|
if (regExp.lastIndexIn(text) >= 0)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
qint32 newProgress;
|
||||||
int progress = regExp.cap(1).toInt(&ok);
|
if (MUtils::regexp_parse_int32(regExp, newProgress))
|
||||||
if(ok && (progress > prevProgress))
|
|
||||||
{
|
{
|
||||||
emit statusUpdated(progress);
|
if (newProgress > prevProgress)
|
||||||
prevProgress = qMin(progress + 2, 99);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(!text.isEmpty())
|
|
||||||
{
|
{
|
||||||
emit messageLogged(text);
|
emit statusUpdated(newProgress);
|
||||||
|
prevProgress = qMin(newProgress + 2, 99);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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 true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (result == RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
bool VorbisDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
bool VorbisDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
{
|
{
|
||||||
|
@ -62,63 +62,29 @@ bool WMADecoder::decode(const QString &sourceFile, const QString &outputFile, QA
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bTimeout = false;
|
int prevProgress = -1;
|
||||||
bool bAborted = false;
|
|
||||||
|
|
||||||
QRegExp regExp("\\[(\\d+)\\.(\\d+)%\\]");
|
QRegExp regExp("\\[(\\d+)\\.(\\d+)%\\]");
|
||||||
|
|
||||||
while(process.state() != QProcess::NotRunning)
|
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||||
{
|
{
|
||||||
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("wma2wav 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 (regExp.lastIndexIn(text) >= 0)
|
if (regExp.lastIndexIn(text) >= 0)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
qint32 newProgress;
|
||||||
int progress = regExp.cap(1).toInt(&ok);
|
if (MUtils::regexp_parse_int32(regExp, newProgress, 2U))
|
||||||
if(ok) emit statusUpdated(progress);
|
|
||||||
}
|
|
||||||
else if(!text.isEmpty())
|
|
||||||
{
|
{
|
||||||
emit messageLogged(text);
|
if (newProgress > prevProgress)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
process.waitForFinished();
|
|
||||||
if(process.state() != QProcess::NotRunning)
|
|
||||||
{
|
{
|
||||||
process.kill();
|
emit statusUpdated(newProgress);
|
||||||
process.waitForFinished(-1);
|
prevProgress = qMin(newProgress + 2, 99);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (result == RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
bool WMADecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
bool WMADecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
{
|
{
|
||||||
|
@ -61,68 +61,29 @@ bool WavPackDecoder::decode(const QString &sourceFile, const QString &outputFile
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bTimeout = false;
|
|
||||||
bool bAborted = false;
|
|
||||||
int prevProgress = -1;
|
int prevProgress = -1;
|
||||||
|
|
||||||
QRegExp regExp("(\\s|\b)(\\d+)%\\s+done");
|
QRegExp regExp("(\\s|\b)(\\d+)%\\s+done");
|
||||||
|
|
||||||
while(process.state() != QProcess::NotRunning)
|
const result_t result = awaitProcess(process, abortFlag, [this, &prevProgress, ®Exp](const QString &text)
|
||||||
{
|
{
|
||||||
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("WvUnpack 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 (regExp.lastIndexIn(text) >= 0)
|
if (regExp.lastIndexIn(text) >= 0)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
qint32 newProgress;
|
||||||
int progress = regExp.cap(2).toInt(&ok);
|
if (MUtils::regexp_parse_int32(regExp, newProgress, 2U))
|
||||||
if(ok && (progress > prevProgress))
|
|
||||||
{
|
{
|
||||||
emit statusUpdated(progress);
|
if (newProgress > prevProgress)
|
||||||
prevProgress = qMin(progress + 2, 99);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(!text.isEmpty())
|
|
||||||
{
|
{
|
||||||
emit messageLogged(text);
|
emit statusUpdated(newProgress);
|
||||||
|
prevProgress = qMin(newProgress + 2, 99);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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 true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (result == RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
bool WavPackDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
bool WavPackDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
{
|
{
|
||||||
|
@ -156,6 +156,84 @@ bool AbstractTool::startProcess(QProcess &process, const QString &program, const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wait for process to terminate while processing its output
|
||||||
|
*/
|
||||||
|
AbstractTool::result_t AbstractTool::awaitProcess(QProcess &process, QAtomicInt &abortFlag, std::function<bool(const QString &text)> &&handler, int *const exitCode)
|
||||||
|
{
|
||||||
|
bool bTimeout = false;
|
||||||
|
bool bAborted = false;
|
||||||
|
|
||||||
|
QString lastText;
|
||||||
|
|
||||||
|
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("Tool process timed out <-- killing!");
|
||||||
|
emit messageLogged("\nPROCESS TIMEOUT !!!");
|
||||||
|
bTimeout = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (process.bytesAvailable() > 0)
|
||||||
|
{
|
||||||
|
QByteArray line = process.readLine();
|
||||||
|
if (line.size() > 0)
|
||||||
|
{
|
||||||
|
static const char REPALCE_CHARS[3] = { '\r', '\b', '\t' };
|
||||||
|
for (size_t i = 0; i < MUTILS_ARR2LEN(REPALCE_CHARS); ++i)
|
||||||
|
{
|
||||||
|
line.replace(REPALCE_CHARS[i], char(0x20));
|
||||||
|
}
|
||||||
|
const QString text = QString::fromUtf8(line.constData()).simplified();
|
||||||
|
if (!text.isEmpty())
|
||||||
|
{
|
||||||
|
if (!handler(text))
|
||||||
|
{
|
||||||
|
if (text.compare(lastText, Qt::CaseInsensitive) != 0)
|
||||||
|
{
|
||||||
|
emit messageLogged(lastText = text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
process.waitForFinished();
|
||||||
|
if (process.state() != QProcess::NotRunning)
|
||||||
|
{
|
||||||
|
process.kill();
|
||||||
|
process.waitForFinished(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exitCode)
|
||||||
|
{
|
||||||
|
*exitCode = process.exitCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
emit statusUpdated(100);
|
||||||
|
emit messageLogged(QString().sprintf("\nExited with code: 0x%04X", process.exitCode()));
|
||||||
|
|
||||||
|
if (bAborted || bTimeout || (process.exitCode() != EXIT_SUCCESS))
|
||||||
|
{
|
||||||
|
return bAborted ? RESULT_ABORTED : (bTimeout ? RESULT_TIMEOUT : RESULT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert program arguments to single string
|
* Convert program arguments to single string
|
||||||
*/
|
*/
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <MUtils\Global.h>
|
#include <MUtils\Global.h>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
class QMutex;
|
class QMutex;
|
||||||
class QProcess;
|
class QProcess;
|
||||||
@ -42,9 +43,6 @@ public:
|
|||||||
AbstractTool(void);
|
AbstractTool(void);
|
||||||
~AbstractTool(void);
|
~AbstractTool(void);
|
||||||
|
|
||||||
bool startProcess(QProcess &process, const QString &program, const QStringList &args, const QString &workingDir = QString());
|
|
||||||
static QString commandline2string(const QString &program, const QStringList &arguments);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void statusUpdated(int progress);
|
void statusUpdated(int progress);
|
||||||
void messageLogged(const QString &line);
|
void messageLogged(const QString &line);
|
||||||
@ -52,11 +50,25 @@ signals:
|
|||||||
protected:
|
protected:
|
||||||
static const int m_processTimeoutInterval = 600000;
|
static const int m_processTimeoutInterval = 600000;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
RESULT_ABORTED = -2,
|
||||||
|
RESULT_TIMEOUT = -1,
|
||||||
|
RESULT_FAILURE = 0,
|
||||||
|
RESULT_SUCCESS = 1
|
||||||
|
}
|
||||||
|
result_t;
|
||||||
|
|
||||||
static __forceinline bool checkFlag(QAtomicInt &flag)
|
static __forceinline bool checkFlag(QAtomicInt &flag)
|
||||||
{
|
{
|
||||||
return MUTILS_BOOLIFY(flag);
|
return MUTILS_BOOLIFY(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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, std::function<bool(const QString &text)> &&handler, int *const exitCode = NULL);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QScopedPointer<MUtils::JobObject> s_jobObjectInstance;
|
static QScopedPointer<MUtils::JobObject> s_jobObjectInstance;
|
||||||
static QScopedPointer<QElapsedTimer> s_startProcessTimer;
|
static QScopedPointer<QElapsedTimer> s_startProcessTimer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user