diff options
| author | Johannes Schickel | 2010-01-01 22:57:08 +0000 | 
|---|---|---|
| committer | Johannes Schickel | 2010-01-01 22:57:08 +0000 | 
| commit | 137744c40c5e5ab717c364a113cf5e83ca104663 (patch) | |
| tree | 7e3d89e60f2f3195cf38214b13411f20c2eeb84d | |
| parent | 2e9d5a5f41636054f57b4a90b3f9165902963c3c (diff) | |
| download | scummvm-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
| -rw-r--r-- | sound/flac.cpp | 6 | ||||
| -rw-r--r-- | sound/mp3.cpp | 24 | ||||
| -rw-r--r-- | sound/vorbis.cpp | 10 | 
3 files changed, 16 insertions, 24 deletions
diff --git a/sound/flac.cpp b/sound/flac.cpp index d06402e192..8699e8cfce 100644 --- a/sound/flac.cpp +++ b/sound/flac.cpp @@ -379,13 +379,11 @@ int FlacInputStream::readBuffer(int16 *buffer, const int numSamples) {  		if (state == FLAC__STREAM_DECODER_END_OF_STREAM) {  			_lastSampleWritten = true; +			++_numPlayedLoops;  		}  		// If we reached the end of the stream, and looping is enabled: Try to rewind -		if (_lastSampleWritten && _numLoops != 1) { -			if (_numLoops != 0) -				_numLoops--; -			_numPlayedLoops++; +		if (_lastSampleWritten && (!_numLoops || _numPlayedLoops < _numLoops)) {  			seekAbsolute(_firstSample);  			state = getStreamDecoderState();  		} 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); diff --git a/sound/vorbis.cpp b/sound/vorbis.cpp index 8e0cda06c9..bb73a26d06 100644 --- a/sound/vorbis.cpp +++ b/sound/vorbis.cpp @@ -221,13 +221,9 @@ int VorbisInputStream::readBuffer(int16 *buffer, const int numSamples) {  			// If we are still out of data, and also past the end of specified  			// time range, check whether looping is enabled...  			if (_pos >= _bufferEnd && ov_time_tell(&_ovFile) >= _endTime) { -				if (_numLoops != 1) { -					// If looping is on and there are loops left, rewind to the start -					if (_numLoops != 0) -						_numLoops--; - -					_numPlayedLoops++; - +				++_numPlayedLoops; +				// If looping is on and there are loops left, rewind to the start +				if (!_numLoops || _numPlayedLoops < _numLoops) {  					res = ov_time_seek(&_ovFile, _startTime);  					if (res < 0) {  						warning("Error seeking in Vorbis stream (%d)", res);  | 
