OSDN Git Service

Now using rand_s() to generate random numbers, which doesn't need a seed. Falling...
[lamexp/LameXP.git] / src / Decoder_Vorbis.cpp
index 4834728..b1c52f3 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // LameXP - Audio Encoder Front-End
-// Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -56,6 +56,7 @@ bool VorbisDecoder::decode(const QString &sourceFile, const QString &outputFile,
 
        bool bTimeout = false;
        bool bAborted = false;
+       int prevProgress = -1;
 
        QRegExp regExp(" (\\d+)% decoded.");
 
@@ -68,11 +69,12 @@ bool VorbisDecoder::decode(const QString &sourceFile, const QString &outputFile,
                        emit messageLogged("\nABORTED BY USER !!!");
                        break;
                }
-               process.waitForReadyRead();
+               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;
                }
@@ -84,7 +86,11 @@ bool VorbisDecoder::decode(const QString &sourceFile, const QString &outputFile,
                        {
                                bool ok = false;
                                int progress = regExp.cap(1).toInt(&ok);
-                               if(ok) emit statusUpdated(progress);
+                               if(ok && (progress > prevProgress))
+                               {
+                                       emit statusUpdated(progress);
+                                       prevProgress = qMin(progress + 2, 99);
+                               }
                        }
                        else if(!text.isEmpty())
                        {
@@ -103,7 +109,7 @@ bool VorbisDecoder::decode(const QString &sourceFile, const QString &outputFile,
        emit statusUpdated(100);
        emit messageLogged(QString().sprintf("\nExited with code: 0x%04X", process.exitCode()));
 
-       if(bTimeout || bAborted || process.exitStatus() != QProcess::NormalExit || QFileInfo(outputFile).size() == 0)
+       if(bTimeout || bAborted || process.exitCode() != EXIT_SUCCESS || QFileInfo(outputFile).size() == 0)
        {
                return false;
        }