1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
25 #include <QReadWriteLock>
26 #include <QWaitCondition>
27 #include <QStringList>
36 ////////////////////////////////////////////////////////////
38 ////////////////////////////////////////////////////////////
40 class AnalyzeTask: public QObject, public QRunnable
45 AnalyzeTask(const QString &inputFile, const QString &templateFile, volatile bool *abortFlag);
48 static void reset(void);
49 static void getAdditionalFiles(QStringList &fileList);
50 static unsigned int filesAccepted(void);
51 static unsigned int filesRejected(void);
52 static unsigned int filesDenied(void);
53 static unsigned int filesDummyCDDA(void);
54 static unsigned int filesCueSheet(void);
56 //Wait till the next running thread terminates
57 static __forceinline bool waitForOneThread(unsigned long timeout)
61 ret = s_waitCond.wait(&s_waitMutex, timeout);
67 void fileSelected(const QString &fileName);
68 void fileAnalyzed(const AudioFileModel &file);
90 const AudioFileModel analyzeFile(const QString &filePath, int *type);
91 void updateInfo(AudioFileModel &audioFile, bool *skipNext, unsigned int *id_val, cover_t *coverType, QByteArray *coverData, const QString &key, const QString &value);
92 unsigned int parseYear(const QString &str);
93 unsigned int parseDuration(const QString &str);
94 bool checkFile_CDDA(QFile &file);
95 void retrieveCover(AudioFileModel &audioFile, cover_t coverType, const QByteArray &coverData);
96 bool analyzeAvisynthFile(const QString &filePath, AudioFileModel &info);
97 void waitForPreviousThreads(void);
99 const unsigned __int64 m_threadIdx;
101 const QString m_mediaInfoBin;
102 const QString m_avs2wavBin;
103 const QString m_templateFile;
104 const QString m_inputFile;
106 volatile bool *m_abortFlag;
108 static QReadWriteLock s_lock;
109 static QMutex s_waitMutex;
110 static QWaitCondition s_waitCond;
112 static unsigned __int64 s_threadIdx_created;
113 static unsigned __int64 s_threadIdx_finished;
115 static QStringList s_recentlyAdded;
116 static QStringList s_additionalFiles;
118 static unsigned int s_filesAccepted;
119 static unsigned int s_filesRejected;
120 static unsigned int s_filesDenied;
121 static unsigned int s_filesDummyCDDA;
122 static unsigned int s_filesCueSheet;
124 static unsigned __int64 makeThreadIdx(void);