[Scummvm-cvs-logs] SF.net SVN: scummvm:[46863] scummvm/trunk/sound

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Fri Jan 1 23:57:13 CET 2010


Revision: 46863
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46863&view=rev
Author:   lordhoto
Date:     2010-01-01 22:57:08 +0000 (Fri, 01 Jan 2010)

Log Message:
-----------
This time properly fix getTotalPlayTime for looped FLAC, MP3 and VORBIS audio streams.

Modified Paths:
--------------
    scummvm/trunk/sound/flac.cpp
    scummvm/trunk/sound/mp3.cpp
    scummvm/trunk/sound/vorbis.cpp

Modified: scummvm/trunk/sound/flac.cpp
===================================================================
--- scummvm/trunk/sound/flac.cpp	2010-01-01 22:56:18 UTC (rev 46862)
+++ scummvm/trunk/sound/flac.cpp	2010-01-01 22:57:08 UTC (rev 46863)
@@ -379,13 +379,11 @@
 
 		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();
 		}

Modified: scummvm/trunk/sound/mp3.cpp
===================================================================
--- scummvm/trunk/sound/mp3.cpp	2010-01-01 22:56:18 UTC (rev 46862)
+++ scummvm/trunk/sound/mp3.cpp	2010-01-01 22:57:08 UTC (rev 46863)
@@ -290,20 +290,18 @@
 			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--;
+			if (!_numLoops || _numPlayedLoops < _numLoops) {
+				// Deinit MAD
+				mad_synth_finish(&_synth);
+				mad_frame_finish(&_frame);
+				mad_stream_finish(&_stream);
 
-			_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;
+				// Reset the decoder state to indicate we should start over
+				_state = MP3_STATE_INIT;
+			}
 		}
 
 	} while (_state != MP3_STATE_EOS && _stream.error == MAD_ERROR_BUFLEN);

Modified: scummvm/trunk/sound/vorbis.cpp
===================================================================
--- scummvm/trunk/sound/vorbis.cpp	2010-01-01 22:56:18 UTC (rev 46862)
+++ scummvm/trunk/sound/vorbis.cpp	2010-01-01 22:57:08 UTC (rev 46863)
@@ -221,13 +221,9 @@
 			// 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);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list