diff --git a/src/Config.h b/src/Config.h index 04c0810d..bb0cc8c7 100644 --- a/src/Config.h +++ b/src/Config.h @@ -35,7 +35,7 @@ #define VER_LAMEXP_MINOR_LO 2 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 4 -#define VER_LAMEXP_BUILD 1737 +#define VER_LAMEXP_BUILD 1741 #define VER_LAMEXP_CONFG 1700 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Decoder_AAC.cpp b/src/Decoder_AAC.cpp index 8a8de54b..3d3ac3bb 100644 --- a/src/Decoder_AAC.cpp +++ b/src/Decoder_AAC.cpp @@ -138,7 +138,18 @@ bool AACDecoder::isFormatSupported(const QString &containerType, const QString & return false; } -QStringList AACDecoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *AACDecoder::supportedTypes(void) { - return QStringList() << "Advanced Audio Coding (*.aac *.mp4 *.m4a)"; + static const char *exts[] = + { + "mp4", "m4a", "aac", NULL + }; + + static const supportedType_t s_supportedTypes[] = + { + { "Advanced Audio Coding", exts }, + { NULL, NULL } + }; + + return s_supportedTypes; } diff --git a/src/Decoder_AAC.h b/src/Decoder_AAC.h index 467074cc..84c3904e 100644 --- a/src/Decoder_AAC.h +++ b/src/Decoder_AAC.h @@ -32,7 +32,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); private: const QString m_binary; diff --git a/src/Decoder_AC3.cpp b/src/Decoder_AC3.cpp index 2ab2469d..5d57605f 100644 --- a/src/Decoder_AC3.cpp +++ b/src/Decoder_AC3.cpp @@ -152,8 +152,20 @@ bool AC3Decoder::isFormatSupported(const QString &containerType, const QString & return false; } -QStringList AC3Decoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *AC3Decoder::supportedTypes(void) { - return QStringList() << "AC-3 / ATSC A/52 (*.ac3 *.eac3 *.wav)" << "Digital Theater System (*.dts)"; -} + static const char *exts[][4] = + { + { "ac3", "eac3", "wav", NULL }, + { "dts", "wav", NULL } + }; + static const supportedType_t s_supportedTypes[] = + { + { "AC-3 / ATSC A/52", exts[0] }, + { "Digital Theater System", exts[1] }, + { NULL, NULL } + }; + + return s_supportedTypes; +} diff --git a/src/Decoder_AC3.h b/src/Decoder_AC3.h index 980d58f4..92db7ff8 100644 --- a/src/Decoder_AC3.h +++ b/src/Decoder_AC3.h @@ -32,7 +32,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); private: const QString m_binary; diff --git a/src/Decoder_ADPCM.cpp b/src/Decoder_ADPCM.cpp index 2b2c6105..58463048 100644 --- a/src/Decoder_ADPCM.cpp +++ b/src/Decoder_ADPCM.cpp @@ -143,7 +143,22 @@ bool ADPCMDecoder::isFormatSupported(const QString &containerType, const QString return false; } -QStringList ADPCMDecoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *ADPCMDecoder::supportedTypes(void) { - return QStringList() << "Microsoft ADPCM (*.wav)" << "Apple/SGI AIFF (*.aif *.aiff)" << "Sun/NeXT Au (*.au *.snd)"; + static const char *exts[][3] = + { + { "wav", NULL }, + { "aif", "aiff", NULL }, + { "au" , "snd", NULL } + }; + + static const supportedType_t s_supportedTypes[] = + { + { "Microsoft ADPCM", exts[0] }, + { "Apple/SGI AIFF", exts[1] }, + { "Sun/NeXT Au", exts[2] }, + { NULL, NULL } + }; + + return s_supportedTypes; } diff --git a/src/Decoder_ADPCM.h b/src/Decoder_ADPCM.h index d55ae7d0..fea1a6fe 100644 --- a/src/Decoder_ADPCM.h +++ b/src/Decoder_ADPCM.h @@ -32,7 +32,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); private: const QString m_binary; diff --git a/src/Decoder_ALAC.cpp b/src/Decoder_ALAC.cpp index d0ceedad..38d6b864 100644 --- a/src/Decoder_ALAC.cpp +++ b/src/Decoder_ALAC.cpp @@ -146,7 +146,18 @@ bool ALACDecoder::isFormatSupported(const QString &containerType, const QString return false; } -QStringList ALACDecoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *ALACDecoder::supportedTypes(void) { - return QStringList() << "Apple Lossless (*.mp4 *.m4a)"; + static const char *exts[] = + { + "mp4", "m4a", NULL + }; + + static const supportedType_t s_supportedTypes[] = + { + { "Apple Lossless", exts }, + { NULL, NULL } + }; + + return s_supportedTypes; } diff --git a/src/Decoder_ALAC.h b/src/Decoder_ALAC.h index 8513990b..75220baa 100644 --- a/src/Decoder_ALAC.h +++ b/src/Decoder_ALAC.h @@ -32,7 +32,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); private: const QString m_binary; diff --git a/src/Decoder_Abstract.cpp b/src/Decoder_Abstract.cpp index f294b1f2..2d34e9b5 100644 --- a/src/Decoder_Abstract.cpp +++ b/src/Decoder_Abstract.cpp @@ -22,7 +22,7 @@ #include "Decoder_Abstract.h" -#include +#include AbstractDecoder::AbstractDecoder(void) { @@ -46,7 +46,7 @@ bool AbstractDecoder::isDecoderAvailable(void) return true; } -QStringList AbstractDecoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *AbstractDecoder::supportedTypes(void) { - return QStringList(); -} + MUTILS_THROW("This function must be re-implemented in sub-classes!"); +} \ No newline at end of file diff --git a/src/Decoder_Abstract.h b/src/Decoder_Abstract.h index 8791d8b6..bb4cee5b 100644 --- a/src/Decoder_Abstract.h +++ b/src/Decoder_Abstract.h @@ -32,10 +32,13 @@ public: AbstractDecoder(void); virtual ~AbstractDecoder(void); + //Types + typedef struct { const char *const name; const char *const *const exts; } supportedType_t; + //Internal decoder API virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag) = 0; static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isDecoderAvailable(void); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); }; diff --git a/src/Decoder_Avisynth.cpp b/src/Decoder_Avisynth.cpp index f48d2e6f..e72a52db 100644 --- a/src/Decoder_Avisynth.cpp +++ b/src/Decoder_Avisynth.cpp @@ -134,7 +134,18 @@ bool AvisynthDecoder::isFormatSupported(const QString &containerType, const QStr return false; } -QStringList AvisynthDecoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *AvisynthDecoder::supportedTypes(void) { - return QStringList() << "Avisynth Script (*.avs)"; + static const char *exts[] = + { + "avs", NULL + }; + + static const supportedType_t s_supportedTypes[] = + { + { "Avisynth Script", exts }, + { NULL, NULL } + }; + + return s_supportedTypes; } diff --git a/src/Decoder_Avisynth.h b/src/Decoder_Avisynth.h index 87e8f45c..e2741038 100644 --- a/src/Decoder_Avisynth.h +++ b/src/Decoder_Avisynth.h @@ -32,7 +32,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); private: const QString m_binary; diff --git a/src/Decoder_FLAC.cpp b/src/Decoder_FLAC.cpp index 11478cac..64e6ae34 100644 --- a/src/Decoder_FLAC.cpp +++ b/src/Decoder_FLAC.cpp @@ -132,7 +132,18 @@ bool FLACDecoder::isFormatSupported(const QString &containerType, const QString return false; } -QStringList FLACDecoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *FLACDecoder::supportedTypes(void) { - return QStringList() << "Free Lossless Audio Codec (*.flac *.fla)"; + static const char *exts[] = + { + "fla", "flac", NULL + }; + + static const supportedType_t s_supportedTypes[] = + { + { "Free Lossless Audio Codec", exts }, + { NULL, NULL } + }; + + return s_supportedTypes; } diff --git a/src/Decoder_FLAC.h b/src/Decoder_FLAC.h index acb5ffcc..20ff65dc 100644 --- a/src/Decoder_FLAC.h +++ b/src/Decoder_FLAC.h @@ -32,7 +32,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); private: const QString m_binary; diff --git a/src/Decoder_MAC.cpp b/src/Decoder_MAC.cpp index bbdb67af..8c560e43 100644 --- a/src/Decoder_MAC.cpp +++ b/src/Decoder_MAC.cpp @@ -137,7 +137,18 @@ bool MACDecoder::isFormatSupported(const QString &containerType, const QString & return false; } -QStringList MACDecoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *MACDecoder::supportedTypes(void) { - return QStringList() << "Monkey's Audio (*.ape)"; + static const char *exts[] = + { + "ape", NULL + }; + + static const supportedType_t s_supportedTypes[] = + { + { "Monkey's Audio", exts }, + { NULL, NULL } + }; + + return s_supportedTypes; } diff --git a/src/Decoder_MAC.h b/src/Decoder_MAC.h index 5bb34490..66589308 100644 --- a/src/Decoder_MAC.h +++ b/src/Decoder_MAC.h @@ -32,7 +32,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); private: const QString m_binary; diff --git a/src/Decoder_MP3.cpp b/src/Decoder_MP3.cpp index 31fdc4f7..0a0162f8 100644 --- a/src/Decoder_MP3.cpp +++ b/src/Decoder_MP3.cpp @@ -153,8 +153,22 @@ bool MP3Decoder::isFormatSupported(const QString &containerType, const QString & return false; } -QStringList MP3Decoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *MP3Decoder::supportedTypes(void) { - return QStringList() << "MPEG Audio Layer III (*.mp3 *.mpa)" << "MPEG Audio Layer II (*.mp2 *.mpa)" << "MPEG Audio Layer I ( *.mp1 *.mpa)"; -} + static const char *exts[][3] = + { + { "mp3", "mpa", NULL }, + { "mp2", "mpa", NULL }, + { "mp1", "mpa", NULL } + }; + static const supportedType_t s_supportedTypes[] = + { + { "MPEG Audio Layer III", exts[0] }, + { "MPEG Audio Layer II", exts[1] }, + { "MPEG Audio Layer I", exts[2] }, + { NULL, NULL } + }; + + return s_supportedTypes; +} diff --git a/src/Decoder_MP3.h b/src/Decoder_MP3.h index 3bc7b61a..89e74c62 100644 --- a/src/Decoder_MP3.h +++ b/src/Decoder_MP3.h @@ -32,7 +32,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); private: const QString m_binary; diff --git a/src/Decoder_Musepack.cpp b/src/Decoder_Musepack.cpp index a3b095e5..1e0f77c7 100644 --- a/src/Decoder_Musepack.cpp +++ b/src/Decoder_Musepack.cpp @@ -138,7 +138,18 @@ bool MusepackDecoder::isFormatSupported(const QString &containerType, const QStr return false; } -QStringList MusepackDecoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *MusepackDecoder::supportedTypes(void) { - return QStringList() << "Musepack (*.mpc *.mpp *.mp+)"; + static const char *exts[] = + { + "mpc", "mpp", "mp+", NULL + }; + + static const supportedType_t s_supportedTypes[] = + { + { "Musepack", exts }, + { NULL, NULL } + }; + + return s_supportedTypes; } diff --git a/src/Decoder_Musepack.h b/src/Decoder_Musepack.h index 7f5db2c9..9efa6f3d 100644 --- a/src/Decoder_Musepack.h +++ b/src/Decoder_Musepack.h @@ -32,7 +32,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); private: const QString m_binary; diff --git a/src/Decoder_Opus.cpp b/src/Decoder_Opus.cpp index 1aeeffb1..47a9dae2 100644 --- a/src/Decoder_Opus.cpp +++ b/src/Decoder_Opus.cpp @@ -146,8 +146,18 @@ bool OpusDecoder::isFormatSupported(const QString &containerType, const QString return false; } -QStringList OpusDecoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *OpusDecoder::supportedTypes(void) { - return QStringList() << "Opus Audio Codec (*.opus *.ogg)"; -} + static const char *exts[] = + { + "opus", "ogg", NULL + }; + static const supportedType_t s_supportedTypes[] = + { + { "Opus Audio Codec", exts }, + { NULL, NULL } + }; + + return s_supportedTypes; +} diff --git a/src/Decoder_Opus.h b/src/Decoder_Opus.h index 99ce15a2..f9fbf8fa 100644 --- a/src/Decoder_Opus.h +++ b/src/Decoder_Opus.h @@ -32,7 +32,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); static void setDisableResampling(bool disableResample) { m_disableResampling = disableResample; } diff --git a/src/Decoder_Shorten.cpp b/src/Decoder_Shorten.cpp index 56849075..0cda74bf 100644 --- a/src/Decoder_Shorten.cpp +++ b/src/Decoder_Shorten.cpp @@ -128,7 +128,18 @@ bool ShortenDecoder::isFormatSupported(const QString &containerType, const QStri return false; } -QStringList ShortenDecoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *ShortenDecoder::supportedTypes(void) { - return QStringList() << "Shorten (*.shn)"; + static const char *exts[] = + { + "shn", NULL + }; + + static const supportedType_t s_supportedTypes[] = + { + { "Shorten", exts }, + { NULL, NULL } + }; + + return s_supportedTypes; } diff --git a/src/Decoder_Shorten.h b/src/Decoder_Shorten.h index 7dc35fd9..ddd3ec9d 100644 --- a/src/Decoder_Shorten.h +++ b/src/Decoder_Shorten.h @@ -32,7 +32,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); private: const QString m_binary; diff --git a/src/Decoder_Speex.cpp b/src/Decoder_Speex.cpp index bc0cfcaa..a8e3933b 100644 --- a/src/Decoder_Speex.cpp +++ b/src/Decoder_Speex.cpp @@ -130,7 +130,18 @@ bool SpeexDecoder::isFormatSupported(const QString &containerType, const QString return false; } -QStringList SpeexDecoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *SpeexDecoder::supportedTypes(void) { - return QStringList() << "Speex (*.spx *.ogg)"; + static const char *exts[] = + { + "spx", "ogg", NULL + }; + + static const supportedType_t s_supportedTypes[] = + { + { "Speex", exts }, + { NULL, NULL } + }; + + return s_supportedTypes; } diff --git a/src/Decoder_Speex.h b/src/Decoder_Speex.h index 91bd8224..e0debf2c 100644 --- a/src/Decoder_Speex.h +++ b/src/Decoder_Speex.h @@ -32,7 +32,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); private: const QString m_binary; diff --git a/src/Decoder_TTA.cpp b/src/Decoder_TTA.cpp index dd42568f..f4e1f47c 100644 --- a/src/Decoder_TTA.cpp +++ b/src/Decoder_TTA.cpp @@ -133,7 +133,18 @@ bool TTADecoder::isFormatSupported(const QString &containerType, const QString & return false; } -QStringList TTADecoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *TTADecoder::supportedTypes(void) { - return QStringList() << "The True Audio (*.tta)"; + static const char *exts[] = + { + "tta", NULL + }; + + static const supportedType_t s_supportedTypes[] = + { + { "The True Audio", exts }, + { NULL, NULL } + }; + + return s_supportedTypes; } diff --git a/src/Decoder_TTA.h b/src/Decoder_TTA.h index 7d34517e..bdedc8cb 100644 --- a/src/Decoder_TTA.h +++ b/src/Decoder_TTA.h @@ -32,7 +32,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); private: const QString m_binary; diff --git a/src/Decoder_Vorbis.cpp b/src/Decoder_Vorbis.cpp index 828bd9fd..5f6481bc 100644 --- a/src/Decoder_Vorbis.cpp +++ b/src/Decoder_Vorbis.cpp @@ -136,7 +136,18 @@ bool VorbisDecoder::isFormatSupported(const QString &containerType, const QStrin return false; } -QStringList VorbisDecoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *VorbisDecoder::supportedTypes(void) { - return QStringList() << "Ogg Vorbis (*.ogg *.ogm)"; + static const char *exts[] = + { + "ogg", "ogx", "ogm", NULL + }; + + static const supportedType_t s_supportedTypes[] = + { + { "Ogg Vorbis", exts }, + { NULL, NULL } + }; + + return s_supportedTypes; } diff --git a/src/Decoder_Vorbis.h b/src/Decoder_Vorbis.h index 5e115856..029ac03f 100644 --- a/src/Decoder_Vorbis.h +++ b/src/Decoder_Vorbis.h @@ -32,7 +32,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); private: const QString m_binary; diff --git a/src/Decoder_WMA.cpp b/src/Decoder_WMA.cpp index 0c4957a7..f64c9bac 100644 --- a/src/Decoder_WMA.cpp +++ b/src/Decoder_WMA.cpp @@ -136,7 +136,18 @@ bool WMADecoder::isFormatSupported(const QString &containerType, const QString & return false; } -QStringList WMADecoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *WMADecoder::supportedTypes(void) { - return QStringList() << "Windows Media Audio (*.wma)"; + static const char *exts[] = + { + "wma", "asf", NULL + }; + + static const supportedType_t s_supportedTypes[] = + { + { "Windows Media Audio", exts }, + { NULL, NULL } + }; + + return s_supportedTypes; } diff --git a/src/Decoder_WMA.h b/src/Decoder_WMA.h index 74d3b144..8444e5d4 100644 --- a/src/Decoder_WMA.h +++ b/src/Decoder_WMA.h @@ -34,7 +34,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); private: const QString m_binary; diff --git a/src/Decoder_WavPack.cpp b/src/Decoder_WavPack.cpp index e2f5cd75..3e012acf 100644 --- a/src/Decoder_WavPack.cpp +++ b/src/Decoder_WavPack.cpp @@ -137,7 +137,18 @@ bool WavPackDecoder::isFormatSupported(const QString &containerType, const QStri return false; } -QStringList WavPackDecoder::supportedTypes(void) +const AbstractDecoder::supportedType_t *WavPackDecoder::supportedTypes(void) { - return QStringList() << "WavPack Hybrid Lossless Audio (*.wv)"; + static const char *exts[] = + { + "wv", NULL + }; + + static const supportedType_t s_supportedTypes[] = + { + { "WavPack Hybrid Lossless Audio", exts }, + { NULL, NULL } + }; + + return s_supportedTypes; } diff --git a/src/Decoder_WavPack.h b/src/Decoder_WavPack.h index 8c277449..bde65c6a 100644 --- a/src/Decoder_WavPack.h +++ b/src/Decoder_WavPack.h @@ -32,7 +32,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); private: const QString m_binary; diff --git a/src/Decoder_Wave.cpp b/src/Decoder_Wave.cpp index 1a61c716..5159db15 100644 --- a/src/Decoder_Wave.cpp +++ b/src/Decoder_Wave.cpp @@ -68,24 +68,6 @@ bool WaveDecoder::decode(const QString &sourceFile, const QString &outputFile, v return okay; } -bool WaveDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion) -{ - if(containerType.compare("Wave", Qt::CaseInsensitive) == 0) - { - if(formatType.compare("PCM", Qt::CaseInsensitive) == 0) - { - return true; - } - } - - return false; -} - -QStringList WaveDecoder::supportedTypes(void) -{ - return QStringList() << "Waveform Audio File (*.wav)"; -} - bool WaveDecoder::progressHandler(const double &progress, void *const data) { if(data) @@ -101,3 +83,32 @@ void WaveDecoder::updateProgress(const double &progress) { emit statusUpdated(qBound(0, qRound(progress * 100.0), 100)); } + +bool WaveDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion) +{ + if(containerType.compare("Wave", Qt::CaseInsensitive) == 0) + { + if(formatType.compare("PCM", Qt::CaseInsensitive) == 0) + { + return true; + } + } + + return false; +} + +const AbstractDecoder::supportedType_t *WaveDecoder::supportedTypes(void) +{ + static const char *exts[] = + { + "wav", NULL + }; + + static const supportedType_t s_supportedTypes[] = + { + { "Waveform Audio File", exts }, + { NULL, NULL } + }; + + return s_supportedTypes; +} diff --git a/src/Decoder_Wave.h b/src/Decoder_Wave.h index cb0105c8..89d8d5c5 100644 --- a/src/Decoder_Wave.h +++ b/src/Decoder_Wave.h @@ -33,7 +33,7 @@ public: virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList supportedTypes(void); + static const supportedType_t *supportedTypes(void); static bool progressHandler(const double &progress, void *const data); void updateProgress(const double &progress); diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 6125855f..5b502e40 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -2373,20 +2373,8 @@ void MainWindow::openFolderActionActivated(void) return; } - QRegExp regExp("\\((.+)\\)", Qt::CaseInsensitive); - const QStringList supportedTypes = DecoderRegistry::getSupportedTypes(); - QStringList filterItems("*.*"); - for(QStringList::ConstIterator iter = supportedTypes.constBegin(); iter != supportedTypes.constEnd(); iter++) - { - if(regExp.lastIndexIn(*iter) >= 0) - { - const QStringList extensions = regExp.cap(1).split(' ', QString::SkipEmptyParts); - for(QStringList::ConstIterator iter2 = extensions.constBegin(); iter2 != extensions.constEnd(); iter2++) - { - if(!filterItems.contains((*iter2), Qt::CaseInsensitive)) filterItems << (*iter2); - } - } - } + QStringList filterItems = DecoderRegistry::getSupportedExts(); + filterItems.prepend("*.*"); bool okay; QString filterStr = QInputDialog::getItem(this, tr("Filter Files"), tr("Select filename filter:"), filterItems, 0, false, &okay).trimmed(); @@ -2395,10 +2383,10 @@ void MainWindow::openFolderActionActivated(void) return; } - QRegExp regExp2("\\*\\.([A-Za-z0-9]+)", Qt::CaseInsensitive); - if(regExp2.lastIndexIn(filterStr) >= 0) + QRegExp regExp("\\*\\.([A-Za-z0-9]+)", Qt::CaseInsensitive); + if(regExp.lastIndexIn(filterStr) >= 0) { - filterStr = regExp2.cap(1).trimmed(); + filterStr = regExp.cap(1).trimmed(); } else { diff --git a/src/PlaylistImporter.cpp b/src/PlaylistImporter.cpp index a34fa6dc..60d8d58e 100644 --- a/src/PlaylistImporter.cpp +++ b/src/PlaylistImporter.cpp @@ -56,9 +56,6 @@ g_xmlEscapeSequence[] = {NULL, NULL} }; -const char *PlaylistImporter::supportedExtensions = "*.m3u *.m3u8 *.pls *.asx *.wpl"; - - //////////////////////////////////////////////////////////// // Public Functions //////////////////////////////////////////////////////////// @@ -378,3 +375,13 @@ QString &PlaylistImporter::unescapeXml(QString &str) return str; } + +const char *const *const PlaylistImporter::getSupportedExtensions(void) +{ + static const char *const s_supportedExtensions[] = + { + "m3u", "m3u8", "pls", "asx", "wpl", NULL + }; + + return s_supportedExtensions; +} diff --git a/src/PlaylistImporter.h b/src/PlaylistImporter.h index a42a2f32..93c7b83a 100644 --- a/src/PlaylistImporter.h +++ b/src/PlaylistImporter.h @@ -39,8 +39,8 @@ public: wplPlaylist }; - static const char *supportedExtensions; static bool importPlaylist(QStringList &fileList, const QString &playlistFile); + static const char *const *const getSupportedExtensions(void); private: PlaylistImporter(void) {} diff --git a/src/Registry_Decoder.cpp b/src/Registry_Decoder.cpp index 2a812692..1e9ef46a 100644 --- a/src/Registry_Decoder.cpp +++ b/src/Registry_Decoder.cpp @@ -22,6 +22,7 @@ #include "Registry_Decoder.h" +//Internal #include "Decoder_AAC.h" #include "Decoder_AC3.h" #include "Decoder_ADPCM.h" @@ -42,12 +43,31 @@ #include "PlaylistImporter.h" #include "Model_Settings.h" +//MUtils +#include + +//Qt #include #include +#include #include #define PROBE_DECODER(DEC) if(DEC::isDecoderAvailable() && DEC::isFormatSupported(containerType, containerProfile, formatType, formatProfile, formatVersion)) { return new DEC(); } -#define GET_FILETYPES(DEC) (DEC::isDecoderAvailable() ? DEC::supportedTypes() : QStringList()) + +#define GET_FILETYPES(LIST, DEC) do \ +{ \ + if(DEC::isDecoderAvailable()) (LIST) << DEC::supportedTypes(); \ +} \ +while(0) + +QMutex DecoderRegistry::m_lock(QMutex::Recursive); +QScopedPointer DecoderRegistry::m_supportedExts; +QScopedPointer DecoderRegistry::m_supportedTypes; +QScopedPointer DecoderRegistry::m_availableTypes; + +//////////////////////////////////////////////////////////// +// Public Functions +//////////////////////////////////////////////////////////// AbstractDecoder *DecoderRegistry::lookup(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion) { @@ -72,54 +92,114 @@ AbstractDecoder *DecoderRegistry::lookup(const QString &containerType, const QSt return NULL; } -QStringList DecoderRegistry::getSupportedTypes(void) +const QStringList &DecoderRegistry::getSupportedExts(void) { - QStringList types; + QMutexLocker locker(&m_lock); - types << GET_FILETYPES(WaveDecoder); - types << GET_FILETYPES(MP3Decoder); - types << GET_FILETYPES(VorbisDecoder); - types << GET_FILETYPES(AACDecoder); - types << GET_FILETYPES(AC3Decoder); - types << GET_FILETYPES(FLACDecoder); - types << GET_FILETYPES(WavPackDecoder); - types << GET_FILETYPES(MusepackDecoder); - types << GET_FILETYPES(ShortenDecoder); - types << GET_FILETYPES(MACDecoder); - types << GET_FILETYPES(TTADecoder); - types << GET_FILETYPES(SpeexDecoder); - types << GET_FILETYPES(ALACDecoder); - types << GET_FILETYPES(WMADecoder); - types << GET_FILETYPES(ADPCMDecoder); - types << GET_FILETYPES(OpusDecoder); - types << GET_FILETYPES(AvisynthDecoder); - - QStringList extensions; - extensions << QString(PlaylistImporter::supportedExtensions).split(" ", QString::SkipEmptyParts); - QRegExp regExp("\\((.+)\\)", Qt::CaseInsensitive); - - for(int i = 0; i < types.count(); i++) + if(!m_supportedExts.isNull()) { - if(regExp.lastIndexIn(types.at(i)) >= 0) + return (*m_supportedExts); + } + + m_supportedExts.reset(new QStringList()); + + const typeList_t &types = getAvailableDecoderTypes(); + for(QList::ConstIterator iter = types.constBegin(); iter != types.constEnd(); iter++) + { + for(size_t i = 0; (*iter)[i].name; i++) { - extensions << regExp.cap(1).split(" ", QString::SkipEmptyParts); + for(size_t j = 0; (*iter)[i].exts[j]; j++) + { + const QString ext = QString().sprintf("*.%s", (*iter)[i].exts[j]); + if(!m_supportedExts->contains(ext, Qt::CaseInsensitive)) + { + (*m_supportedExts) << ext; + } + } } } - if(!extensions.empty()) - { - extensions.removeDuplicates(); - extensions.sort(); - types.prepend(QString("%1 (%2)").arg(tr("All supported types"), extensions.join(" "))); - } - - types << QString("%1 (%2)").arg(tr("Playlists"), PlaylistImporter::supportedExtensions); - types << QString("%1 (*.*)").arg(tr("All files")); + m_supportedExts->sort(); + return (*m_supportedExts); +} - return types; +const QStringList &DecoderRegistry::getSupportedTypes(void) +{ + QMutexLocker locker(&m_lock); + + if(!m_supportedTypes.isNull()) + { + return (*m_supportedTypes); + } + + m_supportedTypes.reset(new QStringList()); + + const typeList_t &types = getAvailableDecoderTypes(); + for(QList::ConstIterator iter = types.constBegin(); iter != types.constEnd(); iter++) + { + for(size_t i = 0; (*iter)[i].name; i++) + { + QStringList extList; + for(size_t j = 0; (*iter)[i].exts[j]; j++) + { + extList << QString().sprintf("*.%s", (*iter)[i].exts[j]); + } + if(!extList.isEmpty()) + { + (*m_supportedTypes) << QString("%1 (%2)").arg(QString::fromLatin1((*iter)[i].name), extList.join(" ")); + } + } + } + + QStringList playlistExts; + const char *const *const playlistPtr = PlaylistImporter::getSupportedExtensions(); + for(size_t i = 0; playlistPtr[i]; i++) + { + playlistExts << QString().sprintf("*.%s", playlistPtr[i]); + } + + (*m_supportedTypes) << QString("%1 (%2)").arg(tr("Playlists"), playlistExts.join(" ")); + (*m_supportedTypes) << QString("%1 (*.*)").arg(tr("All files")); + m_supportedTypes->prepend(QString("%1 (%2 %3)").arg(tr("All supported types"), getSupportedExts().join(" "), playlistExts.join(" "))); + + return (*m_supportedTypes); } void DecoderRegistry::configureDecoders(const SettingsModel *settings) { OpusDecoder::setDisableResampling(settings->opusDisableResample()); } + +//////////////////////////////////////////////////////////// +// Private Functions +//////////////////////////////////////////////////////////// + +const DecoderRegistry::typeList_t &DecoderRegistry::getAvailableDecoderTypes(void) +{ + if(!m_availableTypes.isNull()) + { + return (*m_availableTypes); + } + + m_availableTypes.reset(new typeList_t()); + + GET_FILETYPES(*m_availableTypes, WaveDecoder); + GET_FILETYPES(*m_availableTypes, MP3Decoder); + GET_FILETYPES(*m_availableTypes, VorbisDecoder); + GET_FILETYPES(*m_availableTypes, AACDecoder); + GET_FILETYPES(*m_availableTypes, AC3Decoder); + GET_FILETYPES(*m_availableTypes, FLACDecoder); + GET_FILETYPES(*m_availableTypes, WavPackDecoder); + GET_FILETYPES(*m_availableTypes, MusepackDecoder); + GET_FILETYPES(*m_availableTypes, ShortenDecoder); + GET_FILETYPES(*m_availableTypes, MACDecoder); + GET_FILETYPES(*m_availableTypes, TTADecoder); + GET_FILETYPES(*m_availableTypes, SpeexDecoder); + GET_FILETYPES(*m_availableTypes, ALACDecoder); + GET_FILETYPES(*m_availableTypes, WMADecoder); + GET_FILETYPES(*m_availableTypes, ADPCMDecoder); + GET_FILETYPES(*m_availableTypes, OpusDecoder); + GET_FILETYPES(*m_availableTypes, AvisynthDecoder); + + return (*m_availableTypes); +} diff --git a/src/Registry_Decoder.h b/src/Registry_Decoder.h index b7535ae4..1755bd12 100644 --- a/src/Registry_Decoder.h +++ b/src/Registry_Decoder.h @@ -23,10 +23,11 @@ #pragma once #include +#include "Decoder_AAC.h" class QString; class QStringList; -class AbstractDecoder; +class QMutex; class SettingsModel; class DecoderRegistry : public QObject @@ -36,5 +37,16 @@ class DecoderRegistry : public QObject public: static void configureDecoders(const SettingsModel *settings); static AbstractDecoder *lookup(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); - static QStringList getSupportedTypes(void); + static const QStringList &getSupportedExts(void); + static const QStringList &getSupportedTypes(void); + +private: + typedef QList typeList_t; + + static QMutex m_lock; + static QScopedPointer m_supportedExts; + static QScopedPointer m_supportedTypes; + static QScopedPointer m_availableTypes; + + static const typeList_t &getAvailableDecoderTypes(void); };