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 int 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 bool waitForOneThread(unsigned long timeout
);
60 void fileSelected(const QString
&fileName
);
61 void fileAnalyzed(const AudioFileModel
&file
);
62 void progressValChanged(unsigned int);
63 void progressMaxChanged(unsigned int);
85 const AudioFileModel
analyzeFile(const QString
&filePath
, int *type
);
86 void updateInfo(AudioFileModel
&audioFile
, bool *skipNext
, unsigned int *id_val
, cover_t
*coverType
, QByteArray
*coverData
, const QString
&key
, const QString
&value
);
87 unsigned int parseYear(const QString
&str
);
88 unsigned int parseDuration(const QString
&str
);
89 bool checkFile_CDDA(QFile
&file
);
90 void retrieveCover(AudioFileModel
&audioFile
, cover_t coverType
, const QByteArray
&coverData
);
91 bool analyzeAvisynthFile(const QString
&filePath
, AudioFileModel
&info
);
92 void waitForPreviousThreads(void);
94 const unsigned __int64 m_threadIdx
;
96 const QString m_mediaInfoBin
;
97 const QString m_avs2wavBin
;
98 const QString m_templateFile
;
99 const QString m_inputFile
;
101 volatile bool *m_abortFlag
;
103 static QMutex s_waitMutex
;
104 static QWaitCondition s_waitCond
;
105 static unsigned __int64 s_threadIdx_created
;
106 static unsigned __int64 s_threadIdx_finished
;
108 static QReadWriteLock s_lock
;
109 static unsigned int s_filesAccepted
;
110 static unsigned int s_filesRejected
;
111 static unsigned int s_filesDenied
;
112 static unsigned int s_filesDummyCDDA
;
113 static unsigned int s_filesCueSheet
;
114 static QStringList s_recentlyAdded
;
115 static QStringList s_additionalFiles
;
117 static unsigned __int64
makeThreadIdx(void);