From 0b46e2db06ec1bbfc3aee819787386ace9dad66c Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sat, 7 Mar 2009 22:43:26 +0000 Subject: improved seeking accuracy git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@827 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/Input/vorbis/decoder_vorbis.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/plugins/Input/vorbis/decoder_vorbis.cpp') 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) -- cgit v1.2.3-13-gbd6f