aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2003-07-31 19:32:38 +0000
committerMax Horn2003-07-31 19:32:38 +0000
commitd8494d658b25d65eee1856d127a8ad5e20155bbe (patch)
tree9fd02ba4f1f9fb829d4c0ed461f6dc1fc850af33
parent16425977b75b1128bae917f22ca9cec9720fc863 (diff)
downloadscummvm-rg350-d8494d658b25d65eee1856d127a8ad5e20155bbe.tar.gz
scummvm-rg350-d8494d658b25d65eee1856d127a8ad5e20155bbe.tar.bz2
scummvm-rg350-d8494d658b25d65eee1856d127a8ad5e20155bbe.zip
fixed MP3InputStream, now seems to work properly (kind of a surprise)
svn-id: r9345
-rw-r--r--sound/audiostream.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp
index 7ed8ff2437..133333503b 100644
--- a/sound/audiostream.cpp
+++ b/sound/audiostream.cpp
@@ -259,7 +259,7 @@ void MP3InputStream::refill() {
} else if (MAD_RECOVERABLE(_stream.error)) {
// FIXME: should we do anything here?
- warning("MP3InputStream: Recoverable error...");
+ debug(1, "MP3InputStream: Recoverable error...");
} else {
error("MP3InputStream: Unrecoverable error");
}
@@ -279,14 +279,7 @@ bool MP3InputStream::eof() const {
// Time over -> input steam ends
if (mad_timer_compare(_duration, mad_timer_zero) <= 0)
return true;
- // Data left in the PCM buffer -> we are not yet done!
- if (_posInFrame < _synth.pcm.length)
- return false;
- // EOF of the input file, we are done
- if (_size < 0)
- return true;
- // Otherwise, we are still good to go
- return false;
+ return (_posInFrame >= _synth.pcm.length);
}
static inline int scale_sample(mad_fixed_t sample) {
@@ -304,13 +297,9 @@ static inline int scale_sample(mad_fixed_t sample) {
}
int16 MP3InputStream::read() {
- if (_posInFrame >= _synth.pcm.length) {
- refill();
- if (_size < 0) // EOF
- return 0;
- }
+ if (_size < 0 || _posInFrame >= _synth.pcm.length) // EOF
+ return 0;
-
int16 sample;
if (_isStereo) {
sample = (int16)scale_sample(_synth.pcm.samples[_curChannel][_posInFrame]);
@@ -324,7 +313,11 @@ int16 MP3InputStream::read() {
sample = (int16)scale_sample(_synth.pcm.samples[0][_posInFrame]);
_posInFrame++;
}
-
+
+ if (_posInFrame >= _synth.pcm.length) {
+ refill();
+ }
+
return sample;
}