diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-11-28 15:46:53 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-11-28 15:46:53 +0000 |
| commit | 26724c66d4764a77ca653ce6c0a1573e9e97e97c (patch) | |
| tree | f238f84ed390de31471cb95a20e3775f2ea7e3e7 /src/plugins/Input/flac | |
| parent | d02787b92ad9a220539498ebbc9f1745a075d10d (diff) | |
| download | qmmp-26724c66d4764a77ca653ce6c0a1573e9e97e97c.tar.gz qmmp-26724c66d4764a77ca653ce6c0a1573e9e97e97c.tar.bz2 qmmp-26724c66d4764a77ca653ce6c0a1573e9e97e97c.zip | |
changed decoder api; fixed flac plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@646 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input/flac')
| -rw-r--r-- | src/plugins/Input/flac/cueparser.cpp | 10 | ||||
| -rw-r--r-- | src/plugins/Input/flac/decoder_flac.cpp | 22 | ||||
| -rw-r--r-- | src/plugins/Input/flac/decoder_flac.h | 1 | ||||
| -rw-r--r-- | src/plugins/Input/flac/decoderflacfactory.cpp | 7 | ||||
| -rw-r--r-- | src/plugins/Input/flac/decoderflacfactory.h | 2 |
5 files changed, 13 insertions, 29 deletions
diff --git a/src/plugins/Input/flac/cueparser.cpp b/src/plugins/Input/flac/cueparser.cpp index 64870c97f..1441a999b 100644 --- a/src/plugins/Input/flac/cueparser.cpp +++ b/src/plugins/Input/flac/cueparser.cpp @@ -44,12 +44,7 @@ CUEParser::CUEParser(const QByteArray &array, const QString &fileName) if (words.size() < 2) continue; - if (words[0] == "FILE") - { - //m_filePath = QUrl(fileName).path (); - //m_filePath = QFileInfo(m_filePath).dir().filePath(words[1]); - } - else if (words[0] == "PERFORMER") + if (words[0] == "PERFORMER") { if (m_infoList.isEmpty()) { @@ -97,8 +92,7 @@ CUEParser::CUEParser(const QByteArray &array, const QString &fileName) for (int i = 0; i < m_infoList.size() - 1; ++i) m_infoList[i].setLength(m_infoList[i+1].length() - m_infoList[i].length()); //calculate last item length - QList <FileInfo *> f_list; - //f_list = Decoder::createPlayList(m_filePath); + QList <FileInfo *> f_list = Decoder::createPlayList(m_filePath, FALSE); qint64 l = f_list.isEmpty() ? 0 : f_list.at(0)->length(); if (l > m_infoList.last().length()) m_infoList.last().setLength(l - m_infoList.last().length()); diff --git a/src/plugins/Input/flac/decoder_flac.cpp b/src/plugins/Input/flac/decoder_flac.cpp index 44618c919..ec6cb6755 100644 --- a/src/plugins/Input/flac/decoder_flac.cpp +++ b/src/plugins/Input/flac/decoder_flac.cpp @@ -281,7 +281,6 @@ DecoderFLAC::DecoderFLAC(QObject *parent, DecoderFactory *d, QIODevice *i, Outpu m_offset = 0; m_length = 0; - m_cue = FALSE; m_data = new flac_data; m_data->decoder = NULL; data()->input = i; @@ -362,7 +361,6 @@ bool DecoderFLAC::initialize() seekTime = -1.0; totalTime = 0.0; - if (!data()->input) { QString p = m_path; @@ -374,20 +372,18 @@ bool DecoderFLAC::initialize() qWarning("DecoderFLAC: invalid url."); return FALSE; } - qDebug("DecoderFLAC: using embeded cue"); TagLib::FLAC::File fileRef(p.toLocal8Bit ()); //looking for cuesheet comment TagLib::Ogg::XiphComment *xiph_comment = fileRef.xiphComment(); QList <FileInfo*> list; if (xiph_comment && xiph_comment->fieldListMap().contains("CUESHEET")) { - qDebug("DecoderFLAC: found cuesheet xiph comment"); - CUEParser parser(xiph_comment->fieldListMap()["CUESHEET"].toString().toCString(TRUE), m_path); + qDebug("DecoderFLAC: using cuesheet xiph comment."); + CUEParser parser(xiph_comment->fieldListMap()["CUESHEET"].toString().toCString(TRUE), p); int track = m_path.section("#", -1).toInt(); m_offset = parser.offset(track); m_length = parser.length(track); data()->input = new QFile(p); - m_cue = TRUE; } else { @@ -501,9 +497,10 @@ void DecoderFLAC::deinit() len = freq = bitrate = 0; stat = chan = 0; output_size = 0; - if (!input() && data()->input) + if (!input() && data()->input) //delete internal input only { data()->input->close(); + delete data()->input; data()->input = 0; }; } @@ -519,7 +516,7 @@ void DecoderFLAC::run() } mutex()->unlock(); - while (! done && ! m_finish) + while (!done && !m_finish) { mutex()->lock (); // decode @@ -566,22 +563,17 @@ void DecoderFLAC::run() } done = TRUE; - if (! user_stop) - { - m_finish = TRUE; - } + m_finish = !user_stop; } else { - // error in read + // error while read qWarning("DecoderFLAC: Error while decoding stream, File appears to be " "corrupted"); m_finish = TRUE; } - if (m_length && (StateHandler::instance()->elapsed() >= m_length)) m_finish = TRUE; - mutex()->unlock(); } diff --git a/src/plugins/Input/flac/decoder_flac.h b/src/plugins/Input/flac/decoder_flac.h index cef0cd561..f2e002487 100644 --- a/src/plugins/Input/flac/decoder_flac.h +++ b/src/plugins/Input/flac/decoder_flac.h @@ -102,7 +102,6 @@ private: QString m_path; qint64 m_offset; qint64 m_length; - bool m_cue; }; diff --git a/src/plugins/Input/flac/decoderflacfactory.cpp b/src/plugins/Input/flac/decoderflacfactory.cpp index 2da4c69de..df3ef6dd3 100644 --- a/src/plugins/Input/flac/decoderflacfactory.cpp +++ b/src/plugins/Input/flac/decoderflacfactory.cpp @@ -64,12 +64,12 @@ Decoder *DecoderFLACFactory::create(QObject *parent, QIODevice *input, return new DecoderFLAC(parent, this, input, output, path); } -QList<FileInfo *> DecoderFLACFactory::createPlayList(const QString &fileName) +QList<FileInfo *> DecoderFLACFactory::createPlayList(const QString &fileName, bool useMetaData) { FileInfo *info = new FileInfo(fileName); TagLib::FLAC::File fileRef(fileName.toLocal8Bit ()); - TagLib::Tag *tag = fileRef.tag(); + TagLib::Tag *tag = useMetaData ? fileRef.tag() : 0; if (tag && !tag->isEmpty()) { @@ -91,11 +91,10 @@ QList<FileInfo *> DecoderFLACFactory::createPlayList(const QString &fileName) info->setLength(fileRef.audioProperties()->length()); //looking for cuesheet comment - TagLib::Ogg::XiphComment *xiph_comment = fileRef.xiphComment(); + TagLib::Ogg::XiphComment *xiph_comment = useMetaData ? fileRef.xiphComment() : 0; QList <FileInfo*> list; if (xiph_comment && xiph_comment->fieldListMap().contains("CUESHEET")) { - qDebug(xiph_comment->fieldListMap()["CUESHEET"].toString().toCString(TRUE)); CUEParser parser(xiph_comment->fieldListMap()["CUESHEET"].toString().toCString(TRUE), fileName); list = parser.createPlayList(); delete info; diff --git a/src/plugins/Input/flac/decoderflacfactory.h b/src/plugins/Input/flac/decoderflacfactory.h index 983355d23..7fd7dcb42 100644 --- a/src/plugins/Input/flac/decoderflacfactory.h +++ b/src/plugins/Input/flac/decoderflacfactory.h @@ -40,7 +40,7 @@ public: bool canDecode(QIODevice *input) const; const DecoderProperties properties() const; Decoder *create(QObject *, QIODevice *, Output *, const QString &); - QList<FileInfo *> createPlayList(const QString &fileName); + QList<FileInfo *> createPlayList(const QString &fileName, bool useMetaData); QObject* showDetails(QWidget *parent, const QString &path); void showSettings(QWidget *parent); void showAbout(QWidget *parent); |
