Make Avisynth analyzer check the exit code of avs2wav.

This commit is contained in:
LoRd_MuldeR 2011-05-21 23:51:28 +02:00
parent eece27de06
commit b0a6432b88
2 changed files with 22 additions and 8 deletions

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 2 #define VER_LAMEXP_MINOR_LO 2
#define VER_LAMEXP_TYPE Beta #define VER_LAMEXP_TYPE Beta
#define VER_LAMEXP_PATCH 3 #define VER_LAMEXP_PATCH 3
#define VER_LAMEXP_BUILD 544 #define VER_LAMEXP_BUILD 545
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Tools versions // Tools versions

View File

@ -122,7 +122,7 @@ void FileAnalyzer::run()
} }
else if(!QFileInfo(currentFile).suffix().compare("avs", Qt::CaseInsensitive)) else if(!QFileInfo(currentFile).suffix().compare("avs", Qt::CaseInsensitive))
{ {
qWarning("Added an potential Avisynth script file!"); qDebug("Found a potential Avisynth script, investigating...");
if(analyzeAvisynthFile(currentFile, file)) if(analyzeAvisynthFile(currentFile, file))
{ {
m_filesAccepted++; m_filesAccepted++;
@ -561,8 +561,6 @@ void FileAnalyzer::retrieveCover(AudioFileModel &audioFile, const QString &fileP
bool FileAnalyzer::analyzeAvisynthFile(const QString &filePath, AudioFileModel &info) bool FileAnalyzer::analyzeAvisynthFile(const QString &filePath, AudioFileModel &info)
{ {
bool bAudioInfoReceived = false;
QProcess process; QProcess process;
process.setProcessChannelMode(QProcess::MergedChannels); process.setProcessChannelMode(QProcess::MergedChannels);
process.setReadChannel(QProcess::StandardOutput); process.setReadChannel(QProcess::StandardOutput);
@ -577,6 +575,8 @@ bool FileAnalyzer::analyzeAvisynthFile(const QString &filePath, AudioFileModel &
return false; return false;
} }
bool bInfoHeaderFound = false;
while(process.state() != QProcess::NotRunning) while(process.state() != QProcess::NotRunning)
{ {
if(m_abortFlag) if(m_abortFlag)
@ -610,7 +610,7 @@ bool FileAnalyzer::analyzeAvisynthFile(const QString &filePath, AudioFileModel &
QString key = line.left(index).trimmed(); QString key = line.left(index).trimmed();
QString val = line.mid(index+1).trimmed(); QString val = line.mid(index+1).trimmed();
if(!key.isEmpty() && !val.isEmpty()) if(bInfoHeaderFound && !key.isEmpty() && !val.isEmpty())
{ {
if(key.compare("TotalSeconds", Qt::CaseInsensitive) == 0) if(key.compare("TotalSeconds", Qt::CaseInsensitive) == 0)
{ {
@ -644,7 +644,7 @@ bool FileAnalyzer::analyzeAvisynthFile(const QString &filePath, AudioFileModel &
{ {
info.setFormatAudioType("Avisynth"); info.setFormatAudioType("Avisynth");
info.setFormatContainerType("Avisynth"); info.setFormatContainerType("Avisynth");
bAudioInfoReceived = true; bInfoHeaderFound = true;
} }
} }
} }
@ -658,10 +658,24 @@ bool FileAnalyzer::analyzeAvisynthFile(const QString &filePath, AudioFileModel &
process.waitForFinished(-1); process.waitForFinished(-1);
} }
return bAudioInfoReceived; //Check exit code
switch(process.exitCode())
{
case 0:
qDebug("Avisynth script was analyzed successfully.");
return true;
break;
case -5:
qWarning("It appears that Avisynth is not installed on the system!");
return false;
break;
default:
qWarning("Failed to open the Avisynth script, bad AVS file?");
return false;
break;
}
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Public Functions // Public Functions
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////