[Scummvm-git-logs] scummvm master -> e42ade073cc1f013eae739dc37464630f1104813

csnover csnover at users.noreply.github.com
Mon Nov 20 03:53:23 CET 2017


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
9fc24e19f2 AUDIO: Fix data race in PacketizedMP3Stream
e42ade073c AUDIO: Fix uninitialized data structures in PacketizedMP3Stream


Commit: 9fc24e19f234ba53fb450223137a8041932ecd51
    https://github.com/scummvm/scummvm/commit/9fc24e19f234ba53fb450223137a8041932ecd51
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-11-19T20:53:00-06:00

Commit Message:
AUDIO: Fix data race in PacketizedMP3Stream

Changed paths:
    audio/decoders/mp3.cpp


diff --git a/audio/decoders/mp3.cpp b/audio/decoders/mp3.cpp
index 93c21b9..54da6c5 100644
--- a/audio/decoders/mp3.cpp
+++ b/audio/decoders/mp3.cpp
@@ -119,6 +119,7 @@ public:
 
 	// AudioStream API
 	int readBuffer(int16 *buffer, const int numSamples);
+	bool endOfData() const;
 	bool endOfStream() const;
 
 	// PacketizedAudioStream API
@@ -484,12 +485,17 @@ int PacketizedMP3Stream::readBuffer(int16 *buffer, const int numSamples) {
 	return samples;
 }
 
+bool PacketizedMP3Stream::endOfData() const {
+	Common::StackLock lock(_mutex);
+	return BaseMP3Stream::endOfData();
+}
+
 bool PacketizedMP3Stream::endOfStream() const {
+	Common::StackLock lock(_mutex);
+
 	if (!endOfData())
 		return false;
 
-	// Lock the mutex
-	Common::StackLock lock(_mutex);
 	if (!_queue.empty())
 		return false;
 


Commit: e42ade073cc1f013eae739dc37464630f1104813
    https://github.com/scummvm/scummvm/commit/e42ade073cc1f013eae739dc37464630f1104813
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-11-19T20:53:02-06:00

Commit Message:
AUDIO: Fix uninitialized data structures in PacketizedMP3Stream

If the audio thread called to readBuffer before any packet had been
added to the stream, the state of the stream would be changed from
INIT to EOS. Later, when a packet was received, the state would go
directly from EOS to READY, skipping decoder init, leaving garbage
memory in the decoder structs and causing a crash of the decoder.

Fixes Trac#9653.

Changed paths:
    audio/decoders/mp3.cpp


diff --git a/audio/decoders/mp3.cpp b/audio/decoders/mp3.cpp
index 54da6c5..3fd134d 100644
--- a/audio/decoders/mp3.cpp
+++ b/audio/decoders/mp3.cpp
@@ -453,7 +453,10 @@ int PacketizedMP3Stream::readBuffer(int16 *buffer, const int numSamples) {
 	while (samples < numSamples) {
 		// Empty? Bail out for now, and mark the stream as ended
 		if (_queue.empty()) {
-			_state = MP3_STATE_EOS;
+			// EOS state is only valid once a packet has been received at least
+			// once
+			if (_state == MP3_STATE_READY)
+				_state = MP3_STATE_EOS;
 			return samples;
 		}
 





More information about the Scummvm-git-logs mailing list