aboutsummaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
Diffstat (limited to 'audio')
-rw-r--r--audio/decoders/raw.cpp20
-rw-r--r--audio/decoders/raw.h12
2 files changed, 32 insertions, 0 deletions
diff --git a/audio/decoders/raw.cpp b/audio/decoders/raw.cpp
index 9a9f79092a..477a8e7967 100644
--- a/audio/decoders/raw.cpp
+++ b/audio/decoders/raw.cpp
@@ -221,4 +221,24 @@ SeekableAudioStream *makeRawStream(const byte *buffer, uint32 size,
return makeRawStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, flags, DisposeAfterUse::YES);
}
+class PacketizedRawStream : public StatelessPacketizedAudioStream {
+public:
+ PacketizedRawStream(int rate, byte flags) :
+ StatelessPacketizedAudioStream(rate, ((flags & FLAG_STEREO) != 0) ? 2 : 1), _flags(flags) {}
+
+protected:
+ AudioStream *makeStream(Common::SeekableReadStream *data);
+
+private:
+ byte _flags;
+};
+
+AudioStream *PacketizedRawStream::makeStream(Common::SeekableReadStream *data) {
+ return makeRawStream(data, getRate(), _flags);
+}
+
+PacketizedAudioStream *makePacketizedRawStream(int rate, byte flags) {
+ return new PacketizedRawStream(rate, flags);
+}
+
} // End of namespace Audio
diff --git a/audio/decoders/raw.h b/audio/decoders/raw.h
index 14e7bd45fd..7ccbcdaded 100644
--- a/audio/decoders/raw.h
+++ b/audio/decoders/raw.h
@@ -35,6 +35,7 @@ class SeekableReadStream;
namespace Audio {
+class PacketizedAudioStream;
class SeekableAudioStream;
/**
@@ -89,6 +90,17 @@ SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream,
int rate, byte flags,
DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
+/**
+ * Creates a PacketizedAudioStream that will automatically queue
+ * packets as individual AudioStreams like returned by makeRawStream.
+ *
+ * @param rate Rate of the sound data.
+ * @param flags Audio flags combination.
+ * @see RawFlags
+ * @return The new PacketizedAudioStream.
+ */
+PacketizedAudioStream *makePacketizedRawStream(int rate, byte flags);
+
} // End of namespace Audio
#endif