[Scummvm-cvs-logs] CVS: scummvm/sword1 sound.cpp,1.7,1.8 sound.h,1.3,1.4

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Thu Dec 18 22:52:01 CET 2003


Update of /cvsroot/scummvm/scummvm/sword1
In directory sc8-pr-cvs1:/tmp/cvs-serv12015

Modified Files:
	sound.cpp sound.h 
Log Message:
Make sure that playSample() gets a pointer to the original QueueElement
instead of a copy of it. Otherwise the sound engine will never notice when
a sample finishes playing since it's looking at the wrong sound handle.

For whatever reason, this also seems to fix the "game crashes occasionally
on startup with completely useless stack trace" bug for me. The crash was
easily repeatable in Valgrind for me, but the messages it produced were
just as unhelpful as the stack trace. These messages are also gone now.


Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sound.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- sound.cpp	17 Dec 2003 11:39:19 -0000	1.7
+++ sound.cpp	19 Dec 2003 06:51:32 -0000	1.8
@@ -76,7 +76,7 @@
 		if (_fxQueue[cnt].delay > 0) {
 			_fxQueue[cnt].delay--;
 			if (_fxQueue[cnt].delay == 0)
-				playSample(_fxQueue[cnt]);
+				playSample(&_fxQueue[cnt]);
 		} else {
 			if (!_fxQueue[cnt].handle) { // sound finished
 				_resMan->resClose(_fxList[_fxQueue[cnt].id].sampleId);
@@ -128,16 +128,15 @@
 	// I don't think that we even have to start SFX here.
 }
 
-void SwordSound::playSample(QueueElement elem) {
-
-	uint8 *sampleData = (uint8*)_resMan->fetchRes(_fxList[elem.id].sampleId);
+void SwordSound::playSample(QueueElement *elem) {
+	uint8 *sampleData = (uint8*)_resMan->fetchRes(_fxList[elem->id].sampleId);
 	for (uint16 cnt = 0; cnt < MAX_ROOMS_PER_FX; cnt++) {
-		if (_fxList[elem.id].roomVolList[cnt].roomNo) {
-			if ((_fxList[elem.id].roomVolList[cnt].roomNo == (int)SwordLogic::_scriptVars[SCREEN]) ||
-				(_fxList[elem.id].roomVolList[cnt].roomNo == -1)) {
+		if (_fxList[elem->id].roomVolList[cnt].roomNo) {
+			if ((_fxList[elem->id].roomVolList[cnt].roomNo == (int)SwordLogic::_scriptVars[SCREEN]) ||
+				(_fxList[elem->id].roomVolList[cnt].roomNo == -1)) {
 
-					uint8 volL = _fxList[elem.id].roomVolList[cnt].leftVol * 10;
-					uint8 volR = _fxList[elem.id].roomVolList[cnt].rightVol * 10;
+					uint8 volL = _fxList[elem->id].roomVolList[cnt].leftVol * 10;
+					uint8 volR = _fxList[elem->id].roomVolList[cnt].rightVol * 10;
 					int8 pan = (volR - volL) / 2;
 					uint8 volume = (volR + volL) / 2;
 					uint32 size = READ_LE_UINT32(sampleData + 0x28);
@@ -146,7 +145,7 @@
 						flags = SoundMixer::FLAG_16BITS | SoundMixer::FLAG_LITTLE_ENDIAN;
 					else
 						flags = SoundMixer::FLAG_UNSIGNED;
-					_mixer->playRaw(&elem.handle, sampleData + 0x2C, size, 11025, flags, elem.id, volume, pan);
+					_mixer->playRaw(&elem->handle, sampleData + 0x2C, size, 11025, flags, elem->id, volume, pan);
 			}
 		} else
 			break;

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sound.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- sound.h	17 Dec 2003 07:33:00 -0000	1.3
+++ sound.h	19 Dec 2003 06:51:32 -0000	1.4
@@ -72,7 +72,7 @@
 	void engine(void);
 
 private:
-	void playSample(QueueElement elem);
+	void playSample(QueueElement *elem);
 	void initCowSystem(void);
 	void closeCowSysten(void);
 	uint32 uncompressedSize(uint8 *data);





More information about the Scummvm-git-logs mailing list