SCUMM: (v1-3) - fix sound recovery when loading savegames

Prevent "stuttering" from starting the music multiple times (which may now happen due to the improved savegame loading for v1-3).

Also add some more tweaks to minimize stuttering, like setting volume to 0 during loading.

The result now seems to match what I get when using an emulator.
This commit is contained in:
athrxx 2022-05-12 01:33:50 +02:00
parent ed8e1c4870
commit dfe6082a12
2 changed files with 26 additions and 8 deletions

View file

@ -396,6 +396,10 @@ bool ScummEngine::loadState(int slot, bool compat, Common::String &filename) {
hdr.name[sizeof(hdr.name)-1] = 0;
_saveLoadDescription = hdr.name;
// Set to 0 during load to minimize stuttering
if (_musicEngine)
_musicEngine->setMusicVolume(0);
// Unless specifically requested with _saveSound, we do not save the iMUSE
// state for temporary state saves - such as certain cutscenes in DOTT,
// FOA, Sam and Max, etc.
@ -450,12 +454,6 @@ bool ScummEngine::loadState(int slot, bool compat, Common::String &filename) {
saveLoadWithSerializer(ser);
delete in;
// Update volume settings
syncSoundSettings();
if (_townsPlayer && (hdr.ver >= VER(81)))
_townsPlayer->restoreAfterLoad();
// Init NES costume data
if (_game.platform == Common::kPlatformNES) {
if (hdr.ver < VER(47))
@ -1497,7 +1495,8 @@ void ScummEngine::saveLoadWithSerializer(Common::Serializer &s) {
// If we are loading, and the music being loaded was supposed to loop
// forever, then resume playing it. This helps a lot when the audio CD
// is used to provide ambient music (see bug #1150).
if (s.isLoading() && info.playing && info.numLoops < 0)
// FM-Towns versions handle this in Player_Towns_v1::restoreAfterLoad().
if (s.isLoading() && info.playing && info.numLoops < 0 && _game.platform != Common::kPlatformFMTowns)
_sound->playCDTrackInternal(info.track, info.numLoops, info.start, info.duration);
}