From 3aa9e2c5816aad20aa18e04d3a6644a8f79a4e29 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 11 Aug 2015 22:33:54 -0400 Subject: AUDIO: Add a packetized version of the PCM stream --- audio/decoders/raw.cpp | 20 ++++++++++++++++++++ audio/decoders/raw.h | 12 ++++++++++++ 2 files changed, 32 insertions(+) (limited to 'audio') 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 -- cgit v1.2.3