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

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


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

Modified Files:
      Tag: branch-0-7-0
	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. (This is a backport of a fix I haven't yet commited
to the trunk.)


Index: d_sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_sound.cpp,v
retrieving revision 1.129
retrieving revision 1.129.2.1
diff -u -d -r1.129 -r1.129.2.1
--- d_sound.cpp	11 Dec 2004 00:35:00 -0000	1.129
+++ d_sound.cpp	7 Feb 2005 10:24:04 -0000	1.129.2.1
@@ -285,6 +285,8 @@
 	bool isStereo() const	{ return _decoder->isStereo(); }
 	int getRate() const	{ return _decoder->getRate(); }
 
+	int whichCd()		{ return _cd; }
+
 	void fadeUp();
 	void fadeDown();
 
@@ -688,6 +690,21 @@
 int32 Sound::streamCompMusic(uint32 musicId, bool looping) {
 	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();
+		}
+	}
+
 	int primary = -1;
 	int secondary = -1;
 
@@ -741,7 +758,7 @@
 	if (secondary != -1)
 		_music[secondary]->fadeDown();
 
-	_music[primary] = new MusicInputStream(_vm->_resman->whichCd(), musicId, looping);
+	_music[primary] = new MusicInputStream(cd, musicId, looping);
 
 	if (!_music[primary]->isReady()) {
 		delete _music[primary];





More information about the Scummvm-git-logs mailing list