From 72239a25f9608935024560ab07f17a47863de0d7 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 11 Aug 2015 23:17:30 -0400 Subject: AUDIO: Add a NullAudioStream for streams that are dead-on-arrival --- audio/audiostream.cpp | 21 +++++++++++++++++++++ audio/audiostream.h | 6 ++++++ 2 files changed, 27 insertions(+) (limited to 'audio') diff --git a/audio/audiostream.cpp b/audio/audiostream.cpp index c413edb73d..88c41e8503 100644 --- a/audio/audiostream.cpp +++ b/audio/audiostream.cpp @@ -33,6 +33,7 @@ #include "audio/decoders/quicktime.h" #include "audio/decoders/raw.h" #include "audio/decoders/vorbis.h" +#include "audio/mixer.h" namespace Audio { @@ -465,4 +466,24 @@ AudioStream *makeLimitingAudioStream(AudioStream *parentStream, const Timestamp return new LimitingAudioStream(parentStream, length, disposeAfterUse); } +/** + * An AudioStream that plays nothing and immediately returns that + * the endOfStream() has been reached + */ +class NullAudioStream : public AudioStream { +public: + bool isStereo() const { return false; } + int getRate() const; + int readBuffer(int16 *data, const int numSamples) { return 0; } + bool endOfData() const { return true; } +}; + +int NullAudioStream::getRate() const { + return g_system->getMixer()->getOutputRate(); +} + +AudioStream *makeNullAudioStream() { + return new NullAudioStream(); +} + } // End of namespace Audio diff --git a/audio/audiostream.h b/audio/audiostream.h index 6019acaf5a..a60d5a2086 100644 --- a/audio/audiostream.h +++ b/audio/audiostream.h @@ -433,6 +433,12 @@ private: Common::ScopedPtr _stream; }; +/** + * Create an AudioStream that plays nothing and immediately returns that + * endOfStream() has been reached. + */ +AudioStream *makeNullAudioStream(); + } // End of namespace Audio #endif -- cgit v1.2.3