aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Input/sid/decoder_sid.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2013-04-27 06:39:56 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2013-04-27 06:39:56 +0000
commitc9da71f2828b7940f62e77615915c906c04f8af9 (patch)
tree75daeaed2dab09052831863d6de21e662b2ec2dd /src/plugins/Input/sid/decoder_sid.cpp
parentbf5722c868e1fa72980c5050c56effe66a70662e (diff)
downloadqmmp-c9da71f2828b7940f62e77615915c906c04f8af9.tar.gz
qmmp-c9da71f2828b7940f62e77615915c906c04f8af9.tar.bz2
qmmp-c9da71f2828b7940f62e77615915c906c04f8af9.zip
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
Diffstat (limited to 'src/plugins/Input/sid/decoder_sid.cpp')
-rw-r--r--src/plugins/Input/sid/decoder_sid.cpp100
1 files changed, 100 insertions, 0 deletions
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;
+}