diff options
author | Johannes Schickel | 2010-01-05 02:27:24 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-01-05 02:27:24 +0000 |
commit | f5c3bd887e2257fc7fdfb0d141ddbae592f1e83b (patch) | |
tree | ebbd8705d76d5d23a2b217f7bd31012afe271d2c /sound/vorbis.cpp | |
parent | 00e48f687ff0b0302383abfb9971f5420dc3c265 (diff) | |
download | scummvm-rg350-f5c3bd887e2257fc7fdfb0d141ddbae592f1e83b.tar.gz scummvm-rg350-f5c3bd887e2257fc7fdfb0d141ddbae592f1e83b.tar.bz2 scummvm-rg350-f5c3bd887e2257fc7fdfb0d141ddbae592f1e83b.zip |
- Add a new SeekableAudioStream interface. Soon to be used to replace audio stream specific looping code by generic code in Mixer...
- Adapted some existing AudioStreams to implement that interface (not tested!)
svn-id: r47013
Diffstat (limited to 'sound/vorbis.cpp')
-rw-r--r-- | sound/vorbis.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/sound/vorbis.cpp b/sound/vorbis.cpp index bb73a26d06..eced67726a 100644 --- a/sound/vorbis.cpp +++ b/sound/vorbis.cpp @@ -85,7 +85,7 @@ static ov_callbacks g_stream_wrap = { #pragma mark - -class VorbisInputStream : public AudioStream { +class VorbisInputStream : public SeekableAudioStream { protected: Common::SeekableReadStream *_inStream; bool _disposeAfterUse; @@ -138,6 +138,8 @@ public: #endif } + bool seek(const Timestamp &where); + protected: bool refill(); }; @@ -240,6 +242,23 @@ int VorbisInputStream::readBuffer(int16 *buffer, const int numSamples) { return samples; } +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) { + warning("Error seeking in Vorbis stream (%d)", res); + _pos = _bufferEnd; + return false; + } + + return refill(); +} + bool VorbisInputStream::refill() { // Read the samples int res; @@ -314,7 +333,7 @@ bool VorbisInputStream::refill() { #pragma mark - -AudioStream *makeVorbisStream( +SeekableAudioStream *makeVorbisStream( Common::SeekableReadStream *stream, bool disposeAfterUse, uint32 startTime, |