diff options
author | Johannes Schickel | 2010-01-27 08:08:33 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-01-27 08:08:33 +0000 |
commit | 812603e29eef2bd0c224a9b3b4c2bf29b2d3b653 (patch) | |
tree | 63cb6f484d6ebaad723b589b2d99300bc452ed6b /sound/decoders | |
parent | 9f2a619c06851429e261264c7f4b18a75cd4d7fd (diff) | |
download | scummvm-rg350-812603e29eef2bd0c224a9b3b4c2bf29b2d3b653.tar.gz scummvm-rg350-812603e29eef2bd0c224a9b3b4c2bf29b2d3b653.tar.bz2 scummvm-rg350-812603e29eef2bd0c224a9b3b4c2bf29b2d3b653.zip |
Fix invalid sample position on Timestamp to sample conversion for Stereo streams.
svn-id: r47591
Diffstat (limited to 'sound/decoders')
-rw-r--r-- | sound/decoders/flac.cpp | 2 | ||||
-rw-r--r-- | sound/decoders/raw.cpp | 11 | ||||
-rw-r--r-- | sound/decoders/vorbis.cpp | 2 |
3 files changed, 4 insertions, 11 deletions
diff --git a/sound/decoders/flac.cpp b/sound/decoders/flac.cpp index 29302827da..6fa7302a9a 100644 --- a/sound/decoders/flac.cpp +++ b/sound/decoders/flac.cpp @@ -294,7 +294,7 @@ bool FlacInputStream::seekAbsolute(FLAC__uint64 sample) { bool FlacInputStream::seek(const Timestamp &where) { _sampleCache.bufFill = 0; _sampleCache.bufReadPos = NULL; - return seekAbsolute((FLAC__uint64)calculateSampleOffset(where, _streaminfo.sample_rate)); + return seekAbsolute((FLAC__uint64)convertTimeToStreamPos(where, getRate(), isStereo()).totalNumberOfFrames()); } int FlacInputStream::readBuffer(int16 *buffer, const int numSamples) { diff --git a/sound/decoders/raw.cpp b/sound/decoders/raw.cpp index 6747111a1a..ecdde10250 100644 --- a/sound/decoders/raw.cpp +++ b/sound/decoders/raw.cpp @@ -41,13 +41,6 @@ namespace Audio { ((is16Bit ? (isLE ? READ_LE_UINT16(ptr) : READ_BE_UINT16(ptr)) : (*ptr << 8)) ^ (isUnsigned ? 0x8000 : 0)) -// TODO: Get rid of this -uint32 calculateSampleOffset(const Timestamp &where, int rate) { - return where.convertToFramerate(rate).totalNumberOfFrames(); -} - - - #pragma mark - #pragma mark --- RawMemoryStream --- #pragma mark - @@ -110,7 +103,7 @@ int RawMemoryStream<stereo, is16Bit, isUnsigned, isLE>::readBuffer(int16 *buffer template<bool stereo, bool is16Bit, bool isUnsigned, bool isLE> bool RawMemoryStream<stereo, is16Bit, isUnsigned, isLE>::seek(const Timestamp &where) { - const uint8 *ptr = _origPtr + calculateSampleOffset(where, getRate()) * (is16Bit ? 2 : 1) * (stereo ? 2 : 1); + const uint8 *ptr = _origPtr + convertTimeToStreamPos(where, getRate(), isStereo()).totalNumberOfFrames() * (is16Bit ? 2 : 1); if (ptr > _end) { _ptr = _end; return false; @@ -275,7 +268,7 @@ int RawDiskStream<stereo, is16Bit, isUnsigned, isLE>::readBuffer(int16 *buffer, template<bool stereo, bool is16Bit, bool isUnsigned, bool isLE> bool RawDiskStream<stereo, is16Bit, isUnsigned, isLE>::seek(const Timestamp &where) { - const uint32 seekSample = calculateSampleOffset(where, getRate()) * (stereo ? 2 : 1); + const uint32 seekSample = convertTimeToStreamPos(where, getRate(), isStereo()).totalNumberOfFrames(); uint32 curSample = 0; // Search for the disk block in which the specific sample is placed diff --git a/sound/decoders/vorbis.cpp b/sound/decoders/vorbis.cpp index 46a94a6214..f5ebc112c3 100644 --- a/sound/decoders/vorbis.cpp +++ b/sound/decoders/vorbis.cpp @@ -169,7 +169,7 @@ int VorbisInputStream::readBuffer(int16 *buffer, const int numSamples) { } bool VorbisInputStream::seek(const Timestamp &where) { - int res = ov_pcm_seek(&_ovFile, calculateSampleOffset(where, getRate())); + int res = ov_pcm_seek(&_ovFile, convertTimeToStreamPos(where, getRate(), isStereo()).totalNumberOfFrames()); if (res) { warning("Error seeking in Vorbis stream (%d)", res); _pos = _bufferEnd; |