diff options
Diffstat (limited to 'sound')
-rw-r--r-- | sound/vag.cpp | 11 | ||||
-rw-r--r-- | sound/vag.h | 5 |
2 files changed, 12 insertions, 4 deletions
diff --git a/sound/vag.cpp b/sound/vag.cpp index df596b00dc..01a7b58950 100644 --- a/sound/vag.cpp +++ b/sound/vag.cpp @@ -27,11 +27,12 @@ namespace Audio { -VagStream::VagStream(Common::SeekableReadStream *stream, bool loop) : _stream(stream) { +VagStream::VagStream(Common::SeekableReadStream *stream, bool loop, int rate) : _stream(stream) { _samplesRemaining = 0; _predictor = 0; _s1 = _s2 = 0.0; _loop = loop; + _rate = rate; } @@ -58,8 +59,14 @@ int VagStream::readBuffer(int16 *buffer, const int numSamples) { buffer[samplesDecoded] = d; samplesDecoded++; } - + +#if 0 assert(i == 28); // We're screwed if this fails :P +#endif + // This might mean the file is corrupted, or that the stream has + // been closed. + if (i != 28) return 0; + _samplesRemaining = 0; } diff --git a/sound/vag.h b/sound/vag.h index 2b3e35b35d..228f68279e 100644 --- a/sound/vag.h +++ b/sound/vag.h @@ -38,12 +38,12 @@ namespace Audio { class VagStream : public Audio::AudioStream { public: - VagStream(Common::SeekableReadStream *stream, bool loop = false); + VagStream(Common::SeekableReadStream *stream, bool loop = false, int rate = 11025); ~VagStream(); bool isStereo() const { return false; } bool endOfData() const { return _stream->pos() == _stream->size(); } - int getRate() const { return 11025; } + int getRate() const { return _rate; } int readBuffer(int16 *buffer, const int numSamples); void rewind(); @@ -54,6 +54,7 @@ private: byte _predictor; double _samples[28]; byte _samplesRemaining; + int _rate; double _s1, _s2; }; |