[Scummvm-cvs-logs] CVS: scummvm/scumm sound.cpp,1.288,1.289 sound.h,1.57,1.58

Max Horn fingolfin at users.sourceforge.net
Tue Dec 23 11:19:02 CET 2003


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

Modified Files:
	sound.cpp sound.h 
Log Message:
Replace the DOTT/SAM hack (which ensures that only one SFX is being played at a time for them) with proper code: instead of hacking the sound handle, we assign a fake sound ID to the SFX, thus ensuring only one is playing at a time

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.288
retrieving revision 1.289
diff -u -d -r1.288 -r1.289
--- sound.cpp	23 Dec 2003 00:17:29 -0000	1.288
+++ sound.cpp	23 Dec 2003 19:18:20 -0000	1.289
@@ -432,9 +432,7 @@
 		if (act != 0 && (uint) act < 0x80 && !_scumm->_string[0].no_talk_anim) {
 			a = _scumm->derefActor(act, "processSfxQueues");
 			if (a->isInCurrentRoom() && (finished || !_endOfMouthSync)) {
-				b = true;
-				if (!finished)
-					b = isMouthSyncOff(_curSoundPos);
+				b = finished || isMouthSyncOff(_curSoundPos);
 				if (_mouthSyncMode != b) {
 					_mouthSyncMode = b;
 					if (_talk_sound_frame != -1) {
@@ -466,6 +464,7 @@
 	int num = 0, i;
 	int size;
 	byte *sound;
+	int id = -1;
 
 	if ((_scumm->_gameId == GID_DIG) && (_scumm->_features & GF_DEMO)) {
 		char filename[30];
@@ -534,14 +533,10 @@
 	// HACK: Checking for script 99 in Sam & Max is to keep Conroy's song
 	// from being interrupted.
 
-	int talkChannel = (_talkChannelHandle - 1);	// EVIL HACK!!!
 	if (mode == 1 && (_scumm->_gameId == GID_TENTACLE
 		|| (_scumm->_gameId == GID_SAMNMAX && !_scumm->isScriptRunning(99)))) {
-		for (i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
-			if (i != talkChannel) {
-				_scumm->_mixer->stopHandle(i+1);	// EVIL HACK!!!!
-			}
-		}
+		id = 777777;
+		_scumm->_mixer->stopID(id);
 	}
 
 	if (b > 8) {
@@ -582,7 +577,7 @@
 	_curSoundPos = 0;
 	_mouthSyncMode = true;
 
-	startSfxSound(_sfxFile, size, handle);
+	startSfxSound(_sfxFile, size, handle, id);
 }
 
 void Sound::stopTalkSound() {
@@ -825,7 +820,7 @@
 	}
 }
 
-void Sound::startSfxSound(File *file, int file_size, PlayingSoundHandle *handle) {
+void Sound::startSfxSound(File *file, int file_size, PlayingSoundHandle *handle, int id) {
 	char ident[8];
 	uint size = 0;
 	int rate, comp;
@@ -837,11 +832,11 @@
 	if (file_size > 0) {
 		if (_vorbis_mode) {
 #ifdef USE_VORBIS
-			_scumm->_mixer->playVorbis(handle, file, file_size);
+			_scumm->_mixer->playVorbis(handle, file, file_size, 255, 0, id);
 #endif
 		} else {
 #ifdef USE_MAD
-			_scumm->_mixer->playMP3(handle, file, file_size);
+			_scumm->_mixer->playMP3(handle, file, file_size, 255, 0, id);
 #endif
 		}
 		return;
@@ -887,7 +882,7 @@
 		error("startSfxSound: cannot read %d bytes", size);
 	}
 
-	_scumm->_mixer->playRaw(handle, data, size, rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_UNSIGNED);
+	_scumm->_mixer->playRaw(handle, data, size, rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_UNSIGNED, id);
 }
 
 File *Sound::openSfxFile() {

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.h,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- sound.h	23 Dec 2003 00:17:29 -0000	1.57
+++ sound.h	23 Dec 2003 19:18:20 -0000	1.58
@@ -91,7 +91,7 @@
 
 protected:
 	File *openSfxFile();
-	void startSfxSound(File *file, int file_size, PlayingSoundHandle *handle);
+	void startSfxSound(File *file, int file_size, PlayingSoundHandle *handle, int id = -1);
 	bool isSfxFinished() const;
 };
 





More information about the Scummvm-git-logs mailing list