diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-05-12 10:58:45 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-05-12 10:58:45 +0000 |
| commit | a1eccaf2c22bf4743a65e17c91bc2f5ab3a276a1 (patch) | |
| tree | 28c0ee87f74acde16004c02745accb43f83c45cb | |
| parent | 0367058afb69952beb4677ca41999a27fe9dff3d (diff) | |
| download | qmmp-a1eccaf2c22bf4743a65e17c91bc2f5ab3a276a1.tar.gz qmmp-a1eccaf2c22bf4743a65e17c91bc2f5ab3a276a1.tar.bz2 qmmp-a1eccaf2c22bf4743a65e17c91bc2f5ab3a276a1.zip | |
plugin cache: added decoder priority support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3443 90c681e8-e032-0410-971d-27865f9a5e38
| -rw-r--r-- | src/qmmp/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | src/qmmp/decoder.cpp | 9 | ||||
| -rw-r--r-- | src/qmmp/qmmp.pro | 4 | ||||
| -rw-r--r-- | src/qmmp/qmmpplugincache.cpp (renamed from src/qmmp/plugincache.cpp) | 27 | ||||
| -rw-r--r-- | src/qmmp/qmmpplugincache_p.h (renamed from src/qmmp/plugincache.h) | 8 |
5 files changed, 35 insertions, 16 deletions
diff --git a/src/qmmp/CMakeLists.txt b/src/qmmp/CMakeLists.txt index 325fec452..4710e15e0 100644 --- a/src/qmmp/CMakeLists.txt +++ b/src/qmmp/CMakeLists.txt @@ -57,6 +57,7 @@ SET(libqmmp_SRCS audioconverter.cpp eqsettings.cpp qmmpevents.cpp + qmmpplugincache.cpp ) SET(libqmmp_HDRS @@ -75,6 +76,7 @@ SET(libqmmp_HDRS replaygain_p.h fileinfo.h audioconverter_p.h + qmmpplugincache_p.h eqsettings.h decoder.h tagmodel.h @@ -84,6 +86,7 @@ SET(libqmmp_HDRS metadatamanager.h volume.h output.h + ) SET(libqmmp_MOC_HDRS diff --git a/src/qmmp/decoder.cpp b/src/qmmp/decoder.cpp index 197ba3569..a41efacdd 100644 --- a/src/qmmp/decoder.cpp +++ b/src/qmmp/decoder.cpp @@ -10,7 +10,7 @@ #include <QSettings> #include <QIODevice> #include <math.h> -#include "plugincache.h" +#include "qmmpplugincache_p.h" #include "buffer.h" #include "output.h" #include "visual.h" @@ -87,10 +87,10 @@ DecoderFactory *Decoder::m_lastFactory = 0; QList<QmmpPluginCache*> *Decoder::m_cache = 0; //sort cache items by priority -/*static bool _decoderLessComparator(DecoderFactory* f1, DecoderFactory* f2) +static bool _pluginCacheLessComparator(QmmpPluginCache* f1, QmmpPluginCache* f2) { - return f1->properties().priority < f2->properties().priority; -}*/ + return f1->priority() < f2->priority(); +} void Decoder::checkFactories() { @@ -112,6 +112,7 @@ void Decoder::checkFactories() m_cache->append(item); } m_disabledNames = settings.value("Decoder/disabled_plugins").toStringList(); + qSort(m_cache->begin(), m_cache->end(), _pluginCacheLessComparator); } QString Decoder::file(DecoderFactory *factory) diff --git a/src/qmmp/qmmp.pro b/src/qmmp/qmmp.pro index 41191d798..ee1188005 100644 --- a/src/qmmp/qmmp.pro +++ b/src/qmmp/qmmp.pro @@ -37,7 +37,7 @@ HEADERS += \ volumecontrol_p.h \ outputwriter_p.h \ recycler_p.h \ - plugincache.h + qmmpplugincache_p.h SOURCES += recycler.cpp \ decoder.cpp \ output.cpp \ @@ -66,7 +66,7 @@ SOURCES += recycler.cpp \ eqsettings.cpp \ qmmpevents.cpp \ outputwriter.cpp \ - plugincache.cpp + qmmpplugincache.cpp FORMS += unix:TARGET = ../../lib/qmmp win32:TARGET = ../../../bin/qmmp diff --git a/src/qmmp/plugincache.cpp b/src/qmmp/qmmpplugincache.cpp index a1eed8621..bc8b7b395 100644 --- a/src/qmmp/plugincache.cpp +++ b/src/qmmp/qmmpplugincache.cpp @@ -26,13 +26,14 @@ #include <QTranslator> #include "decoderfactory.h" #include "outputfactory.h" -#include "plugincache.h" +#include "qmmpplugincache_p.h" QmmpPluginCache::QmmpPluginCache(const QString &file, QSettings *settings) { m_error = false; m_instance = 0; m_decoderFactory = 0; + m_priority = 0; bool update = false; QFileInfo info(file); m_path = info.QFileInfo::canonicalFilePath(); @@ -42,12 +43,13 @@ QmmpPluginCache::QmmpPluginCache(const QString &file, QSettings *settings) if(settings->allKeys().contains(copy.remove(0,1))) { QStringList values = settings->value(m_path).toStringList(); - if(values.count() != 2) + if(values.count() != 3) update = true; else { m_shortName = values.at(0); - update = (info.lastModified().toString(Qt::ISODate) != values.at(1)); + m_priority = values.at(1).toInt(); + update = (info.lastModified().toString(Qt::ISODate) != values.at(2)); } } else @@ -59,24 +61,30 @@ QmmpPluginCache::QmmpPluginCache(const QString &file, QSettings *settings) if(DecoderFactory *factory = decoderFactory()) { m_shortName = factory->properties().shortName; + m_priority = factory->properties().priority; } /*else if(OutputFactory *factory = outputFactory()) { m_shortName = factory->properties().shortName; + m_priority = 0; }*/ else + { + qWarning("QmmpPluginCache: unknown plugin type: %s", qPrintable(m_path)); m_error = true; + } if (!m_error) { QStringList values; values << m_shortName; + values << QString::number(m_priority); values << info.lastModified().toString(Qt::ISODate); settings->setValue(m_path, values); - qDebug("PluginCache: added to cache: %s", qPrintable(m_path)); + qDebug("QmmpPluginCache: added cache item \"%s=%s\"", + qPrintable(info.fileName()), qPrintable(values.join(","))); } } - settings->endGroup(); } @@ -90,6 +98,11 @@ const QString QmmpPluginCache::file() const return m_path; } +int QmmpPluginCache::priority() const +{ + return m_priority; +} + DecoderFactory *QmmpPluginCache::decoderFactory() { if(!m_decoderFactory) @@ -115,11 +128,11 @@ QObject *QmmpPluginCache::instance() QPluginLoader loader(m_path); m_instance = loader.instance(); if (loader.isLoaded()) - qDebug("PluginCache: loaded plugin %s", qPrintable(QFileInfo(m_path).fileName())); + qDebug("QmmpPluginCache: loaded plugin %s", qPrintable(QFileInfo(m_path).fileName())); else { m_error = true; - qWarning("PluginCache: %s", qPrintable(loader.errorString ())); + qWarning("QmmpPluginCache: error: %s", qPrintable(loader.errorString ())); } return m_instance; } diff --git a/src/qmmp/plugincache.h b/src/qmmp/qmmpplugincache_p.h index b258fd5e2..028e1f561 100644 --- a/src/qmmp/plugincache.h +++ b/src/qmmp/qmmpplugincache_p.h @@ -18,8 +18,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef PLUGINCACHE_H -#define PLUGINCACHE_H +#ifndef QMMPPLUGINCACHE_P_H +#define QMMPPLUGINCACHE_P_H #include <QString> #include <QObject> @@ -37,6 +37,7 @@ public: const QString shortName() const; const QString file() const; + int priority() const; bool hasError() const; @@ -52,6 +53,7 @@ private: bool m_error; QObject *m_instance; DecoderFactory *m_decoderFactory; + int m_priority; }; -#endif // PLUGINCACHE_H +#endif // QMMPPLUGINCACHE_P_H |
