diff options
Diffstat (limited to 'src/plugins/Input/flac')
| -rw-r--r-- | src/plugins/Input/flac/cueparser.cpp | 17 | ||||
| -rw-r--r-- | src/plugins/Input/flac/cueparser.h | 6 | ||||
| -rw-r--r-- | src/plugins/Input/flac/decoder_flac.cpp | 16 | ||||
| -rw-r--r-- | src/plugins/Input/flac/decoder_flac.h | 8 |
4 files changed, 25 insertions, 22 deletions
diff --git a/src/plugins/Input/flac/cueparser.cpp b/src/plugins/Input/flac/cueparser.cpp index 0be845906..173b31e54 100644 --- a/src/plugins/Input/flac/cueparser.cpp +++ b/src/plugins/Input/flac/cueparser.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2008-2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -88,7 +88,7 @@ CUEParser::CUEParser(const QByteArray &array, const QString &fileName) m_infoList[i].setLength(m_infoList[i+1].length() - m_infoList[i].length()); //calculate last item length QList <FileInfo *> f_list = Decoder::createPlayList(m_filePath, FALSE); - qint64 l = f_list.isEmpty() ? 0 : f_list.at(0)->length(); + qint64 l = f_list.isEmpty() ? 0 : f_list.at(0)->length() * 1000; if (l > m_infoList.last().length()) m_infoList.last().setLength(l - m_infoList.last().length()); else @@ -100,7 +100,7 @@ CUEParser::CUEParser(const QByteArray &array, const QString &fileName) m_infoList[i].setMetaData(Qmmp::GENRE, genre); m_infoList[i].setMetaData(Qmmp::YEAR, date); m_infoList[i].setMetaData(Qmmp::COMMENT, comment); - if(!m_infoList[i].metaData().count(Qmmp::ARTIST) && !artist.isEmpty()) + if (!m_infoList[i].metaData().count(Qmmp::ARTIST) && !artist.isEmpty()) m_infoList[i].setMetaData(Qmmp::ARTIST, artist); } } @@ -116,6 +116,7 @@ QList<FileInfo*> CUEParser::createPlayList() foreach(FileInfo info, m_infoList) { list << new FileInfo(info); + list.last()->setLength(list.last()->length()/1000); } return list; } @@ -174,10 +175,12 @@ QStringList CUEParser::splitLine(const QString &line) return list; } -int CUEParser::getLength(const QString &str) +qint64 CUEParser::getLength(const QString &str) { QStringList list = str.split(":"); - if (list.size() < 2) - return 0; - return list.at(0).toInt()*60 + list.at(1).toInt(); + if (list.size() == 2) + return (qint64)list.at(0).toInt()*60000 + list.at(1).toInt()*1000; + else if (list.size() == 3) + return (qint64)list.at(0).toInt()*60000 + list.at(1).toInt()*1000 + list.at(1).toInt()*1000/75; + return 0; } diff --git a/src/plugins/Input/flac/cueparser.h b/src/plugins/Input/flac/cueparser.h index fccd85912..b30b87bfa 100644 --- a/src/plugins/Input/flac/cueparser.h +++ b/src/plugins/Input/flac/cueparser.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2008-2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -49,9 +49,9 @@ public: private: QString m_filePath; QList <FileInfo> m_infoList; - QList <int> m_offsets; + QList <qint64> m_offsets; QStringList splitLine(const QString &line); - int getLength(const QString &str); + qint64 getLength(const QString &str); }; diff --git a/src/plugins/Input/flac/decoder_flac.cpp b/src/plugins/Input/flac/decoder_flac.cpp index ec6cb6755..c3f8b223c 100644 --- a/src/plugins/Input/flac/decoder_flac.cpp +++ b/src/plugins/Input/flac/decoder_flac.cpp @@ -239,7 +239,7 @@ static void flac_callback_metadata (const FLAC__StreamDecoder *, metadata->data.stream_info.bits_per_sample; dflac->data()->channels = metadata->data.stream_info.channels; dflac->data()->sample_rate = metadata->data.stream_info.sample_rate; - dflac->data()->length = dflac->data()->total_samples / dflac->data()->sample_rate; + dflac->data()->length = dflac->data()->total_samples * 1000 / dflac->data()->sample_rate; } } @@ -273,7 +273,7 @@ DecoderFLAC::DecoderFLAC(QObject *parent, DecoderFactory *d, QIODevice *i, Outpu freq = 0; bitrate = 0; seekTime = -1.0; - totalTime = 0.0; + m_totalTime = 0.0; chan = 0; output_size = 0; m_data = 0; @@ -359,7 +359,7 @@ bool DecoderFLAC::initialize() stat = chan = 0; output_size = 0; seekTime = -1.0; - totalTime = 0.0; + m_totalTime = 0.0; if (!data()->input) { @@ -461,30 +461,30 @@ bool DecoderFLAC::initialize() configure(data()->sample_rate, data()->channels, 32); else configure(data()->sample_rate, data()->channels, data()->bits_per_sample); - totalTime = data()->length; + m_totalTime = data()->length; inited = TRUE; if (m_offset) seekTime = m_offset; if (m_length) - totalTime = m_length; + m_totalTime = m_length; qDebug("DecoderFLAC: initialize succes"); return TRUE; } -qint64 DecoderFLAC::lengthInSeconds() +qint64 DecoderFLAC::totalTime() { if (! inited) return 0; - return totalTime; + return m_totalTime; } void DecoderFLAC::seek(qint64 pos) { - if (totalTime > 0) + if (m_totalTime > 0) seekTime = pos + m_offset; } diff --git a/src/plugins/Input/flac/decoder_flac.h b/src/plugins/Input/flac/decoder_flac.h index f2e002487..e6036232e 100644 --- a/src/plugins/Input/flac/decoder_flac.h +++ b/src/plugins/Input/flac/decoder_flac.h @@ -38,8 +38,8 @@ struct flac_data int bitrate; int abort; /* abort playing (due to an error) */ - unsigned length; - unsigned total_samples; + qint64 length; + qint64 total_samples; FLAC__byte sample_buffer[SAMPLE_BUFFER_SIZE]; unsigned sample_buffer_fill; @@ -64,7 +64,7 @@ public: // Standard Decoder API bool initialize(); - qint64 lengthInSeconds(); + qint64 totalTime(); void seek(qint64); void stop(); @@ -98,7 +98,7 @@ private: long len, freq, bitrate; int chan; unsigned long output_size; - double totalTime, seekTime; + double m_totalTime, seekTime; QString m_path; qint64 m_offset; qint64 m_length; |
