[Scummvm-cvs-logs] SF.net SVN: scummvm:[48904] scummvm/trunk/sound/decoders/mp3.cpp

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Mon May 3 15:03:45 CEST 2010


Revision: 48904
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48904&view=rev
Author:   lordhoto
Date:     2010-05-03 13:03:44 +0000 (Mon, 03 May 2010)

Log Message:
-----------
Paranoia change: Prevent possible assertion caused by MP3Stream.

Currently we have an assert checking that the framerate of an
Audio::Timestamp is always > 0. Since MAD might return "0"
(and maybe even other illegal values) in case the MP3 stream is
invalid we need to check that before we setup the _length
Timestamp of MP3Stream.

Modified Paths:
--------------
    scummvm/trunk/sound/decoders/mp3.cpp

Modified: scummvm/trunk/sound/decoders/mp3.cpp
===================================================================
--- scummvm/trunk/sound/decoders/mp3.cpp	2010-05-03 11:58:45 UTC (rev 48903)
+++ scummvm/trunk/sound/decoders/mp3.cpp	2010-05-03 13:03:44 UTC (rev 48904)
@@ -114,7 +114,14 @@
 	while (_state != MP3_STATE_EOS)
 		readHeader();
 
-	_length = Timestamp(mad_timer_count(_totalTime, MAD_UNITS_MILLISECONDS), getRate());
+	// To rule out any invalid sample rate to be encountered here, say in case the
+	// MP3 stream is invalid, we just check the MAD error code here.
+	// We need to assure this, since else we might trigger an assertion in Timestamp
+	// (When getRate() returns 0 or a negative number to be precise).
+	// Note that we allow "MAD_ERROR_BUFLEN" as error code here, since according
+	// to mad.h it is also set on EOF.
+	if ((_stream.error == MAD_ERROR_NONE || _stream.error == MAD_ERROR_BUFLEN) && getRate() > 0)
+		_length = Timestamp(mad_timer_count(_totalTime, MAD_UNITS_MILLISECONDS), getRate());
 
 	deinitStream();
 


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