[Scummvm-cvs-logs] CVS: scummvm/scumm sound.cpp,1.266,1.267 sound.h,1.50,1.51

Max Horn fingolfin at users.sourceforge.net
Fri Oct 17 09:32:09 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv9190/scumm

Modified Files:
	sound.cpp sound.h 
Log Message:
proper fix for COMI timer issue: don't let a Timer remove itself

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.266
retrieving revision 1.267
diff -u -d -r1.266 -r1.267
--- sound.cpp	12 Oct 2003 19:10:16 -0000	1.266
+++ sound.cpp	17 Oct 2003 16:30:24 -0000	1.267
@@ -1011,8 +1011,9 @@
 	}
 
 	if (_nameBundleMusic[0] == 0) {
-		_outputMixerSize = 66150; // ((22050 * 2 * 2) / 4) * 3
 		if (_scumm->_gameId == GID_CMI) {
+			_outputMixerSize = (22050 * 2 * 2);
+
 			char bunfile[20];
 			sprintf(bunfile, "musdisk%d.bun", _scumm->VAR(_scumm->VAR_CURRENTDISK));
 			if (_musicDisk != _scumm->VAR(_scumm->VAR_CURRENTDISK)) 
@@ -1026,8 +1027,9 @@
 			}
 
 			_musicDisk = (byte)_scumm->VAR(_scumm->VAR_CURRENTDISK);
-			_outputMixerSize = 88140; // ((22050 * 2 * 2)
 		} else {
+			_outputMixerSize = ((22050 * 2 * 2) / 4) * 3;
+
 			if (_bundle->openMusicFile("digmusic.bun", _scumm->getGameDataPath()) == false)
 				return;
 		}
@@ -1038,17 +1040,13 @@
 		_offsetBufBundleMusic = 0;
 		_bundleMusicPosition = 0;
 		_pauseBundleMusic = false;
-		_musicBundleToBeRemoved = false;
 		_musicBundleToBeChanged = false;
 		_bundleMusicTrack = 0;
 		_numberSamplesBundleMusic = _bundle->getNumberOfMusicSamplesByName(song);
 		_nameBundleMusic = song;
 		_scumm->_timer->installProcedure(&music_handler, 1000000, this);
-		return;
-	}
-	if (strcmp(_nameBundleMusic, song) != 0) {
+	} else if (strcmp(_nameBundleMusic, song) != 0) {
 		_newNameBundleMusic = song;
-		_musicBundleToBeRemoved = false;
 		_musicBundleToBeChanged = true;
 	}
 }
@@ -1058,7 +1056,18 @@
 }
 
 void Sound::stopBundleMusic() {
-	_musicBundleToBeRemoved = true;
+	// First stop the music timer
+	_scumm->_timer->releaseProcedure(&music_handler);
+	_nameBundleMusic = "";
+	_scumm->_mixer->stopChannel(_bundleMusicTrack);
+	if (_musicBundleBufFinal) {
+		free(_musicBundleBufFinal);
+		_musicBundleBufFinal = NULL;
+	}
+	if (_musicBundleBufOutput) {
+		free(_musicBundleBufOutput);
+		_musicBundleBufOutput = NULL;
+	}
 }
 
 void Sound::bundleMusicHandler(ScummEngine *scumm) {
@@ -1070,21 +1079,6 @@
 	if (_pauseBundleMusic)
 		return;
 
-	if (_musicBundleToBeRemoved) {
-		_scumm->_timer->releaseProcedure(&music_handler);
-		_nameBundleMusic = "";
-		_scumm->_mixer->stopChannel(_bundleMusicTrack);
-		if (_musicBundleBufFinal) {
-			free(_musicBundleBufFinal);
-			_musicBundleBufFinal = NULL;
-		}
-		if (_musicBundleBufOutput) {
-			free(_musicBundleBufOutput);
-			_musicBundleBufOutput = NULL;
-		}
-		return;
-	}
-
 	if (_musicBundleToBeChanged) {
 		_nameBundleMusic = _newNameBundleMusic;
 		_numberSamplesBundleMusic = _bundle->getNumberOfMusicSamplesByName(_nameBundleMusic);
@@ -1104,9 +1098,7 @@
 		if (l == 0) {
 			tag = READ_BE_UINT32(ptr); ptr += 4;
 			if (tag != MKID_BE('iMUS')) {
-				warning("Decompression of bundle song failed");
-				_musicBundleToBeRemoved = true;
-				return;
+				error("Decompressing bundle song failed (unknown tag '%s')", tag2str(tag));
 			}
 
 			ptr += 12;
@@ -1139,9 +1131,7 @@
 				}
 			}
 			if (size < 0) {
-				warning("Decompression sound failed (no size field)");
-				_musicBundleToBeRemoved = true;
-				return;
+				error("Decompressing sound failed (missing size field)");
 			}
 			header_size = (ptr - _musicBundleBufOutput);
 		}

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.h,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- sound.h	3 Oct 2003 18:33:56 -0000	1.50
+++ sound.h	17 Oct 2003 16:30:24 -0000	1.51
@@ -57,7 +57,6 @@
 	bool _pauseBundleMusic;
 	PlayingSoundHandle _bundleMusicTrack;
 	bool _musicBundleToBeChanged;
-	bool _musicBundleToBeRemoved;
 	int32 _bundleMusicSampleBits;
 	int32 _outputMixerSize;
 	int32 _bundleSampleChannels;





More information about the Scummvm-git-logs mailing list