OSDN Git Service

Bump version.
[lamexp/LameXP.git] / src / Thread_FileAnalyzer_Task.cpp
index 465284f..cc1f7b5 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // LameXP - Audio Encoder Front-End
-// Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2015 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
 
 #include "Thread_FileAnalyzer_Task.h"
 
+//Internal
 #include "Global.h"
 #include "LockedFile.h"
 #include "Model_AudioFile.h"
 
+//MUtils
+#include <MUtils/Global.h>
+#include <MUtils/OSSupport.h>
+#include <MUtils/Exception.h>
+
+//Qt
 #include <QDir>
 #include <QFileInfo>
 #include <QProcess>
@@ -37,6 +44,8 @@
 #include <QWriteLocker>
 #include <QThread>
 
+
+//CRT
 #include <math.h>
 #include <time.h>
 #include <assert.h>
@@ -54,8 +63,8 @@ AnalyzeTask::AnalyzeTask(const int taskId, const QString &inputFile, const QStri
        m_taskId(taskId),
        m_inputFile(inputFile),
        m_templateFile(templateFile),
-       m_mediaInfoBin(lamexp_lookup_tool("mediainfo.exe")),
-       m_avs2wavBin(lamexp_lookup_tool("avs2wav.exe")),
+       m_mediaInfoBin(lamexp_tools_lookup("mediainfo.exe")),
+       m_avs2wavBin(lamexp_tools_lookup("avs2wav.exe")),
        m_abortFlag(abortFlag)
 {
        if(m_mediaInfoBin.isEmpty() || m_avs2wavBin.isEmpty())
@@ -81,15 +90,13 @@ void AnalyzeTask::run()
        }
        catch(const std::exception &error)
        {
-               fflush(stdout); fflush(stderr);
-               fprintf(stderr, "\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what());
-               lamexp_fatal_exit(L"Unhandeled C++ exception error, application will exit!");
+               MUTILS_PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what());
+               MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!");
        }
        catch(...)
        {
-               fflush(stdout); fflush(stderr);
-               fprintf(stderr, "\nGURU MEDITATION !!!\n\nUnknown exception error!\n");
-               lamexp_fatal_exit(L"Unhandeled C++ exception error, application will exit!");
+               MUTILS_PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnknown exception error!\n");
+               MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!");
        }
 }
 
@@ -97,7 +104,7 @@ void AnalyzeTask::run_ex(void)
 {
        int fileType = fileTypeNormal;
        QString currentFile = QDir::fromNativeSeparators(m_inputFile);
-       qDebug("Analyzing: %s", QUTF8(currentFile));
+       qDebug("Analyzing: %s", MUTILS_UTF8(currentFile));
        
        AudioFileModel file = analyzeFile(currentFile, &fileType);
 
@@ -133,12 +140,12 @@ void AnalyzeTask::run_ex(void)
                                }
                                else
                                {
-                                       qDebug("Rejected Avisynth file: %s", QUTF8(file.filePath()));
+                                       qDebug("Rejected Avisynth file: %s", MUTILS_UTF8(file.filePath()));
                                }
                        }
                        else
                        {
-                               qDebug("Rejected file of unknown type: %s", QUTF8(file.filePath()));
+                               qDebug("Rejected file of unknown type: %s", MUTILS_UTF8(file.filePath()));
                        }
                }
                break;
@@ -180,7 +187,7 @@ const AudioFileModel AnalyzeTask::analyzeFile(const QString &filePath, int *type
        params << QDir::toNativeSeparators(filePath);
        
        QProcess process;
-       lamexp_init_process(process, QFileInfo(m_mediaInfoBin).absolutePath());
+       MUtils::init_process(process, QFileInfo(m_mediaInfoBin).absolutePath());
 
        process.start(m_mediaInfoBin, params);
                
@@ -220,7 +227,7 @@ const AudioFileModel AnalyzeTask::analyzeFile(const QString &filePath, int *type
                        QString line = QString::fromUtf8(process.readLine().constData()).simplified();
                        if(!line.isEmpty())
                        {
-                               //qDebug("Line:%s", QUTF8(line));
+                               //qDebug("Line:%s", MUTILS_UTF8(line));
                                
                                int index = line.indexOf('=');
                                if(index > 0)
@@ -279,7 +286,7 @@ const AudioFileModel AnalyzeTask::analyzeFile(const QString &filePath, int *type
 
 void AnalyzeTask::updateInfo(AudioFileModel &audioFile, bool *skipNext, unsigned int *id_val, cover_t *coverType, QByteArray *coverData, const QString &key, const QString &value)
 {
-       //qWarning("'%s' -> '%s'", QUTF8(key), QUTF8(value));
+       //qWarning("'%s' -> '%s'", MUTILS_UTF8(key), MUTILS_UTF8(value));
        
        /*New Stream*/
        if(IS_KEY("Gen_ID") || IS_KEY("Aud_ID"))
@@ -394,7 +401,7 @@ void AnalyzeTask::updateInfo(AudioFileModel &audioFile, bool *skipNext, unsigned
                }
                else
                {
-                       qWarning("Unknown key '%s' with value '%s' found!", QUTF8(key), QUTF8(value));
+                       qWarning("Unknown key '%s' with value '%s' found!", MUTILS_UTF8(key), MUTILS_UTF8(value));
                }
                return;
        }
@@ -455,13 +462,13 @@ void AnalyzeTask::updateInfo(AudioFileModel &audioFile, bool *skipNext, unsigned
                }
                else
                {
-                       qWarning("Unknown key '%s' with value '%s' found!", QUTF8(key), QUTF8(value));
+                       qWarning("Unknown key '%s' with value '%s' found!", MUTILS_UTF8(key), MUTILS_UTF8(value));
                }
                return;
        }
 
        /*Section not recognized*/
-       qWarning("Unknown section: %s", QUTF8(key));
+       qWarning("Unknown section: %s", MUTILS_UTF8(key));
 }
 
 bool AnalyzeTask::checkFile_CDDA(QFile &file)
@@ -496,7 +503,7 @@ void AnalyzeTask::retrieveCover(AudioFileModel &audioFile, cover_t coverType, co
        
        if(!(QImage::fromData(coverData, extension.toUpper().toLatin1().constData()).isNull()))
        {
-               QFile coverFile(QString("%1/%2.%3").arg(lamexp_temp_folder2(), lamexp_rand_str(), extension));
+               QFile coverFile(QString("%1/%2.%3").arg(MUtils::temp_folder(), MUtils::rand_str(), extension));
                if(coverFile.open(QIODevice::WriteOnly))
                {
                        coverFile.write(coverData);
@@ -513,7 +520,7 @@ void AnalyzeTask::retrieveCover(AudioFileModel &audioFile, cover_t coverType, co
 bool AnalyzeTask::analyzeAvisynthFile(const QString &filePath, AudioFileModel &info)
 {
        QProcess process;
-       lamexp_init_process(process, QFileInfo(m_avs2wavBin).absolutePath());
+       MUtils::init_process(process, QFileInfo(m_avs2wavBin).absolutePath());
 
        process.start(m_avs2wavBin, QStringList() << QDir::toNativeSeparators(filePath) << "?");