From 8c79b6f6ee2cb11e1352df5fa4faf70903eca364 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 6 Jan 2010 16:11:21 +0000 Subject: Adapt FLAC and Vorbis to use calculateSampleOffset in their seek implementation. svn-id: r47085 --- sound/flac.cpp | 4 +--- sound/vorbis.cpp | 10 ++-------- 2 files changed, 3 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/flac.cpp b/sound/flac.cpp index 28db39f9f3..b592468baf 100644 --- a/sound/flac.cpp +++ b/sound/flac.cpp @@ -335,9 +335,7 @@ bool FlacInputStream::seekAbsolute(FLAC__uint64 sample) { bool FlacInputStream::seek(const Timestamp &where) { _sampleCache.bufFill = 0; _sampleCache.bufReadPos = NULL; - // Compute the start/end sample (we use floating point arithmetics here to - // avoid overflows). - return seekAbsolute((FLAC__uint64)(where.msecs() * (_streaminfo.sample_rate / 1000.0))); + return seekAbsolute((FLAC__uint64)calculateSampleOffset(where, _streaminfo.sample_rate)); } int FlacInputStream::readBuffer(int16 *buffer, const int numSamples) { diff --git a/sound/vorbis.cpp b/sound/vorbis.cpp index 2fd7c978be..1ed608c0b5 100644 --- a/sound/vorbis.cpp +++ b/sound/vorbis.cpp @@ -240,14 +240,8 @@ int VorbisInputStream::readBuffer(int16 *buffer, const int numSamples) { } bool VorbisInputStream::seek(const Timestamp &where) { -#ifdef USE_TREMOR - ogg_int64_t pos = where.msecs(); -#else - double pos = where.msecs() / 1000.0; -#endif - - int res = ov_time_seek(&_ovFile, pos); - if (res < 0) { + int res = ov_pcm_seek(&_ovFile, calculateSampleOffset(where, getRate())); + if (res) { warning("Error seeking in Vorbis stream (%d)", res); _pos = _bufferEnd; return false; -- cgit v1.2.3