diff options
author | Matthew Hoops | 2015-08-11 23:17:30 -0400 |
---|---|---|
committer | Matthew Hoops | 2015-08-30 21:00:54 -0400 |
commit | 72239a25f9608935024560ab07f17a47863de0d7 (patch) | |
tree | eab854974a5bc57d3f413d74a7874b4bad2b6221 | |
parent | 331d8ece21948bb07f43be512ab686bb41cf01fa (diff) | |
download | scummvm-rg350-72239a25f9608935024560ab07f17a47863de0d7.tar.gz scummvm-rg350-72239a25f9608935024560ab07f17a47863de0d7.tar.bz2 scummvm-rg350-72239a25f9608935024560ab07f17a47863de0d7.zip |
AUDIO: Add a NullAudioStream for streams that are dead-on-arrival
-rw-r--r-- | audio/audiostream.cpp | 21 | ||||
-rw-r--r-- | audio/audiostream.h | 6 |
2 files changed, 27 insertions, 0 deletions
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<QueuingAudioStream> _stream; }; +/** + * Create an AudioStream that plays nothing and immediately returns that + * endOfStream() has been reached. + */ +AudioStream *makeNullAudioStream(); + } // End of namespace Audio #endif |