mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-04 01:07:22 +00:00
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
This commit is contained in:
parent
4c3b4835aa
commit
1fffbe40ce
@ -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
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user