aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Battaglia2009-03-30 13:42:28 +0000
committerFabio Battaglia2009-03-30 13:42:28 +0000
commit0c1bae6b15c941cd6d8e6dfb98c0e6ddf8c3eb4c (patch)
treedfbdbfde3324abf7fb0f1ac0e2ae0f2e4169b7b6
parent4076bdecbce2a93e8254eb09cb01460ce693d906 (diff)
downloadscummvm-rg350-0c1bae6b15c941cd6d8e6dfb98c0e6ddf8c3eb4c.tar.gz
scummvm-rg350-0c1bae6b15c941cd6d8e6dfb98c0e6ddf8c3eb4c.tar.bz2
scummvm-rg350-0c1bae6b15c941cd6d8e6dfb98c0e6ddf8c3eb4c.zip
Rate selection is now possible for VAG audio decoder, also decoder doesn't die with incomplete/corrupted files
svn-id: r39764
-rw-r--r--sound/vag.cpp11
-rw-r--r--sound/vag.h5
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;
};