mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-21 19:51:49 +00:00
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. svn-id: r48904
This commit is contained in:
parent
df679afe19
commit
f2ee496c0e
@ -114,6 +114,13 @@ MP3Stream::MP3Stream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag
|
||||
while (_state != MP3_STATE_EOS)
|
||||
readHeader();
|
||||
|
||||
// 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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user