aboutsummaryrefslogtreecommitdiff
path: root/sound/mp3.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2010-01-01 22:57:08 +0000
committerJohannes Schickel2010-01-01 22:57:08 +0000
commit137744c40c5e5ab717c364a113cf5e83ca104663 (patch)
tree7e3d89e60f2f3195cf38214b13411f20c2eeb84d /sound/mp3.cpp
parent2e9d5a5f41636054f57b4a90b3f9165902963c3c (diff)
downloadscummvm-rg350-137744c40c5e5ab717c364a113cf5e83ca104663.tar.gz
scummvm-rg350-137744c40c5e5ab717c364a113cf5e83ca104663.tar.bz2
scummvm-rg350-137744c40c5e5ab717c364a113cf5e83ca104663.zip
This time properly fix getTotalPlayTime for looped FLAC, MP3 and VORBIS audio streams.
svn-id: r46863
Diffstat (limited to 'sound/mp3.cpp')
-rw-r--r--sound/mp3.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/sound/mp3.cpp b/sound/mp3.cpp
index 4ed68a3586..fede2a32cb 100644
--- a/sound/mp3.cpp
+++ b/sound/mp3.cpp
@@ -290,20 +290,18 @@ void MP3InputStream::decodeMP3Data() {
break;
}
- if (_state == MP3_STATE_EOS && _numLoops != 1) {
+ if (_state == MP3_STATE_EOS) {
+ ++_numPlayedLoops;
// If looping is on and there are loops left, rewind to the start
- if (_numLoops != 0)
- _numLoops--;
-
- _numPlayedLoops++;
-
- // Deinit MAD
- mad_synth_finish(&_synth);
- mad_frame_finish(&_frame);
- mad_stream_finish(&_stream);
-
- // Reset the decoder state to indicate we should start over
- _state = MP3_STATE_INIT;
+ if (!_numLoops || _numPlayedLoops < _numLoops) {
+ // Deinit MAD
+ mad_synth_finish(&_synth);
+ mad_frame_finish(&_frame);
+ mad_stream_finish(&_stream);
+
+ // Reset the decoder state to indicate we should start over
+ _state = MP3_STATE_INIT;
+ }
}
} while (_state != MP3_STATE_EOS && _stream.error == MAD_ERROR_BUFLEN);