aboutsummaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
authorMatthew Hoops2015-08-11 22:33:54 -0400
committerMatthew Hoops2015-08-30 19:53:54 -0400
commit3aa9e2c5816aad20aa18e04d3a6644a8f79a4e29 (patch)
tree9e5452066adffd15e60849ff534cb4d048d793d0 /audio
parenta64aff02878eaaeda3a014cbfc71daf760000136 (diff)
downloadscummvm-rg350-3aa9e2c5816aad20aa18e04d3a6644a8f79a4e29.tar.gz
scummvm-rg350-3aa9e2c5816aad20aa18e04d3a6644a8f79a4e29.tar.bz2
scummvm-rg350-3aa9e2c5816aad20aa18e04d3a6644a8f79a4e29.zip
AUDIO: Add a packetized version of the PCM stream
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