From 523181d7193d829c86e5b255b47c35a4c28bca14 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 30 Jan 2010 15:18:25 +0000 Subject: Add a factory which plays audio from a buffer via RawDiskStream. svn-id: r47714 --- sound/decoders/raw.cpp | 6 ++++++ sound/decoders/raw.h | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/decoders/raw.cpp b/sound/decoders/raw.cpp index f726d91cc5..18abfdcb35 100644 --- a/sound/decoders/raw.cpp +++ b/sound/decoders/raw.cpp @@ -426,6 +426,12 @@ SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream, return makeRawStream(stream, blocks, rate, flags, disposeAfterUse); } +SeekableAudioStream *makeRawStream(const byte *buffer, uint32 size, + int rate, byte flags, + DisposeAfterUse::Flag disposeAfterUse) { + return makeRawStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, flags, DisposeAfterUse::YES); +} + SeekableAudioStream *makeRawDiskStream_OLD(Common::SeekableReadStream *stream, RawDiskStreamAudioBlock *block, int numBlocks, int rate, byte flags, DisposeAfterUse::Flag disposeStream) { assert(numBlocks > 0); diff --git a/sound/decoders/raw.h b/sound/decoders/raw.h index c3be9f16a1..e6fe0d6abf 100644 --- a/sound/decoders/raw.h +++ b/sound/decoders/raw.h @@ -117,11 +117,25 @@ struct RawDiskStreamAudioBlock { */ typedef Common::List RawStreamBlockList; +/** + * Creates an audio stream, which plays from the given buffer. + * + * @param buffer Buffer to play from. + * @param size Size of the buffer in bytes. + * @param rate Rate of the sound data. + * @param flags Audio flags combination. + * @see RawFlags + * @param disposeAfterUse Whether to free the buffer after use (with free!). + * @return The new SeekableAudioStream (or 0 on failure). + */ +SeekableAudioStream *makeRawStream(const byte *buffer, uint32 size, + int rate, byte flags, + DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); + /** * Creates an audio stream, which plays from the given stream. * * @param stream Stream object to play from. - * @param size Size of the buffer. * @param rate Rate of the sound data. * @param flags Audio flags combination. * @see RawFlags -- cgit v1.2.3