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 | |
| 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')
47 files changed, 178 insertions, 172 deletions
diff --git a/src/plugins/General/mpris/playerobject.cpp b/src/plugins/General/mpris/playerobject.cpp index 160d32e56..c043a2e63 100644 --- a/src/plugins/General/mpris/playerobject.cpp +++ b/src/plugins/General/mpris/playerobject.cpp @@ -135,8 +135,8 @@ QVariantMap PlayerObject::GetMetadata() map.insert("artist", m_core->metaData(Qmmp::ARTIST)); map.insert("album", m_core->metaData(Qmmp::ALBUM)); map.insert("tracknumber", m_core->metaData(Qmmp::TRACK)); - map.insert("time", m_core->length()); - map.insert("mtime", m_core->length() * 1000); + map.insert("time", m_core->totalTime()/1000); + map.insert("mtime", m_core->totalTime()); map.insert("genre", m_core->metaData(Qmmp::GENRE)); map.insert("comment", m_core->metaData(Qmmp::COMMENT)); map.insert("audio-bitrate", m_core->bitrate()); @@ -152,7 +152,7 @@ int PlayerObject::GetCaps() caps |= CAN_PAUSE; else caps |= CAN_PLAY; - if ((GetStatus().state < 2) && (m_core->length() > 0)) + if ((GetStatus().state < 2) && (m_core->totalTime() > 0)) caps |= CAN_SEEK; caps |= CAN_GO_NEXT; caps |= CAN_GO_PREV; @@ -174,12 +174,12 @@ int PlayerObject::VolumeGet() void PlayerObject::PositionSet(int pos) { - m_core->seek(pos / 1000); + m_core->seek(pos); } int PlayerObject::PositionGet() { - return m_core->elapsed() * 1000; + return m_core->elapsed(); } void PlayerObject::updateCaps() diff --git a/src/plugins/General/notifier/notifier.cpp b/src/plugins/General/notifier/notifier.cpp index d1254a78b..42b07eb2d 100644 --- a/src/plugins/General/notifier/notifier.cpp +++ b/src/plugins/General/notifier/notifier.cpp @@ -85,7 +85,7 @@ void Notifier::showMetaData() file.write(m_core->metaData(Qmmp::ARTIST).toUtf8()+"\n"); file.write(m_core->metaData(Qmmp::ALBUM).toUtf8()+"\n"); file.write(m_core->metaData(Qmmp::TRACK).toUtf8()+"\n"); - file.write(QString("%1").arg(m_core->length()).toUtf8()+"\n"); + file.write(QString("%1").arg(m_core->totalTime()/1000).toUtf8()+"\n"); file.close(); } diff --git a/src/plugins/General/notifier/popupwidget.cpp b/src/plugins/General/notifier/popupwidget.cpp index 9e7c3cc53..f6a7c7e73 100644 --- a/src/plugins/General/notifier/popupwidget.cpp +++ b/src/plugins/General/notifier/popupwidget.cpp @@ -83,10 +83,10 @@ void PopupWidget::showMetaData() QString title = core->metaData(Qmmp::TITLE); if (title.isEmpty()) title = core->metaData(Qmmp::URL).section('/',-1); - if (core->length() > 0) + if (core->totalTime() > 0) { title.append(" "); - title.append(QString("(%1:%2)").arg(core->length()/60).arg(core->length()%60, 2, 10, QChar('0'))); + title.append(QString("(%1:%2)").arg(core->totalTime()/60000).arg(core->totalTime()%60000, 2, 10, QChar('0'))); } m_label1->setText("<b>" + title + "</b>"); diff --git a/src/plugins/General/scrobbler/scrobbler.cpp b/src/plugins/General/scrobbler/scrobbler.cpp index 8cf79d4c6..d73f85fea 100644 --- a/src/plugins/General/scrobbler/scrobbler.cpp +++ b/src/plugins/General/scrobbler/scrobbler.cpp @@ -132,7 +132,7 @@ void Scrobbler::updateMetaData() if (m_state == Qmmp::Playing && !metadata.value(Qmmp::TITLE).isEmpty() //skip empty tags && !metadata.value(Qmmp::ARTIST).isEmpty() - && m_core->length() //skip stream + && m_core->totalTime() //skip stream && !metadata.value(Qmmp::ARTIST).contains("&") //skip tags with special symbols && !metadata.value(Qmmp::TITLE).contains("&") && !metadata.value(Qmmp::ALBUM).contains("&") @@ -140,7 +140,7 @@ void Scrobbler::updateMetaData() && !metadata.value(Qmmp::TITLE).contains("=") && !metadata.value(Qmmp::ALBUM).contains("=")) { - m_song = SongInfo(metadata, m_core->length()); + m_song = SongInfo(metadata, m_core->totalTime()/1000); if (isReady() && m_notificationid == 0) sendNotification(m_song); 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; diff --git a/src/qmmp/decoder.h b/src/qmmp/decoder.h index df1313561..d4190e733 100644 --- a/src/qmmp/decoder.h +++ b/src/qmmp/decoder.h @@ -42,7 +42,7 @@ public: // Standard Decoder API virtual bool initialize() = 0; - virtual qint64 lengthInSeconds() = 0; + virtual qint64 totalTime() = 0; virtual void seek(qint64) = 0; virtual void stop() = 0; virtual void pause(){}; diff --git a/src/qmmp/output.cpp b/src/qmmp/output.cpp index 860e8b823..c5ad809f7 100644 --- a/src/qmmp/output.cpp +++ b/src/qmmp/output.cpp @@ -24,8 +24,8 @@ Output::Output (QObject* parent) : QThread (parent), m_recycler (stackSize()) m_channels = 0; m_kbps = 0; m_totalWritten = 0; - m_currentSeconds = -1; - m_bytesPerSecond = 0; + m_currentMilliseconds = -1; + m_bytesPerMillisecond = 0; m_userStop = FALSE; m_pause = FALSE; } @@ -35,7 +35,7 @@ void Output::configure(quint32 freq, int chan, int prec) m_frequency = freq; m_channels = chan; m_precision = prec; - m_bytesPerSecond = freq * chan * (prec / 8); + m_bytesPerMillisecond = freq * chan * (prec / 8) / 1000; } void Output::pause() @@ -57,8 +57,8 @@ qint64 Output::written() void Output::seek(qint64 pos) { - m_totalWritten = pos * m_bytesPerSecond; - m_currentSeconds = -1; + m_totalWritten = pos * m_bytesPerMillisecond; + m_currentMilliseconds = -1; } Recycler *Output::recycler() @@ -125,7 +125,7 @@ void Output::dispatch(const Qmmp::State &state) void Output::run() { mutex()->lock (); - if (!m_bytesPerSecond) + if (!m_bytesPerMillisecond) { qWarning("Output: invalid audio parameters"); mutex()->unlock (); @@ -190,15 +190,15 @@ void Output::run() void Output::status() { - long ct = (m_totalWritten - latency()) / m_bytesPerSecond; + qint64 ct = (m_totalWritten - latency()) / m_bytesPerMillisecond; if (ct < 0) ct = 0; - if (ct > m_currentSeconds) + if (ct > m_currentMilliseconds) { - m_currentSeconds = ct; - dispatch(m_currentSeconds, m_totalWritten, m_kbps, + m_currentMilliseconds = ct; + dispatch(m_currentMilliseconds, m_totalWritten, m_kbps, m_frequency, m_precision, m_channels); } } diff --git a/src/qmmp/output.h b/src/qmmp/output.h index 07b9d7f67..d50be846d 100644 --- a/src/qmmp/output.h +++ b/src/qmmp/output.h @@ -76,9 +76,9 @@ private: StateHandler *m_handler; quint32 m_frequency; int m_channels, m_precision, m_kbps; - qint64 m_bytesPerSecond; + qint64 m_bytesPerMillisecond; bool m_userStop, m_pause; - qint64 m_totalWritten, m_currentSeconds; + qint64 m_totalWritten, m_currentMilliseconds; static void checkFactories(); //TODO use QMap instead diff --git a/src/qmmp/soundcore.cpp b/src/qmmp/soundcore.cpp index f5225b1d3..4fd8cd0c8 100644 --- a/src/qmmp/soundcore.cpp +++ b/src/qmmp/soundcore.cpp @@ -249,9 +249,9 @@ const QString SoundCore::url() return m_source; } -qint64 SoundCore::length() const +qint64 SoundCore::totalTime() const { - return (m_decoder) ? m_decoder->lengthInSeconds() : 0; + return (m_decoder) ? m_decoder->totalTime() : 0; } void SoundCore::setEQ(double bands[10], double preamp) diff --git a/src/qmmp/soundcore.h b/src/qmmp/soundcore.h index 03af722a9..75d8e4f47 100644 --- a/src/qmmp/soundcore.h +++ b/src/qmmp/soundcore.h @@ -48,7 +48,7 @@ public: /*! * Returns length in seconds */ - qint64 length() const; + qint64 totalTime() const; /*! * Sets equalizer settings. Each item of \p bands[] and \p reamp should be diff --git a/src/qmmp/statehandler.cpp b/src/qmmp/statehandler.cpp index ea65241ff..3348b36a7 100644 --- a/src/qmmp/statehandler.cpp +++ b/src/qmmp/statehandler.cpp @@ -23,6 +23,8 @@ #include "soundcore.h" #include "statehandler.h" +#define TICK_INTERVAL 250 + StateHandler* StateHandler::m_instance = 0; @@ -56,15 +58,15 @@ void StateHandler::dispatch(qint64 elapsed, int channels) { m_mutex.lock(); - if (m_elapsed != elapsed) + if (llabs(m_elapsed - elapsed) > TICK_INTERVAL) { m_elapsed = elapsed; emit (elapsedChanged(elapsed)); - } - if (m_bitrate != bitrate) - { - m_bitrate = bitrate; - emit (bitrateChanged(bitrate)); + if (m_bitrate != bitrate) + { + m_bitrate = bitrate; + emit (bitrateChanged(bitrate)); + } } if (m_frequency != frequency) { diff --git a/src/ui/display.cpp b/src/ui/display.cpp index d9967b74b..3280a5104 100644 --- a/src/ui/display.cpp +++ b/src/ui/display.cpp @@ -162,13 +162,13 @@ MainDisplay::~MainDisplay() void MainDisplay::setTime (qint64 t) { - posbar->setValue (t); //TODO use qint64 - m_timeIndicator->setTime(t); + posbar->setValue (t); + m_timeIndicator->setTime(t/1000); } void MainDisplay::setDuration(qint64 t) { posbar->setMax (t); - m_timeIndicator->setSongDuration(t); + m_timeIndicator->setSongDuration(t/1000); } void MainDisplay::setState(Qmmp::State state) @@ -179,7 +179,7 @@ void MainDisplay::setState(Qmmp::State state) { m_playstatus->setStatus(PlayStatus::PLAY); m_timeIndicator->setNeedToShowTime(TRUE); - setDuration(m_core->length()); + setDuration(m_core->totalTime()); break; } case Qmmp::Paused: diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index d02490f49..94253925a 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -167,7 +167,7 @@ void MainWindow::replay() play(); } -void MainWindow::seek(int pos) +void MainWindow::seek(qint64 pos) { if (!seeking) m_core->seek(pos); diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index 5442c9dfb..d89def113 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -67,7 +67,7 @@ public: bool processCommandArgs(const QStringList &list,const QString& cwd); public slots: - void seek(int); + void seek(qint64); void previous(); void play(); void pause(); diff --git a/src/ui/playlist.cpp b/src/ui/playlist.cpp index 8913b58c1..b9369d2e3 100644 --- a/src/ui/playlist.cpp +++ b/src/ui/playlist.cpp @@ -461,14 +461,14 @@ void PlayList::setTime(qint64 time) if (time < 0) m_current_time->display ("--:--"); else - m_current_time->display (formatTime (time)); + m_current_time->display (formatTime (time/1000)); m_current_time->update(); if (m_playListModel && SoundCore::instance()) { m_playListModel->totalLength(); QString str_length = formatTime (m_playListModel->totalLength()) + - "/" + formatTime (SoundCore::instance()->length()); + "/" + formatTime (SoundCore::instance()->totalTime()/1000); m_length_totalLength->display (str_length); m_length_totalLength->update(); diff --git a/src/ui/positionbar.cpp b/src/ui/positionbar.cpp index 1660f192e..423aaee7b 100644 --- a/src/ui/positionbar.cpp +++ b/src/ui/positionbar.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Ilya Kotov * + * Copyright (C) 2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -73,7 +73,7 @@ void PositionBar::mouseMoveEvent (QMouseEvent *e) { if (m_moving) { - int po = e->x(); + qint64 po = e->x(); po = po - press_pos; if (0<=po && po<=width()-30) @@ -96,7 +96,7 @@ void PositionBar::mouseReleaseEvent(QMouseEvent*) m_moving = FALSE; } -void PositionBar::setValue(int v) +void PositionBar::setValue(qint64 v) { if (m_moving || m_max == 0) return; @@ -104,7 +104,7 @@ void PositionBar::setValue(int v) draw(FALSE); } -void PositionBar::setMax(int max) +void PositionBar::setMax(qint64 max) { m_max = max; draw(FALSE); @@ -119,7 +119,7 @@ void PositionBar::updateSkin() void PositionBar::draw(bool pressed) { - int p=int(ceil(double(m_value-m_min)*(width()-30)/(m_max-m_min))); + qint64 p=qint64(ceil(double(m_value-m_min)*(width()-30)/(m_max-m_min))); m_pixmap = m_skin->getPosBar(); if (m_max > 0) { @@ -133,7 +133,7 @@ void PositionBar::draw(bool pressed) m_pos = p; } -int PositionBar::convert(int p) +qint64 PositionBar::convert(qint64 p) { - return int(ceil(double(m_max-m_min)*(p)/(width()-30)+m_min)); + return qint64(ceil(double(m_max-m_min)*(p)/(width()-30)+m_min)); } diff --git a/src/ui/positionbar.h b/src/ui/positionbar.h index ea03ef14a..cbabab9aa 100644 --- a/src/ui/positionbar.h +++ b/src/ui/positionbar.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Ilya Kotov * + * Copyright (C) 2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -41,12 +41,12 @@ public: ~PositionBar(); public slots: - void setValue(int); - int value()const{return m_value;} - void setMax(int); + void setValue(qint64); + qint64 value()const{return m_value;} + void setMax(qint64); signals: - void sliderMoved (int); + void sliderMoved (qint64); private slots: void updateSkin(); @@ -54,11 +54,11 @@ private slots: private: Skin *m_skin; bool m_moving; - int press_pos; - int m_max, m_min, m_pos, m_value, m_old; + qint64 press_pos; + qint64 m_max, m_min, m_pos, m_value, m_old; QPixmap m_pixmap; MainWindow *mw; - int convert(int); // value = convert(position); + qint64 convert(qint64); // value = convert(position); void draw(bool pressed = TRUE); protected: diff --git a/src/ui/titlebar.cpp b/src/ui/titlebar.cpp index 00a59e1bc..d094a8c49 100644 --- a/src/ui/titlebar.cpp +++ b/src/ui/titlebar.cpp @@ -216,7 +216,7 @@ void TitleBar::setTime(qint64 time) if (time < 0) m_currentTime->display("--:--"); else - m_currentTime->display(formatTime(time)); + m_currentTime->display(formatTime(time/1000)); } void TitleBar::updateMask() |
