diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-10-12 19:48:39 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-10-12 19:48:39 +0000 |
| commit | e48a196c880d9f92804c6e1e3ea5631ae2017dd1 (patch) | |
| tree | 6767f170f669cdfaea23e469050c05ad1f6c67ca /src/plugins/Input/sndfile | |
| parent | 0a74e1c0e3781afe041ba9acc361461cc3ebda82 (diff) | |
| download | qmmp-e48a196c880d9f92804c6e1e3ea5631ae2017dd1.tar.gz qmmp-e48a196c880d9f92804c6e1e3ea5631ae2017dd1.tar.bz2 qmmp-e48a196c880d9f92804c6e1e3ea5631ae2017dd1.zip | |
enabled all input plugins
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@581 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input/sndfile')
| -rw-r--r-- | src/plugins/Input/sndfile/decoder_sndfile.cpp | 71 | ||||
| -rw-r--r-- | src/plugins/Input/sndfile/decoder_sndfile.h | 11 | ||||
| -rw-r--r-- | src/plugins/Input/sndfile/decodersndfilefactory.cpp | 26 | ||||
| -rw-r--r-- | src/plugins/Input/sndfile/decodersndfilefactory.h | 6 |
4 files changed, 46 insertions, 68 deletions
diff --git a/src/plugins/Input/sndfile/decoder_sndfile.cpp b/src/plugins/Input/sndfile/decoder_sndfile.cpp index dc7516854..4568a2fd9 100644 --- a/src/plugins/Input/sndfile/decoder_sndfile.cpp +++ b/src/plugins/Input/sndfile/decoder_sndfile.cpp @@ -31,9 +31,10 @@ // Decoder class -DecoderSndFile::DecoderSndFile(QObject *parent, DecoderFactory *d, QIODevice *i, Output *o) - : Decoder(parent, d, i, o) +DecoderSndFile::DecoderSndFile(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; @@ -107,7 +108,7 @@ void DecoderSndFile::flush(bool final) bool DecoderSndFile::initialize() { - bks = blockSize(); + bks = Buffer::size(); m_inited = m_user_stop = m_done = m_finish = FALSE; m_freq = m_bitrate = 0; m_output_size = 0; @@ -115,28 +116,17 @@ bool DecoderSndFile::initialize() m_totalTime = 0.0; SF_INFO snd_info; - - if (! input()) - { - error("DecoderSndFile: cannot initialize. No input."); - - return FALSE; - } - - if (! m_output_buf) + if (!m_output_buf) m_output_buf = new char[globalBufferSize]; m_output_at = 0; m_output_bytes = 0; - QString filename = qobject_cast<QFile*>(input())->fileName (); - input()->close(); - memset (&snd_info, 0, sizeof(snd_info)); snd_info.format=0; - m_sndfile = sf_open(filename.toLocal8Bit(), SFM_READ, &snd_info); + m_sndfile = sf_open(m_path.toLocal8Bit(), SFM_READ, &snd_info); if (!m_sndfile) { - qWarning("DecoderSndFile: failed to open: %s", qPrintable(filename)); + qWarning("DecoderSndFile: failed to open: %s", qPrintable(m_path)); return FALSE; } @@ -145,10 +135,10 @@ bool DecoderSndFile::initialize() m_totalTime = (double) snd_info.frames / m_freq; - m_bitrate = QFileInfo(filename).size () * 8.0 / m_totalTime / 1000.0 + 0.5; + m_bitrate = QFileInfo(m_path).size () * 8.0 / m_totalTime / 1000.0 + 0.5; - configure(m_freq, m_chan, 16, m_bitrate); - m_buf = new short[blockSize() / sizeof(short)]; + configure(m_freq, m_chan, 16); + m_buf = new short[bks / sizeof(short)]; m_inited = TRUE; qDebug("DecoderSndFile: detected format: %08X", snd_info.format); qDebug("DecoderSndFile: initialize succes"); @@ -156,7 +146,7 @@ bool DecoderSndFile::initialize() } -double DecoderSndFile::lengthInSeconds() +qint64 DecoderSndFile::lengthInSeconds() { if (! m_inited) return 0; @@ -165,7 +155,7 @@ double DecoderSndFile::lengthInSeconds() } -void DecoderSndFile::seek(double pos) +void DecoderSndFile::seek(qint64 pos) { m_seekTime = pos; } @@ -178,10 +168,10 @@ void DecoderSndFile::deinit() m_output_size = 0; if (m_inited) { - delete m_buf; - m_buf = 0; - sf_close(m_sndfile); - m_sndfile = 0; + delete m_buf; + m_buf = 0; + sf_close(m_sndfile); + m_sndfile = 0; } } @@ -189,36 +179,28 @@ void DecoderSndFile::run() { long len = 0; - int stat = 0; mutex()->lock (); - if (! m_inited) + if (!m_inited) { mutex()->unlock(); - return; } - - stat = DecoderState::Decoding; mutex()->unlock(); - { - dispatch(DecoderState ((DecoderState::Type) stat)); - } - - while (! m_done && ! m_finish) + while (!m_done && !m_finish) { mutex()->lock (); // decode - if (m_seekTime >= 0.0) + if (m_seekTime >= 0) { m_output_size = sf_seek(m_sndfile, m_freq*m_seekTime, SEEK_SET); m_seekTime = -1.0; } - len = sizeof(short)* sf_read_short (m_sndfile, m_buf, blockSize() / sizeof(short)); + len = sizeof(short)* sf_read_short (m_sndfile, m_buf, bks / sizeof(short)); if (len > 0) { @@ -256,25 +238,16 @@ void DecoderSndFile::run() else { // error in read - error("DecoderSndFile: Error while decoding stream, File appears to be " - "corrupted"); - + qWarning("DecoderSndFile: Error while decoding stream, File appears to be corrupted"); m_finish = TRUE; } - mutex()->unlock(); } mutex()->lock (); - if (m_finish) - stat = DecoderState::Finished; - else if (m_user_stop) - stat = DecoderState::Stopped; - + finish(); mutex()->unlock(); - dispatch(DecoderState ((DecoderState::Type) stat)); deinit(); } - diff --git a/src/plugins/Input/sndfile/decoder_sndfile.h b/src/plugins/Input/sndfile/decoder_sndfile.h index 9a66acd3d..e221065f2 100644 --- a/src/plugins/Input/sndfile/decoder_sndfile.h +++ b/src/plugins/Input/sndfile/decoder_sndfile.h @@ -30,13 +30,13 @@ extern "C"{ class DecoderSndFile : public Decoder { public: - DecoderSndFile(QObject *, DecoderFactory *, QIODevice *, Output *); + DecoderSndFile(QObject *, DecoderFactory *, Output *, const QString &); virtual ~DecoderSndFile(); // Standard Decoder API bool initialize(); - double lengthInSeconds(); - void seek(double); + qint64 lengthInSeconds(); + void seek(qint64); void stop(); @@ -58,8 +58,9 @@ private: bool m_done, m_finish, m_inited, m_user_stop; long m_freq, m_bitrate; int m_chan; - unsigned long m_output_size; - double m_totalTime, m_seekTime; + qint64 m_output_size; + qint64 m_totalTime, m_seekTime; + QString m_path; }; diff --git a/src/plugins/Input/sndfile/decodersndfilefactory.cpp b/src/plugins/Input/sndfile/decodersndfilefactory.cpp index 30178aabe..1828b8292 100644 --- a/src/plugins/Input/sndfile/decodersndfilefactory.cpp +++ b/src/plugins/Input/sndfile/decodersndfilefactory.cpp @@ -68,46 +68,50 @@ const DecoderProperties DecoderSndFileFactory::properties() const //properties.contentType = ""; properties.hasAbout = TRUE; properties.hasSettings = FALSE; + properties.noInput = TRUE; + properties.protocols = "file"; return properties; } Decoder *DecoderSndFileFactory::create(QObject *parent, QIODevice *input, - Output *output) + Output *output, const QString &path) { - return new DecoderSndFile(parent, this, input, output); + Q_UNUSED(input); + return new DecoderSndFile(parent, this, output, path); } -FileTag *DecoderSndFileFactory::createTag(const QString &source) +QList<FileInfo *> DecoderSndFileFactory::createPlayList(const QString &fileName) { - FileTag *ftag = new FileTag(); + QList <FileInfo *> list; SF_INFO snd_info; SNDFILE *sndfile = 0; memset (&snd_info, 0, sizeof(snd_info)); snd_info.format = 0; - sndfile = sf_open(source.toLocal8Bit(), SFM_READ, &snd_info); + sndfile = sf_open(fileName.toLocal8Bit(), SFM_READ, &snd_info); if (!sndfile) - return ftag; + return list; + list << new FileInfo(fileName); if (sf_get_string(sndfile, SF_STR_TITLE)) { char* title = strdup(sf_get_string(sndfile, SF_STR_TITLE)); - ftag->setValue(FileTag::TITLE, QString::fromUtf8(title).trimmed()); + list.at(0)->setMetaData(Qmmp::TITLE, QString::fromUtf8(title).trimmed()); } if (sf_get_string(sndfile, SF_STR_ARTIST)) { char* artist = strdup(sf_get_string(sndfile, SF_STR_ARTIST)); - ftag->setValue(FileTag::ARTIST, QString::fromUtf8(artist).trimmed()); + list.at(0)->setMetaData(Qmmp::ARTIST, QString::fromUtf8(artist).trimmed()); } if (sf_get_string(sndfile, SF_STR_COMMENT)) { char* comment = strdup(sf_get_string(sndfile, SF_STR_COMMENT)); - ftag->setValue(FileTag::COMMENT, QString::fromUtf8(comment).trimmed()); + list.at(0)->setMetaData(Qmmp::COMMENT, QString::fromUtf8(comment).trimmed()); } - ftag->setValue(FileTag::LENGTH ,int(snd_info.frames / snd_info.samplerate)); + list.at(0)->setLength(int(snd_info.frames / snd_info.samplerate)); sf_close(sndfile); - return ftag; + return list; } QObject* DecoderSndFileFactory::showDetails(QWidget *parent, const QString &path) diff --git a/src/plugins/Input/sndfile/decodersndfilefactory.h b/src/plugins/Input/sndfile/decodersndfilefactory.h index ca1753cac..aab996d98 100644 --- a/src/plugins/Input/sndfile/decodersndfilefactory.h +++ b/src/plugins/Input/sndfile/decodersndfilefactory.h @@ -28,7 +28,7 @@ #include <qmmp/decoder.h> #include <qmmp/output.h> #include <qmmp/decoderfactory.h> -#include <qmmp/filetag.h> +#include <qmmp/fileinfo.h> @@ -43,8 +43,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 &path); + QList<FileInfo *> createPlayList(const QString &fileName); QObject* showDetails(QWidget *parent, const QString &path); void showSettings(QWidget *parent); void showAbout(QWidget *parent); |
