diff options
-rw-r--r-- | engines/sword2/music.cpp | 40 |
1 files changed, 3 insertions, 37 deletions
diff --git a/engines/sword2/music.cpp b/engines/sword2/music.cpp index 233d9369d2..ae6e2f1268 100644 --- a/engines/sword2/music.cpp +++ b/engines/sword2/music.cpp @@ -53,40 +53,6 @@ namespace Sword2 { -/** - * This class behaves like SeekableSubReadStream, except it remembers where the - * previous read() or seek() took it, so that it can continue from that point - * the next time. This is because we're frequently streaming two pieces of - * music from the same file. - */ -class SafeSubReadStream : public Common::SeekableSubReadStream { -protected: - uint32 _previousPos; -public: - SafeSubReadStream(SeekableReadStream *parentStream, uint32 begin, uint32 end); - virtual uint32 read(void *dataPtr, uint32 dataSize); - virtual bool seek(int32 offset, int whence = SEEK_SET); -}; - -SafeSubReadStream::SafeSubReadStream(SeekableReadStream *parentStream, uint32 begin, uint32 end) - : SeekableSubReadStream(parentStream, begin, end, DisposeAfterUse::NO) { - _previousPos = 0; -} - -uint32 SafeSubReadStream::read(void *dataPtr, uint32 dataSize) { - uint32 result; - SeekableSubReadStream::seek(_previousPos); - result = SeekableSubReadStream::read(dataPtr, dataSize); - _previousPos = pos(); - return result; -} - -bool SafeSubReadStream::seek(int32 offset, int whence) { - bool result = SeekableSubReadStream::seek(offset, whence); - _previousPos = pos(); - return result; -} - static Audio::AudioStream *makeCLUStream(Common::File *fp, int size); static Audio::AudioStream *makePSXCLUStream(Common::File *fp, int size); @@ -197,19 +163,19 @@ static Audio::AudioStream *getAudioStream(SoundFileHandle *fh, const char *base, return makeCLUStream(&fh->file, enc_len); #ifdef USE_MAD case kMP3Mode: { - SafeSubReadStream *tmp = new SafeSubReadStream(&fh->file, pos, pos + enc_len); + Common::SafeSubReadStream *tmp = new Common::SafeSubReadStream(&fh->file, pos, pos + enc_len); return Audio::makeMP3Stream(tmp, DisposeAfterUse::YES); } #endif #ifdef USE_VORBIS case kVorbisMode: { - SafeSubReadStream *tmp = new SafeSubReadStream(&fh->file, pos, pos + enc_len); + Common::SafeSubReadStream *tmp = new Common::SafeSubReadStream(&fh->file, pos, pos + enc_len); return Audio::makeVorbisStream(tmp, DisposeAfterUse::YES); } #endif #ifdef USE_FLAC case kFLACMode: { - SafeSubReadStream *tmp = new SafeSubReadStream(&fh->file, pos, pos + enc_len); + Common::SafeSubReadStream *tmp = new Common::SafeSubReadStream(&fh->file, pos, pos + enc_len); return Audio::makeFLACStream(tmp, DisposeAfterUse::YES); } #endif |