Actually make RegExp-based file renaming work.
[LameXP.git] / src / Thread_FileAnalyzer_Task.h
blob3cc867846efae74575092f754cb09377a258a119
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.
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.
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.
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
23 #pragma once
25 #include <QRunnable>
26 #include <QReadWriteLock>
27 #include <QWaitCondition>
28 #include <QStringList>
29 #include <QMutex>
30 #include <QSemaphore>
32 class AudioFileModel;
33 class QFile;
34 class QDir;
35 class QFileInfo;
36 class LockedFile;
38 ////////////////////////////////////////////////////////////
39 // Splash Thread
40 ////////////////////////////////////////////////////////////
42 class AnalyzeTask: public QObject, public QRunnable
44 Q_OBJECT
46 public:
47 AnalyzeTask(const int taskId, const QString &inputFile, const QString &templateFile, volatile bool *abortFlag);
48 ~AnalyzeTask(void);
50 enum fileType_t
52 fileTypeNormal = 0,
53 fileTypeCDDA = 1,
54 fileTypeDenied = 2,
55 fileTypeCueSheet = 3,
56 fileTypeUnknown = 4
59 //Wait until there is a free slot in the queue
60 static bool waitForFreeSlot(volatile bool *abortFlag);
62 signals:
63 void fileAnalyzed(const unsigned int taskId, const int fileType, const AudioFileModel &file);
64 void taskCompleted(const unsigned int taskId);
66 protected:
67 void run(void);
68 void run_ex(void);
70 private:
71 enum cover_t
73 coverNone,
74 coverJpeg,
75 coverPng,
76 coverGif
79 const AudioFileModel analyzeFile(const QString &filePath, int *type);
80 void updateInfo(AudioFileModel &audioFile, bool *skipNext, unsigned int *id_val, cover_t *coverType, QByteArray *coverData, const QString &key, const QString &value);
81 unsigned int parseYear(const QString &str);
82 unsigned int parseDuration(const QString &str);
83 bool checkFile_CDDA(QFile &file);
84 void retrieveCover(AudioFileModel &audioFile, cover_t coverType, const QByteArray &coverData);
85 bool analyzeAvisynthFile(const QString &filePath, AudioFileModel &info);
87 const unsigned int m_taskId;
89 const QString m_mediaInfoBin;
90 const QString m_avs2wavBin;
91 const QString m_templateFile;
92 const QString m_inputFile;
94 volatile bool *m_abortFlag;