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

NMIError 60350957+NMIError at users.noreply.github.com
Wed Jul 21 20:25:45 UTC 2021


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:
e6b30e4d57 SAGA: Fix MIDI parser memory leak
fecd4310c3 SAGA2: Fix MIDI parser memory leak


Commit: e6b30e4d57e61ccd5a7138fc41c5d014abcfd7f2
    https://github.com/scummvm/scummvm/commit/e6b30e4d57e61ccd5a7138fc41c5d014abcfd7f2
Author: Coen Rampen (crampen at gmail.com)
Date: 2021-07-21T22:25:32+02:00

Commit Message:
SAGA: Fix MIDI parser memory leak

A new MidiParser object is created every time a MIDI track is played, but the
old parser would not be freed. Fixed this by first deleting the parser before
creating a new one.

Changed paths:
    engines/saga/music.cpp


diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp
index 871d4689fa..507dd77ec7 100644
--- a/engines/saga/music.cpp
+++ b/engines/saga/music.cpp
@@ -274,8 +274,11 @@ void Music::play(uint32 resourceId, MusicFlags flags) {
 
 	_trackNumber = resourceId;
 	_mixer->stopHandle(_musicHandle);
-	if (_parser)
-		_parser->stopPlaying();
+	if (_parser) {
+		_parser->unloadMusic();
+		delete _parser;
+		_parser = 0;
+	}
 	if (_driverPC98)
 		_driverPC98->reset();
 


Commit: fecd4310c3d03b966fa34656646efb07cd7fab3c
    https://github.com/scummvm/scummvm/commit/fecd4310c3d03b966fa34656646efb07cd7fab3c
Author: Coen Rampen (crampen at gmail.com)
Date: 2021-07-21T22:25:32+02:00

Commit Message:
SAGA2: Fix MIDI parser memory leak

A new MidiParser object is created every time a MIDI track is played, but the
old parser would not be freed. Fixed this by reusing the old parser instead of
creating a new one, which is more efficient anyway.

Changed paths:
    engines/saga2/music.cpp


diff --git a/engines/saga2/music.cpp b/engines/saga2/music.cpp
index 4a12fbf864..40d0d29e9c 100644
--- a/engines/saga2/music.cpp
+++ b/engines/saga2/music.cpp
@@ -110,21 +110,22 @@ void Music::play(uint32 resourceId, MusicFlags flags) {
 		return;
 
 	_trackNumber = resourceId;
-	if (_parser)
-		_parser->stopPlaying();
+	if (_parser) {
+		_parser->unloadMusic();
+	} else {
+		_parser = MidiParser::createParser_XMIDI(0, 0, 0);
+
+		_parser->setMidiDriver(_driver);
+		_parser->setTimerRate(_driver->getBaseTempo());
+		_parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1);
+		_parser->property(MidiParser::mpSendSustainOffOnNotesOff, 1);
+	}
 
 	free(_currentMusicBuffer);
 
 	_currentMusicBuffer = (byte *)LoadResource(_musicContext, resourceId, "music data");
 	uint32 size = _musicContext->size(resourceId);
 
-	_parser = MidiParser::createParser_XMIDI(0, 0, 0);
-
-	_parser->setMidiDriver(_driver);
-	_parser->setTimerRate(_driver->getBaseTempo());
-	_parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1);
-	_parser->property(MidiParser::mpSendSustainOffOnNotesOff, 1);
-
 	// Handle music looping
 	_parser->property(MidiParser::mpAutoLoop, flags & MUSIC_LOOP);
 	if (!_parser->loadMusic(_currentMusicBuffer, size))




More information about the Scummvm-git-logs mailing list