[Scummvm-cvs-logs] SF.net SVN: scummvm: [23606] scummvm/branches/branch-0-9-0/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Thu Jul 27 00:26:00 CEST 2006


Revision: 23606
Author:   lordhoto
Date:     2006-07-26 15:25:55 -0700 (Wed, 26 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=23606&view=rev

Log Message:
-----------
Make the midi player threadsafe (this should fix bug #1506583 "KYRA1: Crash on exceeded polyphony"). (backport)

Modified Paths:
--------------
    scummvm/branches/branch-0-9-0/engines/kyra/sound.cpp
    scummvm/branches/branch-0-9-0/engines/kyra/sound.h
Modified: scummvm/branches/branch-0-9-0/engines/kyra/sound.cpp
===================================================================
--- scummvm/branches/branch-0-9-0/engines/kyra/sound.cpp	2006-07-26 22:24:33 UTC (rev 23605)
+++ scummvm/branches/branch-0-9-0/engines/kyra/sound.cpp	2006-07-26 22:25:55 UTC (rev 23606)
@@ -118,6 +118,11 @@
 }
 
 SoundMidiPC::~SoundMidiPC() {
+	stopMusic();
+	stopSoundEffect();
+
+	Common::StackLock lock(_mutex);
+
 	_driver->setTimerCallback(NULL, NULL);
 	close();
 }
@@ -243,6 +248,8 @@
 void SoundMidiPC::playMusic(uint8 *data, uint32 size) {
 	stopMusic();
 
+	Common::StackLock lock(_mutex);
+
 	_parserSource = data;
 	_parser = MidiParser::createParser_XMIDI();
 	assert(_parser);
@@ -278,6 +285,8 @@
 void SoundMidiPC::loadSoundEffectFile(uint8 *data, uint32 size) {
 	stopSoundEffect();
 
+	Common::StackLock lock(_mutex);
+
 	_soundEffectSource = data;
 	_soundEffect = MidiParser::createParser_XMIDI();
 	assert(_soundEffect);
@@ -296,6 +305,8 @@
 }
 
 void SoundMidiPC::stopMusic() {
+	Common::StackLock lock(_mutex);
+
 	_isPlaying = false;
 	if (_parser) {
 		_parser->unloadMusic();
@@ -311,6 +322,8 @@
 }
 
 void SoundMidiPC::stopSoundEffect() {
+	Common::StackLock lock(_mutex);
+
 	_sfxIsPlaying = false;
 	if (_soundEffect) {
 		_soundEffect->unloadMusic();
@@ -323,6 +336,7 @@
 
 void SoundMidiPC::onTimer(void *refCon) {
 	SoundMidiPC *music = (SoundMidiPC *)refCon;
+	Common::StackLock lock(music->_mutex);
 
 	// this should be set to the fadeToBlack value
 	static const uint32 musicFadeTime = 2 * 1000;

Modified: scummvm/branches/branch-0-9-0/engines/kyra/sound.h
===================================================================
--- scummvm/branches/branch-0-9-0/engines/kyra/sound.h	2006-07-26 22:24:33 UTC (rev 23605)
+++ scummvm/branches/branch-0-9-0/engines/kyra/sound.h	2006-07-26 22:25:55 UTC (rev 23606)
@@ -26,9 +26,12 @@
 #include "common/stdafx.h"
 #include "common/scummsys.h"
 #include "common/file.h"
+#include "common/mutex.h"
+
 #include "sound/mididrv.h"
 #include "sound/midiparser.h"
 #include "sound/mixer.h"
+
 #include "kyra/kyra.h"
 
 namespace Audio {
@@ -200,6 +203,8 @@
 	byte *_parserSource;
 	MidiParser *_soundEffect;
 	byte *_soundEffectSource;
+
+	Common::Mutex _mutex;
 };
 
 class MixedSoundDriver : public Sound {


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