aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMax Horn2003-08-05 11:30:13 +0000
committerMax Horn2003-08-05 11:30:13 +0000
commit4c4aa4e95744ad90f47874d03b090bbb6cda78c8 (patch)
tree234986a204efbcab7aea6aef5622a193286a2389 /sound
parent5ba31343ddcd59ecf7dd178c1e202d06c4b4253d (diff)
downloadscummvm-rg350-4c4aa4e95744ad90f47874d03b090bbb6cda78c8.tar.gz
scummvm-rg350-4c4aa4e95744ad90f47874d03b090bbb6cda78c8.tar.bz2
scummvm-rg350-4c4aa4e95744ad90f47874d03b090bbb6cda78c8.zip
fix bug #783423
svn-id: r9484
Diffstat (limited to 'sound')
-rw-r--r--sound/audiostream.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp
index 7a71a43234..0312992802 100644
--- a/sound/audiostream.cpp
+++ b/sound/audiostream.cpp
@@ -214,10 +214,9 @@ class MP3InputStream : public MusicStream {
File *_file;
byte *_ptr;
int _rate;
- bool _initialized;
bool init();
- void refill();
+ void refill(bool first = false);
inline int16 readIntern();
inline bool eosIntern() const;
public:
@@ -260,7 +259,7 @@ MP3InputStream::MP3InputStream(File *file, mad_timer_t duration, uint size) {
_ptr = (byte *)malloc(_bufferSize + MAD_BUFFER_GUARD);
_rate = 0;
- _initialized = init();
+ init();
// If a size is specified, we do not perform any further read operations
if (size) {
@@ -291,7 +290,7 @@ bool MP3InputStream::init() {
mad_stream_buffer(&_stream, _ptr, _size);
// Read in initial data
- refill();
+ refill(true);
// Check the header, determine if this is a stereo stream
int num;
@@ -316,7 +315,7 @@ bool MP3InputStream::init() {
return true;
}
-void MP3InputStream::refill() {
+void MP3InputStream::refill(bool first) {
// Read the next frame (may have to retry several times, e.g.
// to skip over ID3 information).
@@ -363,7 +362,7 @@ void MP3InputStream::refill() {
mad_timer_negate(&frame_duration);
mad_timer_add(&_duration, frame_duration);
- if (mad_timer_compare(_duration, mad_timer_zero) <= 0)
+ if (!first && _file && mad_timer_compare(_duration, mad_timer_zero) <= 0)
_size = -1; // Mark for EOF
// Synthesise the frame into PCM samples and reset the buffer position