aboutsummaryrefslogtreecommitdiff
path: root/sound/audiostream.h
diff options
context:
space:
mode:
authorJohannes Schickel2010-01-05 02:27:24 +0000
committerJohannes Schickel2010-01-05 02:27:24 +0000
commitf5c3bd887e2257fc7fdfb0d141ddbae592f1e83b (patch)
treeebbd8705d76d5d23a2b217f7bd31012afe271d2c /sound/audiostream.h
parent00e48f687ff0b0302383abfb9971f5420dc3c265 (diff)
downloadscummvm-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/audiostream.h')
-rw-r--r--sound/audiostream.h43
1 files changed, 36 insertions, 7 deletions
diff --git a/sound/audiostream.h b/sound/audiostream.h
index ac4f783f28..15e7ea6d33 100644
--- a/sound/audiostream.h
+++ b/sound/audiostream.h
@@ -30,8 +30,12 @@
#include "common/scummsys.h"
#include "common/stream.h"
+#include "sound/timestamp.h"
+
namespace Audio {
+class SeekableAudioStream;
+
/**
* Generic audio input stream. Subclasses of this are used to feed arbitrary
* sampled audio data into ScummVM's audio mixer.
@@ -93,10 +97,10 @@ public:
* @return an Audiostream ready to use in case of success;
* NULL in case of an error (e.g. invalid/nonexisting file)
*/
- static AudioStream* openStreamFile(const Common::String &basename,
- uint32 startTime = 0,
- uint32 duration = 0,
- uint numLoops = 1);
+ static SeekableAudioStream *openStreamFile(const Common::String &basename,
+ uint32 startTime = 0,
+ uint32 duration = 0,
+ uint numLoops = 1);
/**
* Sets number of times the stream is supposed to get looped
@@ -129,6 +133,32 @@ public:
virtual int32 getTotalPlayTime() const { return kUnknownPlayTime; }
};
+/**
+ * A seekable audio stream. Subclasses of this class implement a
+ * working seeking. The seeking itself is not required to be
+ * working when the stream is being played by Mixer!
+ */
+class SeekableAudioStream : public AudioStream {
+public:
+ /**
+ * Seeks to a given offset in the stream.
+ *
+ * @param where offset in milliseconds
+ * @return true on success, false on failure.
+ */
+ bool seek(uint32 where) {
+ return seek(Timestamp(where, getRate()));
+ }
+
+ /**
+ * Seeks to a given offset in the stream.
+ *
+ * @param where offset as timestamp
+ * @return true on success, false on failure.
+ */
+ virtual bool seek(const Timestamp &where) = 0;
+};
+
/**
* Factory function for a raw linear AudioStream, which will simply treat all
@@ -138,7 +168,7 @@ public:
* signed native endian). Optionally supports (infinite) looping of a portion
* of the data.
*/
-AudioStream *makeLinearInputStream(const byte *ptr, uint32 len, int rate,
+SeekableAudioStream *makeLinearInputStream(const byte *ptr, uint32 len, int rate,
byte flags, uint loopStart, uint loopEnd);
@@ -157,8 +187,7 @@ struct LinearDiskStreamAudioBlock {
* LinearDiskStreamAudioBlock which defines the start position and length of
* each block of uncompressed audio in the stream.
*/
-
-AudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block,
+SeekableAudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block,
int numBlocks, int rate, byte flags, bool disposeStream, uint loopStart, uint loopEnd);
/**