diff options
author | Max Horn | 2010-01-28 09:38:21 +0000 |
---|---|---|
committer | Max Horn | 2010-01-28 09:38:21 +0000 |
commit | 1c906a1f08f9d1f316c2efd65a347c00e07bc469 (patch) | |
tree | e8f741ede9a33e2bd9748faeb4a46130a722f950 /sound | |
parent | f85c77d63ea85d62cb5bbf55fe71dd9c42e6924b (diff) | |
download | scummvm-rg350-1c906a1f08f9d1f316c2efd65a347c00e07bc469.tar.gz scummvm-rg350-1c906a1f08f9d1f316c2efd65a347c00e07bc469.tar.bz2 scummvm-rg350-1c906a1f08f9d1f316c2efd65a347c00e07bc469.zip |
Hide VagStream implementation, only expose it via a factory method
svn-id: r47634
Diffstat (limited to 'sound')
-rw-r--r-- | sound/decoders/vag.cpp | 27 | ||||
-rw-r--r-- | sound/decoders/vag.h | 37 |
2 files changed, 43 insertions, 21 deletions
diff --git a/sound/decoders/vag.cpp b/sound/decoders/vag.cpp index f2c9281d80..d3f0811f2b 100644 --- a/sound/decoders/vag.cpp +++ b/sound/decoders/vag.cpp @@ -24,9 +24,32 @@ */ #include "sound/decoders/vag.h" +#include "sound/audiostream.h" +#include "common/stream.h" namespace Audio { +class VagStream : public Audio::RewindableAudioStream { +public: + VagStream(Common::SeekableReadStream *stream, int rate); + ~VagStream(); + + bool isStereo() const { return false; } + bool endOfData() const { return _stream->pos() == _stream->size(); } + int getRate() const { return _rate; } + int readBuffer(int16 *buffer, const int numSamples); + + bool rewind(); +private: + Common::SeekableReadStream *_stream; + + byte _predictor; + double _samples[28]; + byte _samplesRemaining; + int _rate; + double _s1, _s2; +}; + VagStream::VagStream(Common::SeekableReadStream *stream, int rate) : _stream(stream) { _samplesRemaining = 0; _predictor = 0; @@ -120,4 +143,8 @@ bool VagStream::rewind() { return true; } +RewindableAudioStream *makeVagStream(Common::SeekableReadStream *stream, int rate) { + return new VagStream(stream, rate); +} + } diff --git a/sound/decoders/vag.h b/sound/decoders/vag.h index d659a7db4e..7e0ed255be 100644 --- a/sound/decoders/vag.h +++ b/sound/decoders/vag.h @@ -34,31 +34,26 @@ #ifndef SOUND_VAG_H #define SOUND_VAG_H -#include "sound/audiostream.h" -#include "common/stream.h" +namespace Common { + class SeekableReadStream; +} namespace Audio { -class VagStream : public Audio::RewindableAudioStream { -public: - VagStream(Common::SeekableReadStream *stream, int rate = 11025); - ~VagStream(); +class AudioStream; +class RewindableAudioStream; - bool isStereo() const { return false; } - bool endOfData() const { return _stream->pos() == _stream->size(); } - int getRate() const { return _rate; } - int readBuffer(int16 *buffer, const int numSamples); - - bool rewind(); -private: - Common::SeekableReadStream *_stream; - - byte _predictor; - double _samples[28]; - byte _samplesRemaining; - int _rate; - double _s1, _s2; -}; +/** + * Takes an input stream containing Vag sound data and creates + * an RewindableAudioStream from that. + * + * @param stream the SeekableReadStream from which to read the ADPCM data + * @param rate the sampling rate + * @return a new RewindableAudioStream, or NULL, if an error occured + */ +RewindableAudioStream *makeVagStream( + Common::SeekableReadStream *stream, + int rate = 11025); } // End of namespace Sword1 |