diff options
author | Johannes Schickel | 2010-01-10 15:20:14 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-01-10 15:20:14 +0000 |
commit | 6ca0570fe3bb3f3765677ff8cd3f9e0cbf062d6b (patch) | |
tree | 732a2cc846d6f70dd2c42b0dc0cd52d45de34bb2 /sound/audiostream.h | |
parent | bda3fc940c3ecca011b04a32fb20970f53f49d1c (diff) | |
download | scummvm-rg350-6ca0570fe3bb3f3765677ff8cd3f9e0cbf062d6b.tar.gz scummvm-rg350-6ca0570fe3bb3f3765677ff8cd3f9e0cbf062d6b.tar.bz2 scummvm-rg350-6ca0570fe3bb3f3765677ff8cd3f9e0cbf062d6b.zip |
- Add a SubLoopingAudioStream, which loops a nested part of a stream and thus features the same looping capabilites as LinearMemoryStream and LinearDiskStream.
- Remove custom looping code from LinearMemoryStream and LinearDiskStream.
- Adapt various client code to the changes.
svn-id: r47226
Diffstat (limited to 'sound/audiostream.h')
-rw-r--r-- | sound/audiostream.h | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/sound/audiostream.h b/sound/audiostream.h index 817cd36f95..003fef64f7 100644 --- a/sound/audiostream.h +++ b/sound/audiostream.h @@ -216,6 +216,42 @@ public: AudioStream *makeLoopingAudioStream(SeekableAudioStream *stream, Timestamp start, Timestamp end, uint loops); /** + * A looping audio stream, which features looping of a nested part of the + * stream. + * + * NOTE: + * Currently this implementation stops after the nested loop finished + * playback. + * + * IMPORTANT: + * This might be merged with SubSeekableAudioStream for playback purposes. + * (After extending it to accept a start time). + */ +class SubLoopingAudioStream : public AudioStream { +public: + SubLoopingAudioStream(SeekableAudioStream *stream, uint loops, + const Timestamp loopStart, + const Timestamp loopEnd, + bool disposeAfterUse = true); + ~SubLoopingAudioStream(); + + int readBuffer(int16 *buffer, const int numSamples); + bool endOfData() const { return _done; } + + bool isStereo() const { return _parent->isStereo(); } + int getRate() const { return _parent->getRate(); } +private: + SeekableAudioStream *_parent; + bool _disposeAfterUse; + + uint _loops; + Timestamp _pos; + Timestamp _loopStart, _loopEnd; + + bool _done; +}; + +/** * A SubSeekableAudioStream provides access to a SeekableAudioStream * just in the range [start, end). * The same caveats apply to SubSeekableAudioStream as do to SeekableAudioStream. @@ -259,6 +295,8 @@ private: Timestamp _pos, _length; }; +SeekableAudioStream *makeLinearInputStream(const byte *ptr, uint32 len, int rate, byte flags); + /** * Factory function for a raw linear AudioStream, which will simply treat all * data in the buffer described by ptr and len as raw sample data in the @@ -267,8 +305,8 @@ private: * signed native endian). Optionally supports (infinite) looping of a portion * of the data. */ -SeekableAudioStream *makeLinearInputStream(const byte *ptr, uint32 len, int rate, - byte flags, uint loopStart, uint loopEnd); +AudioStream *makeLinearInputStream(const byte *ptr, uint32 len, int rate, + byte flags, uint loopStart, uint loopEnd); /** @@ -279,6 +317,8 @@ struct LinearDiskStreamAudioBlock { int32 len; ///< Length of the block (in samples) }; +SeekableAudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, + int numBlocks, int rate, byte flags, bool disposeStream); /** * Factory function for a Linear Disk Stream. This can stream linear (PCM) @@ -286,7 +326,7 @@ struct LinearDiskStreamAudioBlock { * LinearDiskStreamAudioBlock which defines the start position and length of * each block of uncompressed audio in the stream. */ -SeekableAudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, +AudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, int numBlocks, int rate, byte flags, bool disposeStream, uint loopStart, uint loopEnd); class QueuingAudioStream : public Audio::AudioStream { |