[Scummvm-cvs-logs] CVS: scummvm/sword2/driver d_sound.cpp,1.138,1.139

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Mon Feb 7 02:53:49 CET 2005


Update of /cvsroot/scummvm/scummvm/sword2/driver
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14339/driver

Modified Files:
	d_sound.cpp 
Log Message:
Fixed crash that would happen if the game tried to play music from CD1 and
CD2 at the same time. There will eventually be a better fix for this, I
hope.


Index: d_sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_sound.cpp,v
retrieving revision 1.138
retrieving revision 1.139
diff -u -d -r1.138 -r1.139
--- d_sound.cpp	28 Jan 2005 16:33:13 -0000	1.138
+++ d_sound.cpp	7 Feb 2005 10:51:48 -0000	1.139
@@ -487,6 +487,21 @@
 int32 Sound::streamCompMusic(uint32 musicId, bool loop) {
 	Common::StackLock lock(_mutex);
 
+	int cd = _vm->_resman->whichCd();
+
+	// HACK: We only have one music file handle, so if any music from the
+	// "wrong" CD is playing, kill it immediately.
+
+	for (int i = 0; i < MAXMUS; i++) {
+		if (_music[i] && _music[i]->whichCd() != cd) {
+			delete _music[i];
+			_music[i] = NULL;
+
+			if (fpMus.isOpen())
+				fpMus.close();
+		}
+	}
+
 	if (loop)
 		_loopingMusicId = musicId;
 	else
@@ -545,7 +560,7 @@
 	if (secondary != -1)
 		_music[secondary]->fadeDown();
 
-	_music[primary] = new MusicInputStream(_vm->_resman->whichCd(), musicId, loop);
+	_music[primary] = new MusicInputStream(cd, musicId, loop);
 
 	if (!_music[primary]->isReady()) {
 		delete _music[primary];





More information about the Scummvm-git-logs mailing list