From c9da71f2828b7940f62e77615915c906c04f8af9 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sat, 27 Apr 2013 06:39:56 +0000 Subject: prepare for sid plugin implementation git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3405 90c681e8-e032-0410-971d-27865f9a5e38 --- qmmp.pri | 1 + src/app/app.pro | 1 - src/plugins/Input/Input.pro | 3 + src/plugins/Input/sid/decoder_sid.cpp | 100 ++++++++++++++++++++++++++++ src/plugins/Input/sid/decoder_sid.h | 56 ++++++++++++++++ src/plugins/Input/sid/decodersidfactory.cpp | 97 +++++++++++++++++++++++++++ src/plugins/Input/sid/decodersidfactory.h | 52 +++++++++++++++ src/plugins/Input/sid/sid.pro | 44 ++++++++++++ 8 files changed, 353 insertions(+), 1 deletion(-) create mode 100644 src/plugins/Input/sid/decoder_sid.cpp create mode 100644 src/plugins/Input/sid/decoder_sid.h create mode 100644 src/plugins/Input/sid/decodersidfactory.cpp create mode 100644 src/plugins/Input/sid/decodersidfactory.h create mode 100644 src/plugins/Input/sid/sid.pro diff --git a/qmmp.pri b/qmmp.pri index 821ffc1fb..33aca6869 100644 --- a/qmmp.pri +++ b/qmmp.pri @@ -32,6 +32,7 @@ CONFIG += PROJECTM_PLUGIN CONFIG += UDISKS_PLUGIN #deprecated CONFIG += UDISKS2_PLUGIN CONFIG += HAL_PLUGIN +CONFIG += SID_PLUGIN #additional features diff --git a/src/app/app.pro b/src/app/app.pro index 12362d557..dfad34bd9 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -22,7 +22,6 @@ QT += network unix:TARGET = ../../bin/qmmp win32:TARGET = ../../../bin/qmmp CONFIG += thread \ - release \ warn_on QMAKE_LIBDIR += ../../lib \ qmmpui diff --git a/src/plugins/Input/Input.pro b/src/plugins/Input/Input.pro index 4cdd778f0..f327264ce 100644 --- a/src/plugins/Input/Input.pro +++ b/src/plugins/Input/Input.pro @@ -45,5 +45,8 @@ contains(CONFIG, WILDMIDI_PLUGIN){ SUBDIRS += wildmidi } +contains(CONFIG, SID_PLUGIN){ + SUBDIRS += sid +} } diff --git a/src/plugins/Input/sid/decoder_sid.cpp b/src/plugins/Input/sid/decoder_sid.cpp new file mode 100644 index 000000000..bcd84e56b --- /dev/null +++ b/src/plugins/Input/sid/decoder_sid.cpp @@ -0,0 +1,100 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + + +#include "decoder_sid.h" + +// Decoder class +DecoderSID::DecoderSID(QIODevice *input) : Decoder(input) +{ + m_player = new sidplayfp(); +} + +DecoderSID::~DecoderSID() +{ + delete m_player; +} + +bool DecoderSID::initialize() +{ + QByteArray data = input()->readAll(); + + if(data.isEmpty()) + { + qWarning("DecoderSID: error: %s", qPrintable(input()->errorString())); + return false; + } + + SidTune *tune = new SidTune(0); + tune->read((const unsigned char*)data.constData(), data.size()); + tune->selectSong(0); + + if(!tune->getStatus()) + { + qWarning("DecoderSID: error: %s", tune->statusString()); + return false; + } + + sidbuilder *rs = new ReSIDfpBuilder("ReSIDfp builder"); + rs->create(m_player->info().maxsids()); + + SidConfig cfg = m_player->config(); + + cfg.frequency = 44100; + cfg.samplingMethod = SidConfig::INTERPOLATE; + cfg.playback = SidConfig::STEREO; + cfg.sidEmulation = rs; + + if(!m_player->config(cfg)) + { + qWarning("DecoderSID: unable to load config, error: %s", m_player->error()); + return false; + } + + if(!m_player->load(tune)) + { + qWarning("DecoderSID: unable to load tune, error: %s", m_player->error()); + return false; + } + + configure(44100, 2); + qDebug("DecoderSID: initialize succes"); + return true; +} + +qint64 DecoderSID::totalTime() +{ + return 0; +} + +void DecoderSID::seek(qint64 pos) +{ + Q_UNUSED(pos); +} + +int DecoderSID::bitrate() +{ + return 8; +} + +qint64 DecoderSID::read(char *data, qint64 size) +{ + return m_player->play((short *)data, size/2) * 2; +} diff --git a/src/plugins/Input/sid/decoder_sid.h b/src/plugins/Input/sid/decoder_sid.h new file mode 100644 index 000000000..39e62dc4f --- /dev/null +++ b/src/plugins/Input/sid/decoder_sid.h @@ -0,0 +1,56 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef DECODER_SID_H +#define DECODER_SID_H + +#include +#include +#include +#include +#include +#include +#include + +class GmeHelper; + +/** + @author Ilya Kotov +*/ +class DecoderSID : public Decoder +{ +public: + DecoderSID(QIODevice *input); + virtual ~DecoderSID(); + + // Standard Decoder API + bool initialize(); + qint64 totalTime(); + int bitrate(); + qint64 read(char *data, qint64 size); + void seek(qint64); + +private: + qint64 m_totalTime; + QString m_path; + sidplayfp *m_player; +}; + +#endif // DECODER_SID_H diff --git a/src/plugins/Input/sid/decodersidfactory.cpp b/src/plugins/Input/sid/decodersidfactory.cpp new file mode 100644 index 000000000..8971c9c2d --- /dev/null +++ b/src/plugins/Input/sid/decodersidfactory.cpp @@ -0,0 +1,97 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include +#include +#include "decoder_sid.h" +#include "decodersidfactory.h" + +// DecoderSIDFactory + +bool DecoderSIDFactory::supports(const QString &source) const +{ + foreach(QString filter, properties().filters) + { + QRegExp regexp(filter, Qt::CaseInsensitive, QRegExp::Wildcard); + if (regexp.exactMatch(source)) + return true; + } + return false; +} + +bool DecoderSIDFactory::canDecode(QIODevice *) const +{ + return false; +} + +const DecoderProperties DecoderSIDFactory::properties() const +{ + DecoderProperties properties; + properties.name = tr("SID Plugin"); + properties.filters << "*.sid"; + properties.description = tr("SID Files"); + //properties.contentType = ;*/ + properties.shortName = "sid"; + /*properties.hasAbout = true; + properties.hasSettings = false; + properties.noInput = true;*/ + return properties; +} + +Decoder *DecoderSIDFactory::create(const QString &path, QIODevice *input) +{ + return new DecoderSID(input); +} + +QList DecoderSIDFactory::createPlayList(const QString &fileName, bool useMetaData) +{ + QList list; + list << new FileInfo(fileName); + return list; +} + +MetaDataModel* DecoderSIDFactory::createMetaDataModel(const QString &path, QObject *parent) +{ + Q_UNUSED(path); + Q_UNUSED(parent); + return 0; +} + +void DecoderSIDFactory::showSettings(QWidget *parent) +{ + Q_UNUSED(parent); +} + +void DecoderSIDFactory::showAbout(QWidget *parent) +{ + /*-QMessageBox::about (parent, tr("About GME Audio Plugin"), + tr("Qmmp GME Audio Plugin")+"\n"+ + tr("This plugin uses Game_Music_Emu library to play game music files")+"\n"+ + tr("Written by: Ilya Kotov "));*/ +} + +QTranslator *DecoderSIDFactory::createTranslator(QObject *parent) +{ + QTranslator *translator = new QTranslator(parent); + QString locale = Qmmp::systemLanguageID(); + translator->load(QString(":/sid_plugin_") + locale); + return translator; +} +Q_EXPORT_PLUGIN2(gme,DecoderSIDFactory) diff --git a/src/plugins/Input/sid/decodersidfactory.h b/src/plugins/Input/sid/decodersidfactory.h new file mode 100644 index 000000000..2d076c8fe --- /dev/null +++ b/src/plugins/Input/sid/decodersidfactory.h @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#ifndef DECODERSIDFACTORY_H +#define DECODERSIDFACTORY_H + +#include +#include +#include +#include +#include +#include +#include +#include + +/** + @author Ilya Kotov +*/ +class DecoderSIDFactory : public QObject, DecoderFactory +{ + Q_OBJECT + Q_INTERFACES(DecoderFactory) + +public: + bool supports(const QString &source) const; + bool canDecode(QIODevice *input) const; + const DecoderProperties properties() const; + Decoder *create(const QString &path, QIODevice *input); + QList createPlayList(const QString &fileName, bool useMetaData); + MetaDataModel* createMetaDataModel(const QString &path, QObject *parent = 0); + void showSettings(QWidget *parent); + void showAbout(QWidget *parent); + QTranslator *createTranslator(QObject *parent); +}; + +#endif diff --git a/src/plugins/Input/sid/sid.pro b/src/plugins/Input/sid/sid.pro new file mode 100644 index 000000000..17bd121b0 --- /dev/null +++ b/src/plugins/Input/sid/sid.pro @@ -0,0 +1,44 @@ +include(../../plugins.pri) + +HEADERS += decodersidfactory.h \ + decoder_sid.h +SOURCES += decoder_sid.cpp \ + decodersidfactory.cpp +TARGET = $$PLUGINS_PREFIX/Input/sid +QMAKE_CLEAN = $$PLUGINS_PREFIX/Input/libsid.so +INCLUDEPATH += ../../../ +CONFIG += warn_on \ + plugin \ + link_pkgconfig +TEMPLATE = lib + +TRANSLATIONS = translations/sid_plugin_it.ts \ + translations/sid_plugin_ru.ts \ + translations/sid_plugin_cs.ts \ + translations/sid_plugin_de.ts \ + translations/sid_plugin_zh_CN.ts \ + translations/sid_plugin_zh_TW.ts \ + translations/sid_plugin_uk_UA.ts \ + translations/sid_plugin_pl.ts \ + translations/sid_plugin_tr.ts \ + translations/sid_plugin_lt.ts \ + translations/sid_plugin_nl.ts \ + translations/sid_plugin_ja.ts + +#RESOURCES = translations/translations.qrc + +unix{ + isEmpty (LIB_DIR):LIB_DIR = /lib + target.path = $$LIB_DIR/qmmp/Input + INSTALLS += target + QMAKE_LIBDIR += ../../../../lib + LIBS += -lqmmp + PKGCONFIG += libsidplayfp +} + +win32 { + HEADERS += ../../../../src/qmmp/metadatamodel.h \ + ../../../../src/qmmp/decoderfactory.h + QMAKE_LIBDIR += ../../../../bin + LIBS += -lqmmp0 -lsidplayfp.dll +} -- cgit v1.2.3-13-gbd6f