diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-03-07 22:43:26 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-03-07 22:43:26 +0000 |
| commit | 0b46e2db06ec1bbfc3aee819787386ace9dad66c (patch) | |
| tree | 109f4bbf3a7227262a280f00731f0767d331a811 /src/plugins/Input | |
| parent | 5896c5ae40726637cbfc5605f5f659791ff569c7 (diff) | |
| download | qmmp-0b46e2db06ec1bbfc3aee819787386ace9dad66c.tar.gz qmmp-0b46e2db06ec1bbfc3aee819787386ace9dad66c.tar.bz2 qmmp-0b46e2db06ec1bbfc3aee819787386ace9dad66c.zip | |
improved seeking accuracy
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@827 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input')
30 files changed, 120 insertions, 116 deletions
diff --git a/src/plugins/Input/aac/decoder_aac.cpp b/src/plugins/Input/aac/decoder_aac.cpp index 07f389627..43ba3964e 100644 --- a/src/plugins/Input/aac/decoder_aac.cpp +++ b/src/plugins/Input/aac/decoder_aac.cpp @@ -163,7 +163,7 @@ bool DecoderAAC::initialize() qWarning("DecoderAAC: unsupported AAC file"); return FALSE; } - m_totalTime = aac_file.length(); + m_totalTime = aac_file.length() * 1000; m_bitrate = aac_file.bitrate(); if (!m_data) @@ -248,7 +248,7 @@ qint64 DecoderAAC::aac_decode(void *out) return size; } -qint64 DecoderAAC::lengthInSeconds() +qint64 DecoderAAC::totalTime() { if (!m_inited) return 0; diff --git a/src/plugins/Input/aac/decoder_aac.h b/src/plugins/Input/aac/decoder_aac.h index 64b1ec940..328cfc3c4 100644 --- a/src/plugins/Input/aac/decoder_aac.h +++ b/src/plugins/Input/aac/decoder_aac.h @@ -40,7 +40,7 @@ public: // Standard Decoder API bool initialize(); - qint64 lengthInSeconds(); + qint64 totalTime(); void seek(qint64); void stop(); diff --git a/src/plugins/Input/cdaudio/decoder_cdaudio.cpp b/src/plugins/Input/cdaudio/decoder_cdaudio.cpp index 82bfe3ff3..029d5e2db 100644 --- a/src/plugins/Input/cdaudio/decoder_cdaudio.cpp +++ b/src/plugins/Input/cdaudio/decoder_cdaudio.cpp @@ -319,7 +319,7 @@ bool DecoderCDAudio::initialize() } -qint64 DecoderCDAudio::lengthInSeconds() +qint64 DecoderCDAudio::totalTime() { if (! m_inited) return 0; diff --git a/src/plugins/Input/cdaudio/decoder_cdaudio.h b/src/plugins/Input/cdaudio/decoder_cdaudio.h index 12d4aaeb8..78ab8d62d 100644 --- a/src/plugins/Input/cdaudio/decoder_cdaudio.h +++ b/src/plugins/Input/cdaudio/decoder_cdaudio.h @@ -51,7 +51,7 @@ public: // Standard Decoder API bool initialize(); - qint64 lengthInSeconds(); + qint64 totalTime(); void seek(qint64); void stop(); diff --git a/src/plugins/Input/cue/cueparser.cpp b/src/plugins/Input/cue/cueparser.cpp index 78d2fc8ad..68d3cb9e2 100644 --- a/src/plugins/Input/cue/cueparser.cpp +++ b/src/plugins/Input/cue/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 * @@ -102,9 +102,8 @@ CUEParser::CUEParser(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, FALSE); - qint64 l = f_list.isEmpty() ? 0 : f_list.at(0)->length(); + QList <FileInfo *> f_list = Decoder::createPlayList(m_filePath, FALSE); + 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 @@ -133,6 +132,7 @@ QList<FileInfo*> CUEParser::createPlayList() foreach(FileInfo info, m_infoList) { list << new FileInfo(info); + list.last()->setLength(list.last()->length()/1000); } return list; } @@ -191,10 +191,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/cue/cueparser.h b/src/plugins/Input/cue/cueparser.h index 694415111..654b9212d 100644 --- a/src/plugins/Input/cue/cueparser.h +++ b/src/plugins/Input/cue/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 * @@ -47,9 +47,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/cue/decoder_cue.cpp b/src/plugins/Input/cue/decoder_cue.cpp index a660d3cc0..fd965bd0e 100644 --- a/src/plugins/Input/cue/decoder_cue.cpp +++ b/src/plugins/Input/cue/decoder_cue.cpp @@ -121,7 +121,7 @@ bool DecoderCUE::initialize() return TRUE; } -qint64 DecoderCUE::lengthInSeconds() +qint64 DecoderCUE::totalTime() { return m_decoder ? m_length : 0; } diff --git a/src/plugins/Input/cue/decoder_cue.h b/src/plugins/Input/cue/decoder_cue.h index 35ab8496e..14c32eeae 100644 --- a/src/plugins/Input/cue/decoder_cue.h +++ b/src/plugins/Input/cue/decoder_cue.h @@ -37,7 +37,7 @@ public: // Standard Decoder API bool initialize(); - qint64 lengthInSeconds(); + qint64 totalTime(); void seek(qint64); void stop(); void pause(); diff --git a/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp b/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp index 919830cfc..12e6d16ab 100644 --- a/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp +++ b/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp @@ -44,7 +44,7 @@ DecoderFFmpeg::DecoderFFmpeg(QObject *parent, DecoderFactory *d, Output *o, cons freq = 0; bitrate = 0; seekTime = -1.0; - totalTime = 0.0; + m_totalTime = 0.0; chan = 0; output_size = 0; ic = 0; @@ -122,7 +122,7 @@ bool DecoderFFmpeg::initialize() chan = 0; output_size = 0; seekTime = -1.0; - totalTime = 0.0; + m_totalTime = 0.0; if (!output_buf) output_buf = new char[globalBufferSize]; @@ -153,7 +153,7 @@ bool DecoderFFmpeg::initialize() if (avcodec_open(c, codec) < 0) return FALSE; - totalTime = ic->duration/AV_TIME_BASE; + m_totalTime = ic->duration * 1000 / AV_TIME_BASE; configure(c->sample_rate, c->channels, 16); @@ -166,12 +166,12 @@ bool DecoderFFmpeg::initialize() } -qint64 DecoderFFmpeg::lengthInSeconds() +qint64 DecoderFFmpeg::totalTime() { if (! inited) return 0; - return totalTime; + return m_totalTime; } @@ -212,7 +212,7 @@ void DecoderFFmpeg::run() if (seekTime >= 0.0) { int64_t timestamp; - timestamp = int64_t(seekTime)*AV_TIME_BASE; + timestamp = int64_t(seekTime)*AV_TIME_BASE/1000; if (ic->start_time != AV_NOPTS_VALUE) timestamp += ic->start_time; av_seek_frame(ic, -1, timestamp, AVSEEK_FLAG_BACKWARD); diff --git a/src/plugins/Input/ffmpeg/decoder_ffmpeg.h b/src/plugins/Input/ffmpeg/decoder_ffmpeg.h index ad4ab00b3..5c789d24d 100644 --- a/src/plugins/Input/ffmpeg/decoder_ffmpeg.h +++ b/src/plugins/Input/ffmpeg/decoder_ffmpeg.h @@ -50,7 +50,7 @@ public: // Standard Decoder API bool initialize(); - qint64 lengthInSeconds(); + qint64 totalTime(); void seek(qint64); void stop(); @@ -77,7 +77,7 @@ private: long freq, bitrate; int chan; qint64 output_size; - qint64 totalTime, seekTime; + qint64 m_totalTime, seekTime; QString m_path; }; 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; diff --git a/src/plugins/Input/mad/decoder_mad.cpp b/src/plugins/Input/mad/decoder_mad.cpp index b4ff243ae..2bda8322b 100644 --- a/src/plugins/Input/mad/decoder_mad.cpp +++ b/src/plugins/Input/mad/decoder_mad.cpp @@ -31,7 +31,7 @@ DecoderMAD::DecoderMAD(QObject *parent, DecoderFactory *d, QIODevice *i, Output derror = false; eof = false; useeq = false; - totalTime = 0.; + m_totalTime = 0.; seekTime = -1.; channels = 0; bks = 0; @@ -77,7 +77,7 @@ bool DecoderMAD::initialize() m_finish = false; derror = false; eof = false; - totalTime = 0.; + m_totalTime = 0.; seekTime = -1.; channels = 0; bitrate = 0; @@ -153,7 +153,7 @@ void DecoderMAD::deinit() derror = false; eof = false; useeq = false; - totalTime = 0.; + m_totalTime = 0.; seekTime = -1.; channels = 0; bks = 0; @@ -327,8 +327,8 @@ bool DecoderMAD::findHeader() duration = header.duration; } - totalTime = mad_timer_count(duration, MAD_UNITS_SECONDS); - qDebug ("DecoderMAD: Total time: %ld", long(totalTime)); + m_totalTime = mad_timer_count(duration, MAD_UNITS_MILLISECONDS); + qDebug ("DecoderMAD: Total time: %ld", long(m_totalTime)); freq = header.samplerate; channels = MAD_NCHANNELS(&header); bitrate = header.bitrate / 1000; @@ -338,11 +338,11 @@ bool DecoderMAD::findHeader() return TRUE; } -qint64 DecoderMAD::lengthInSeconds() +qint64 DecoderMAD::totalTime() { if (! inited) return 0.; - return totalTime; + return m_totalTime; } void DecoderMAD::seek(qint64 pos) @@ -410,9 +410,9 @@ void DecoderMAD::run() { mutex()->lock(); - if (seekTime >= 0.0 && totalTime > 0) + if (seekTime >= 0.0 && m_totalTime > 0) { - long seek_pos = long(seekTime * input()->size() / totalTime); + long seek_pos = long(seekTime * input()->size() / m_totalTime); input()->seek(seek_pos); output_size = long(seekTime) * long(freq * channels * 16 / 2); mad_frame_mute(&frame); diff --git a/src/plugins/Input/mad/decoder_mad.h b/src/plugins/Input/mad/decoder_mad.h index 5e1b72877..6fb6f2a40 100644 --- a/src/plugins/Input/mad/decoder_mad.h +++ b/src/plugins/Input/mad/decoder_mad.h @@ -27,7 +27,7 @@ public: // standard decoder API bool initialize(); - qint64 lengthInSeconds(); + qint64 totalTime(); void seek(qint64); void stop(); @@ -45,7 +45,7 @@ private: bool findXingHeader(struct mad_bitptr, unsigned int); uint findID3v2(uchar *data, ulong size); bool inited, user_stop, done, m_finish, derror, eof, useeq; - qint64 totalTime, seekTime; + qint64 m_totalTime, seekTime; int channels; unsigned long bitrate; long freq, len; diff --git a/src/plugins/Input/modplug/decoder_modplug.cpp b/src/plugins/Input/modplug/decoder_modplug.cpp index c0e5bc380..adb11daed 100644 --- a/src/plugins/Input/modplug/decoder_modplug.cpp +++ b/src/plugins/Input/modplug/decoder_modplug.cpp @@ -169,13 +169,13 @@ bool DecoderModPlug::initialize() return FALSE; }*/ - m_totalTime = (qint64) m_soundFile->GetSongTime(); + m_totalTime = (qint64) m_soundFile->GetSongTime() * 1000; configure(m_freq, m_chan, m_bps); m_inited = TRUE; return TRUE; } -qint64 DecoderModPlug::lengthInSeconds() +qint64 DecoderModPlug::totalTime() { if (! m_inited) return 0; @@ -230,11 +230,11 @@ void DecoderModPlug::run() quint32 lMaxtime; double lPostime; - if (m_seekTime > (lMaxtime = m_soundFile->GetSongTime())) - m_seekTime = lMaxtime; + if (m_seekTime > (lMaxtime = m_soundFile->GetSongTime()) * 1000) + m_seekTime = lMaxtime * 1000; lMax = m_soundFile->GetMaxPosition(); lPostime = float(lMax) / lMaxtime; - m_soundFile->SetCurrentPos(int(m_seekTime * lPostime)); + m_soundFile->SetCurrentPos(int(m_seekTime * lPostime / 1000)); m_seekTime = -1.0; } diff --git a/src/plugins/Input/modplug/decoder_modplug.h b/src/plugins/Input/modplug/decoder_modplug.h index 71f082c4a..8a14443b3 100644 --- a/src/plugins/Input/modplug/decoder_modplug.h +++ b/src/plugins/Input/modplug/decoder_modplug.h @@ -33,7 +33,7 @@ public: // Standard Decoder API bool initialize(); - qint64 lengthInSeconds(); + qint64 totalTime(); void seek(qint64); void stop(); @@ -67,7 +67,7 @@ private: bool m_done, m_finish; long m_freq, m_bitrate; int m_chan, m_sampleSize; - unsigned long m_output_size; + qint64 m_output_size; qint64 m_totalTime, m_seekTime; double m_preampFactor; bool m_usePreamp; diff --git a/src/plugins/Input/mpc/decoder_mpc.cpp b/src/plugins/Input/mpc/decoder_mpc.cpp index 9b3679dd3..d8d739c1c 100644 --- a/src/plugins/Input/mpc/decoder_mpc.cpp +++ b/src/plugins/Input/mpc/decoder_mpc.cpp @@ -112,14 +112,10 @@ DecoderMPC::DecoderMPC(QObject *parent, DecoderFactory *d, QIODevice *i, Output freq = 0; bitrate = 0; seekTime = -1.0; - totalTime = 0.0; + m_totalTime = 0.0; chan = 0; output_size = 0; m_data = 0; - - - - } @@ -191,7 +187,7 @@ bool DecoderMPC::initialize() chan = 0; output_size = 0; seekTime = -1.0; - totalTime = 0.0; + m_totalTime = 0.0; if (!input()) @@ -242,19 +238,19 @@ bool DecoderMPC::initialize() qWarning("DecoderMPC: cannot get info."); return FALSE; } - totalTime = mpc_streaminfo_get_length(&data()->info); + m_totalTime = mpc_streaminfo_get_length(&data()->info) * 1000; inited = TRUE; qDebug("DecoderMPC: initialize succes"); return TRUE; } -qint64 DecoderMPC::lengthInSeconds() +qint64 DecoderMPC::totalTime() { if (! inited) return 0; - return totalTime; + return m_totalTime; } @@ -292,7 +288,7 @@ void DecoderMPC::run() if (seekTime >= 0.0) { - mpc_decoder_seek_seconds(&data()->decoder, seekTime); + mpc_decoder_seek_seconds(&data()->decoder, seekTime/1000); seekTime = -1.0; } MPC_SAMPLE_FORMAT buffer[MPC_DECODER_BUFFER_LENGTH]; diff --git a/src/plugins/Input/mpc/decoder_mpc.h b/src/plugins/Input/mpc/decoder_mpc.h index 733fcd8ca..052f634c8 100644 --- a/src/plugins/Input/mpc/decoder_mpc.h +++ b/src/plugins/Input/mpc/decoder_mpc.h @@ -40,7 +40,7 @@ public: // Standard Decoder API bool initialize(); - qint64 lengthInSeconds(); + qint64 totalTime(); void seek(qint64); void stop(); @@ -68,8 +68,8 @@ private: bool done, m_finish; long len, freq, bitrate; int chan; - unsigned long output_size; - qint64 totalTime, seekTime; + qint64 output_size; + qint64 m_totalTime, seekTime; }; diff --git a/src/plugins/Input/mplayer/decoder_mplayer.cpp b/src/plugins/Input/mplayer/decoder_mplayer.cpp index 45b835a15..f9a5ff26a 100644 --- a/src/plugins/Input/mplayer/decoder_mplayer.cpp +++ b/src/plugins/Input/mplayer/decoder_mplayer.cpp @@ -123,15 +123,15 @@ bool DecoderMplayer::initialize() return TRUE; } -qint64 DecoderMplayer::lengthInSeconds() +qint64 DecoderMplayer::totalTime() { - return m_length; + return m_length * 1000; } void DecoderMplayer::seek(qint64 pos) { if (m_process->state() == QProcess::Running) - m_process->write(QString("seek %1 \n").arg(pos - m_currentTime).toLocal8Bit ()); + m_process->write(QString("seek %1 \n").arg(pos/1000 - m_currentTime).toLocal8Bit ()); } void DecoderMplayer::stop() @@ -173,8 +173,8 @@ void DecoderMplayer::readStdOut() { StateHandler::instance()->dispatch(Qmmp::Playing); m_currentTime = (qint64) rx_av.cap(1).toDouble(); - StateHandler::instance()->dispatch(m_currentTime, - m_length, + StateHandler::instance()->dispatch(m_currentTime * 1000, + m_length * 1000, m_bitrate, m_samplerate, m_bitsPerSample, diff --git a/src/plugins/Input/mplayer/decoder_mplayer.h b/src/plugins/Input/mplayer/decoder_mplayer.h index 2fff55ab0..38d47e629 100644 --- a/src/plugins/Input/mplayer/decoder_mplayer.h +++ b/src/plugins/Input/mplayer/decoder_mplayer.h @@ -49,7 +49,7 @@ public: // Standard Decoder API bool initialize(); - qint64 lengthInSeconds(); + qint64 totalTime(); void seek(qint64); void stop(); void pause(); diff --git a/src/plugins/Input/sndfile/decoder_sndfile.cpp b/src/plugins/Input/sndfile/decoder_sndfile.cpp index 4568a2fd9..9152913fe 100644 --- a/src/plugins/Input/sndfile/decoder_sndfile.cpp +++ b/src/plugins/Input/sndfile/decoder_sndfile.cpp @@ -133,9 +133,9 @@ bool DecoderSndFile::initialize() m_freq = snd_info.samplerate; m_chan = snd_info.channels; - m_totalTime = (double) snd_info.frames / m_freq; + m_totalTime = snd_info.frames * 1000 / m_freq; - m_bitrate = QFileInfo(m_path).size () * 8.0 / m_totalTime / 1000.0 + 0.5; + m_bitrate = QFileInfo(m_path).size () * 8.0 / m_totalTime + 0.5; configure(m_freq, m_chan, 16); m_buf = new short[bks / sizeof(short)]; @@ -146,7 +146,7 @@ bool DecoderSndFile::initialize() } -qint64 DecoderSndFile::lengthInSeconds() +qint64 DecoderSndFile::totalTime() { if (! m_inited) return 0; @@ -196,7 +196,7 @@ void DecoderSndFile::run() if (m_seekTime >= 0) { - m_output_size = sf_seek(m_sndfile, m_freq*m_seekTime, SEEK_SET); + m_output_size = sf_seek(m_sndfile, m_freq*m_seekTime/1000, SEEK_SET); m_seekTime = -1.0; } diff --git a/src/plugins/Input/sndfile/decoder_sndfile.h b/src/plugins/Input/sndfile/decoder_sndfile.h index e221065f2..c62544193 100644 --- a/src/plugins/Input/sndfile/decoder_sndfile.h +++ b/src/plugins/Input/sndfile/decoder_sndfile.h @@ -35,7 +35,7 @@ public: // Standard Decoder API bool initialize(); - qint64 lengthInSeconds(); + qint64 totalTime(); void seek(qint64); void stop(); diff --git a/src/plugins/Input/vorbis/decoder_vorbis.cpp b/src/plugins/Input/vorbis/decoder_vorbis.cpp index 901e10f86..34b9c10dd 100644 --- a/src/plugins/Input/vorbis/decoder_vorbis.cpp +++ b/src/plugins/Input/vorbis/decoder_vorbis.cpp @@ -90,7 +90,7 @@ DecoderVorbis::DecoderVorbis(QObject *parent, DecoderFactory *d, QIODevice *i, O freq = 0; bitrate = 0; seekTime = -1.0; - totalTime = 0.0; + m_totalTime = 0.0; chan = 0; output_size = 0; } @@ -159,7 +159,7 @@ bool DecoderVorbis::initialize() stat = chan = 0; output_size = 0; seekTime = -1.0; - totalTime = 0.0; + m_totalTime = 0.0; if (! input()) { qDebug("DecoderVorbis: cannot initialize. No input"); @@ -200,8 +200,8 @@ bool DecoderVorbis::initialize() bitrate = ov_bitrate(&oggfile, -1) / 1000; chan = 0; - totalTime = long(ov_time_total(&oggfile, 0)); - totalTime = totalTime < 0 ? 0 : totalTime; + m_totalTime = ov_time_total(&oggfile, -1) * 1000; + m_totalTime = qMax(qint64(0), m_totalTime); vorbis_info *ogginfo = ov_info(&oggfile, -1); if (ogginfo) @@ -217,12 +217,12 @@ bool DecoderVorbis::initialize() } -qint64 DecoderVorbis::lengthInSeconds() +qint64 DecoderVorbis::totalTime() { if (! inited) return 0; - return totalTime; + return m_totalTime; } @@ -314,10 +314,10 @@ void DecoderVorbis::run() if (seekTime >= 0.0) { - ov_time_seek(&oggfile, double(seekTime)); + ov_time_seek(&oggfile, (double) seekTime/1000); seekTime = -1.0; - output_size = long(ov_time_tell(&oggfile)) * long(freq * chan * 2); + output_size = ov_time_tell(&oggfile) * freq * chan * 2; } len = -1; while (len < 0) diff --git a/src/plugins/Input/vorbis/decoder_vorbis.h b/src/plugins/Input/vorbis/decoder_vorbis.h index f9609cac7..ec1158f31 100644 --- a/src/plugins/Input/vorbis/decoder_vorbis.h +++ b/src/plugins/Input/vorbis/decoder_vorbis.h @@ -20,7 +20,7 @@ public: // Standard Decoder API bool initialize(); - qint64 lengthInSeconds(); + qint64 totalTime(); void seek(qint64); void stop(); @@ -55,8 +55,8 @@ private: bool done, m_finish; long len, freq, bitrate; int chan; - unsigned long output_size; - qint64 totalTime, seekTime; + qint64 output_size; + qint64 m_totalTime, seekTime; }; diff --git a/src/plugins/Input/wavpack/cueparser.cpp b/src/plugins/Input/wavpack/cueparser.cpp index e68499cf1..081912dba 100644 --- a/src/plugins/Input/wavpack/cueparser.cpp +++ b/src/plugins/Input/wavpack/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/wavpack/cueparser.h b/src/plugins/Input/wavpack/cueparser.h index fccd85912..b30b87bfa 100644 --- a/src/plugins/Input/wavpack/cueparser.h +++ b/src/plugins/Input/wavpack/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/wavpack/decoder_wavpack.cpp b/src/plugins/Input/wavpack/decoder_wavpack.cpp index 87892f9da..082c148b4 100644 --- a/src/plugins/Input/wavpack/decoder_wavpack.cpp +++ b/src/plugins/Input/wavpack/decoder_wavpack.cpp @@ -166,12 +166,12 @@ bool DecoderWavPack::initialize() if (m_length) m_totalTime = m_length; else - m_totalTime = (qint64) WavpackGetNumSamples(m_context) / m_freq; + m_totalTime = (qint64) WavpackGetNumSamples(m_context) * 1000 / m_freq; qDebug("DecoderWavPack: initialize succes"); return TRUE; } -qint64 DecoderWavPack::lengthInSeconds() +qint64 DecoderWavPack::totalTime() { if (!m_inited) return 0; @@ -223,7 +223,7 @@ void DecoderWavPack::run() //seeking if (m_seekTime >= 0.0) { - WavpackSeekSample (m_context, m_seekTime * m_freq); + WavpackSeekSample (m_context, m_seekTime * m_freq / 1000); m_seekTime = -1.0; } //stop if track ended diff --git a/src/plugins/Input/wavpack/decoder_wavpack.h b/src/plugins/Input/wavpack/decoder_wavpack.h index d7a87cde6..fe2a0a092 100644 --- a/src/plugins/Input/wavpack/decoder_wavpack.h +++ b/src/plugins/Input/wavpack/decoder_wavpack.h @@ -36,7 +36,7 @@ public: // Standard Decoder API bool initialize(); - qint64 lengthInSeconds(); + qint64 totalTime(); void seek(qint64); void stop(); @@ -59,7 +59,7 @@ private: bool m_done, m_finish; long m_freq, m_bitrate; int m_chan; - unsigned long m_output_size; + qint64 m_output_size; qint64 m_totalTime, m_seekTime; QString m_path; qint64 m_offset; |
