From e48a196c880d9f92804c6e1e3ea5631ae2017dd1 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sun, 12 Oct 2008 19:48:39 +0000 Subject: enabled all input plugins git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@581 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/Input/modplug/decoder_modplug.cpp | 58 ++++++++++------------ src/plugins/Input/modplug/decoder_modplug.h | 9 ++-- .../Input/modplug/decodermodplugfactory.cpp | 32 ++++++------ src/plugins/Input/modplug/decodermodplugfactory.h | 6 +-- 4 files changed, 51 insertions(+), 54 deletions(-) (limited to 'src/plugins/Input/modplug') diff --git a/src/plugins/Input/modplug/decoder_modplug.cpp b/src/plugins/Input/modplug/decoder_modplug.cpp index ea0d18f64..6321f56b7 100644 --- a/src/plugins/Input/modplug/decoder_modplug.cpp +++ b/src/plugins/Input/modplug/decoder_modplug.cpp @@ -47,9 +47,10 @@ DecoderModPlug* DecoderModPlug::m_instance = 0; -DecoderModPlug::DecoderModPlug(QObject *parent, DecoderFactory *d, QIODevice *i, Output *o) - : Decoder(parent, d, i, o) +DecoderModPlug::DecoderModPlug(QObject *parent, DecoderFactory *d, Output *o, const QString &path) + : Decoder(parent, d, o) { + m_path = path; m_inited = FALSE; m_user_stop = FALSE; m_output_buf = 0; @@ -125,7 +126,7 @@ void DecoderModPlug::flush(bool final) bool DecoderModPlug::initialize() { - m_bks = blockSize(); + m_bks = Buffer::size(); m_inited = m_user_stop = m_done = m_finish = FALSE; m_freq = m_bitrate = 0; m_chan = 0; @@ -133,29 +134,25 @@ bool DecoderModPlug::initialize() m_seekTime = -1.0; m_totalTime = 0.0; - - if (! input()) - { - error("DecoderModPlug: cannot initialize. No input."); - - return FALSE; - } - if (! m_output_buf) m_output_buf = new char[globalBufferSize]; m_output_at = 0; m_output_bytes = 0; - QString filename = qobject_cast(input())->fileName (); ArchiveReader reader(this); - if (reader.isSupported(filename)) + if (reader.isSupported(m_path)) + m_input_buf = reader.unpack(m_path); + else { - input()->close(); - m_input_buf = reader.unpack(filename); + QFile file(m_path); + if (!file.open(QIODevice::ReadOnly)) + { + qWarning("DecoderModPlug: error: %s", qPrintable(file.errorString ())); + return FALSE; + } + m_input_buf = file.readAll(); + file.close(); } - else - m_input_buf = input()->readAll(); - if (m_input_buf.isEmpty()) { qWarning("DecoderModPlug: error reading moplug file"); @@ -172,13 +169,13 @@ bool DecoderModPlug::initialize() return FALSE; }*/ - m_totalTime = (int) m_soundFile->GetSongTime(); - configure(m_freq, m_chan, m_bps, m_bitrate); + m_totalTime = (qint64) m_soundFile->GetSongTime(); + configure(m_freq, m_chan, m_bps); m_inited = TRUE; return TRUE; } -double DecoderModPlug::lengthInSeconds() +qint64 DecoderModPlug::lengthInSeconds() { if (! m_inited) return 0; @@ -187,7 +184,7 @@ double DecoderModPlug::lengthInSeconds() } -void DecoderModPlug::seek(double pos) +void DecoderModPlug::seek(qint64 pos) { m_seekTime = pos; } @@ -212,24 +209,22 @@ void DecoderModPlug::run() mutex()->lock (); ulong len = 0; - if (! m_inited) + if (!m_inited) { mutex()->unlock(); - return; } mutex()->unlock(); - dispatch(DecoderState::Decoding); char *prebuf = new char[m_bks]; - while (! m_done && ! m_finish) + while (!m_done && !m_finish) { mutex()->lock (); //seeking - if (m_seekTime >= 0.0) + if (m_seekTime >= 0) { quint32 lMax; quint32 lMaxtime; @@ -318,9 +313,8 @@ void DecoderModPlug::run() } else { - // error in read - error("DecoderModPlug: Error while decoding stream, File appears to be " - "corrupted"); + // error while read + qWarning("DecoderModPlug: Error while decoding stream, File appears to be corrupted"); m_finish = TRUE; } mutex()->unlock(); @@ -329,9 +323,7 @@ void DecoderModPlug::run() mutex()->lock (); if (m_finish) - dispatch(DecoderState::Finished); - else if (m_user_stop) - dispatch(DecoderState::Stopped); + finish(); mutex()->unlock(); delete prebuf; diff --git a/src/plugins/Input/modplug/decoder_modplug.h b/src/plugins/Input/modplug/decoder_modplug.h index 4883c3b09..71f082c4a 100644 --- a/src/plugins/Input/modplug/decoder_modplug.h +++ b/src/plugins/Input/modplug/decoder_modplug.h @@ -28,13 +28,13 @@ class CSoundFile; class DecoderModPlug : public Decoder { public: - DecoderModPlug(QObject *, DecoderFactory *, QIODevice *, Output *); + DecoderModPlug(QObject *, DecoderFactory *, Output *, const QString &path); virtual ~DecoderModPlug(); // Standard Decoder API bool initialize(); - double lengthInSeconds(); - void seek(double); + qint64 lengthInSeconds(); + void seek(qint64); void stop(); void readSettings(); @@ -68,9 +68,10 @@ private: long m_freq, m_bitrate; int m_chan, m_sampleSize; unsigned long m_output_size; - double m_totalTime, m_seekTime; + qint64 m_totalTime, m_seekTime; double m_preampFactor; bool m_usePreamp; + QString m_path; static DecoderModPlug* m_instance; }; diff --git a/src/plugins/Input/modplug/decodermodplugfactory.cpp b/src/plugins/Input/modplug/decodermodplugfactory.cpp index 1124abb79..9e13c0b74 100644 --- a/src/plugins/Input/modplug/decodermodplugfactory.cpp +++ b/src/plugins/Input/modplug/decodermodplugfactory.cpp @@ -65,49 +65,53 @@ const DecoderProperties DecoderModPlugFactory::properties() const //properties.contentType = ; properties.hasAbout = TRUE; properties.hasSettings = TRUE; + properties.noInput = TRUE; + properties.protocols = "file"; return properties; } Decoder *DecoderModPlugFactory::create(QObject *parent, QIODevice *input, - Output *output) + Output *output, const QString &path) { - return new DecoderModPlug(parent, this, input, output); + Q_UNUSED(input); + return new DecoderModPlug(parent, this, output, path); } -FileTag *DecoderModPlugFactory::createTag(const QString &source) +QList DecoderModPlugFactory::createPlayList(const QString &fileName) { - FileTag *ftag = new FileTag(); + QList list; QSettings settings(QDir::homePath()+"/.qmmp/qmmprc", QSettings::IniFormat); if (settings.value("UseFileName", FALSE).toBool()) { - ftag->setValue(FileTag::TITLE, source.section('/',-1)); - return ftag; + list << new FileInfo(fileName); + list.at(0)->setMetaData(Qmmp::TITLE, fileName.section('/',-1)); + return list; } ArchiveReader reader(0); QByteArray buffer; - if (reader.isSupported(source)) + if (reader.isSupported(fileName)) { - buffer = reader.unpack(source); + buffer = reader.unpack(fileName); } else { - QFile file(source); + QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { qWarning("DecoderModPlugFactory: error: %s", qPrintable(file.errorString ())); - return ftag; + return list; } buffer = file.readAll(); file.close(); } CSoundFile* soundFile = new CSoundFile(); soundFile->Create((uchar*) buffer.data(), buffer.size()); - - ftag->setValue(FileTag::LENGTH, (int) soundFile->GetSongTime()); - ftag->setValue(FileTag::TITLE, QString::fromUtf8(soundFile->GetTitle())); + list << new FileInfo(fileName); + list.at(0)->setLength((int) soundFile->GetSongTime()); + list.at(0)->setMetaData(Qmmp::TITLE, QString::fromUtf8(soundFile->GetTitle())); soundFile->Destroy(); delete soundFile; - return ftag; + return list; } QObject* DecoderModPlugFactory::showDetails(QWidget *parent, const QString &path) diff --git a/src/plugins/Input/modplug/decodermodplugfactory.h b/src/plugins/Input/modplug/decodermodplugfactory.h index 20378f739..8581e0d99 100644 --- a/src/plugins/Input/modplug/decodermodplugfactory.h +++ b/src/plugins/Input/modplug/decodermodplugfactory.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include class DecoderModPlugFactory : public QObject, @@ -41,8 +41,8 @@ public: bool supports(const QString &source) const; bool canDecode(QIODevice *input) const; const DecoderProperties properties() const; - Decoder *create(QObject *, QIODevice *, Output *); - FileTag *createTag(const QString &source); + Decoder *create(QObject *, QIODevice *, Output *, const QString &); + QList createPlayList(const QString &fileName); QObject* showDetails(QWidget *parent, const QString &path); void showSettings(QWidget *parent); void showAbout(QWidget *parent); -- cgit v1.2.3-13-gbd6f