OSDN Git Service

Bump version.
[lamexp/LameXP.git] / src / Thread_FileAnalyzer.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
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, but always including the *additional*
9 // restrictions defined in the "License.txt" file.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 //
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
22
23 #pragma once
24
25 //#include "Model_AudioFile.h"
26
27 #include <QThread>
28 #include <QStringList>
29 #include <QHash>
30 #include <QSet>
31
32 class AudioFileModel;
33 class QFile;
34 class QDir;
35 class QFileInfo;
36 class LockedFile;
37 class QThreadPool;
38 class QElapsedTimer;
39
40 ////////////////////////////////////////////////////////////
41 // Splash Thread
42 ////////////////////////////////////////////////////////////
43
44 class FileAnalyzer: public QThread
45 {
46         Q_OBJECT
47
48 public:
49         FileAnalyzer(const QStringList &inputFiles);
50         ~FileAnalyzer(void);
51         void run();
52         bool getSuccess(void) { return (!isRunning()) && (!m_bAborted) && m_bSuccess; }
53
54         unsigned int filesAccepted(void);
55         unsigned int filesRejected(void);
56         unsigned int filesDenied(void);
57         unsigned int filesDummyCDDA(void);
58         unsigned int filesCueSheet(void);
59
60 signals:
61         void fileSelected(const QString &fileName);
62         void fileAnalyzed(const AudioFileModel &file);
63         void progressValChanged(unsigned int);
64         void progressMaxChanged(unsigned int);
65
66 public slots:
67         void abortProcess(void) { m_bAborted = true; exit(-1); }
68
69 private slots:
70         void initializeTasks(void);
71         void taskFileAnalyzed(const unsigned int taskId, const int fileType, const AudioFileModel &file);
72         void taskThreadFinish(const unsigned int);
73
74 private:
75         bool analyzeNextFile(void);
76         void handlePlaylistFiles(void);
77         bool createTemplate(void);
78
79         QThreadPool *m_pool;
80         QElapsedTimer *m_timer;
81
82         unsigned int m_tasksCounterNext;
83         unsigned int m_tasksCounterDone;
84         unsigned int m_completedCounter;
85
86         unsigned int m_filesAccepted;
87         unsigned int m_filesRejected;
88         unsigned int m_filesDenied;
89         unsigned int m_filesDummyCDDA;
90         unsigned int m_filesCueSheet;
91
92         QStringList m_inputFiles;
93         LockedFile *m_templateFile;
94
95         QSet<unsigned int> m_completedTaskIds;
96         QSet<unsigned int> m_runningTaskIds;
97         QHash<unsigned int, AudioFileModel> m_completedFiles;
98
99         static const char *g_tags_gen[];
100         static const char *g_tags_aud[];
101
102         volatile bool m_bAborted;
103         volatile bool m_bSuccess;
104 };