[Scummvm-cvs-logs] scummvm master -> 1fffbe40ceb82bec77479c56176abeff0d2bd5e5

bluegr md5 at scummvm.org
Sun Jul 15 16:41:08 CEST 2012


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
1fffbe40ce TINSEL: Change SetMidiVolume() so that it doesn't start/stop music tracks


Commit: 1fffbe40ceb82bec77479c56176abeff0d2bd5e5
    https://github.com/scummvm/scummvm/commit/1fffbe40ceb82bec77479c56176abeff0d2bd5e5
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2012-07-15T07:37:55-07:00

Commit Message:
TINSEL: Change SetMidiVolume() so that it doesn't start/stop music tracks

Previously, SetMidiVolume() would stop the currently playing track when
the MIDI volume was set to 0. Now, the music track always plays, even
when the volume is set to 0. This fixes bug #3541533 - "DW: Silencing
music volume stops music" and resolves two FIXME comments

Changed paths:
    engines/tinsel/music.cpp
    engines/tinsel/tinlib.cpp



diff --git a/engines/tinsel/music.cpp b/engines/tinsel/music.cpp
index 637e043..b3bfbcc 100644
--- a/engines/tinsel/music.cpp
+++ b/engines/tinsel/music.cpp
@@ -131,13 +131,11 @@ bool PlayMidiSequence(uint32 dwFileOffset, bool bLoop) {
 	g_currentMidi = dwFileOffset;
 	g_currentLoop = bLoop;
 
-	if (_vm->_config->_musicVolume != 0) {
-		bool mute = false;
-		if (ConfMan.hasKey("mute"))
-			mute = ConfMan.getBool("mute");
+	bool mute = false;
+	if (ConfMan.hasKey("mute"))
+		mute = ConfMan.getBool("mute");
 
-		SetMidiVolume(mute ? 0 : _vm->_config->_musicVolume);
-	}
+	SetMidiVolume(mute ? 0 : _vm->_config->_musicVolume);
 
 	// the index and length of the last tune loaded
 	uint32 dwSeqLen = 0;	// length of the sequence
@@ -270,27 +268,7 @@ int GetMidiVolume() {
  */
 void SetMidiVolume(int vol) {
 	assert(vol >= 0 && vol <= Audio::Mixer::kMaxChannelVolume);
-
-	static int priorVolMusic = 0;	// FIXME: Avoid non-const global vars
-
-	if (vol == 0 && priorVolMusic == 0)	{
-		// Nothing to do
-	} else if (vol == 0 && priorVolMusic != 0) {
-		// Stop current midi sequence
-		StopMidi();
-		_vm->_midiMusic->setVolume(vol);
-	} else if (vol != 0 && priorVolMusic == 0) {
-		// Perhaps restart last midi sequence
-		if (g_currentLoop)
-			PlayMidiSequence(g_currentMidi, true);
-
-		_vm->_midiMusic->setVolume(vol);
-	} else if (vol != 0 && priorVolMusic != 0) {
-		// Alter current volume
-		_vm->_midiMusic->setVolume(vol);
-	}
-
-	priorVolMusic = vol;
+	_vm->_midiMusic->setVolume(vol);
 }
 
 /**
@@ -933,14 +911,12 @@ void RestoreMidiFacts(SCNHANDLE	Midi, bool Loop) {
 	g_currentMidi = Midi;
 	g_currentLoop = Loop;
 
-	if (_vm->_config->_musicVolume != 0 && Loop) {
-		bool mute = false;
-		if (ConfMan.hasKey("mute"))
-			mute = ConfMan.getBool("mute");
+	bool mute = false;
+	if (ConfMan.hasKey("mute"))
+		mute = ConfMan.getBool("mute");
 
-		PlayMidiSequence(g_currentMidi, true);
-		SetMidiVolume(mute ? 0 : _vm->_config->_musicVolume);
-	}
+	PlayMidiSequence(g_currentMidi, true);
+	SetMidiVolume(mute ? 0 : _vm->_config->_musicVolume);
 }
 
 #if 0
diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp
index 7c4fec6..058f8eb 100644
--- a/engines/tinsel/tinlib.cpp
+++ b/engines/tinsel/tinlib.cpp
@@ -1625,10 +1625,6 @@ static void Play(CORO_PARAM, SCNHANDLE hFilm, int x, int y, bool bComplete, int
  * Play a midi file.
  */
 static void PlayMidi(CORO_PARAM, SCNHANDLE hMidi, int loop, bool complete) {
-	// FIXME: This is a workaround for the FIXME below
-	if (GetMidiVolume() == 0)
-		return;
-
 	CORO_BEGIN_CONTEXT;
 	CORO_END_CONTEXT(_ctx);
 
@@ -1637,18 +1633,13 @@ static void PlayMidi(CORO_PARAM, SCNHANDLE hMidi, int loop, bool complete) {
 
 	PlayMidiSequence(hMidi, loop == MIDI_LOOP);
 
-	// FIXME: The following check messes up the script arguments when
-	// entering the secret door in the bookshelf in the library,
-	// leading to a crash, when the music volume is set to 0 (MidiPlaying()
-	// always false then).
-	//
-	// Why exactly this happens is unclear. An analysis of the involved
-	// script(s) might reveal more.
-	//
-	// Note: This check&sleep was added in DW v2. It was most likely added
-	// to ensure that the MIDI song started playing before the next opcode
+	// This check&sleep was added in DW v2. It was most likely added to
+	// ensure that the MIDI song started playing before the next opcode
 	// is executed.
-	if (!MidiPlaying())
+	// In DW1, it messes up the script arguments when entering the secret
+	// door in the bookshelf in the library, leading to a crash, when the
+	// music volume is set to 0.
+	if (!MidiPlaying() && TinselV2)
 		CORO_SLEEP(1);
 
 	if (complete) {






More information about the Scummvm-git-logs mailing list