[Scummvm-git-logs] scummvm master -> 311b6fec1acb4d1396ab9773be712ba489406308
bluegr
noreply at scummvm.org
Fri May 20 06:55:12 UTC 2022
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:
311b6fec1a SCI: fix sound pausing when loading via kRestoreGame
Commit: 311b6fec1acb4d1396ab9773be712ba489406308
https://github.com/scummvm/scummvm/commit/311b6fec1acb4d1396ab9773be712ba489406308
Author: athrxx (athrxx at scummvm.org)
Date: 2022-05-20T09:55:07+03:00
Commit Message:
SCI: fix sound pausing when loading via kRestoreGame
This is similar to what we recently fixed for the saving. It does concern only the loading from the SCI menu and from the SCI death dialog (that's how it got my attention).
I have written a long comment in SciMusic::resetGlobalPauseCounter() which explains it.
I have decided to make this very obvious (you could say: more ugly), so it won't cause confusion in the future. Of course, it could be just hidden somewhere deep in SciMusic::saveLoadWithSerializer() and noone would ever notice. But the "ugly" way seemed the safer thing to do...
Changed paths:
engines/sci/engine/kfile.cpp
engines/sci/sound/music.cpp
engines/sci/sound/music.h
engines/sci/sound/soundcmd.cpp
engines/sci/sound/soundcmd.h
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index 3e7a6d02d39..eef93120829 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -1238,10 +1238,11 @@ reg_t kRestoreGame(EngineState *s, int argc, reg_t *argv) {
s->r_acc = TRUE_REG; // signals failure
}
- if (!s->r_acc.isNull()) {
- // no success?
- if (pausedMusic)
+ if (pausedMusic) {
+ if (!s->r_acc.isNull()) // no success?
g_sci->_soundCmd->pauseAll(false); // unpause music
+ else
+ g_sci->_soundCmd->resetGlobalPauseCounter(); // reset music global pause counter without affecting the individual sounds
}
return s->r_acc;
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp
index b145aee1283..a5d0720451d 100644
--- a/engines/sci/sound/music.cpp
+++ b/engines/sci/sound/music.cpp
@@ -294,6 +294,28 @@ void SciMusic::pauseAll(bool pause) {
}
}
+void SciMusic::resetGlobalPauseCounter() {
+ // This is an adjustment for our savegame loading process,
+ // ONLY when done from kRestoreGame().
+ // The enginge will call SciMusic::pauseAll() before loading.
+ // So the _globalPause will be increased and the individual
+ // sounds will be paused, too. However, the sounds will
+ // then be restored to the playing status that is stored in
+ // the savegame. The _globalPause stays, however. There may
+ // be no unpausing after the loading, since the playing status
+ // in the savegames is the correct one. So, the essence is:
+ // the _globalPause counter needs to go down without anything
+ // else happening.
+ // The loading from GMM has been implemented differently. It
+ // will remove the paused state before loading (and doesn't
+ // do anything unpleasant afterwards, either). So this is not
+ // needed there.
+ // I have added an assert, since it is such a special case,
+ // people need to know what they're doing if they call this...
+ assert(_globalPause == 1);
+ _globalPause = 0;
+}
+
void SciMusic::stopAll() {
const MusicList::iterator end = _playList.end();
for (MusicList::iterator i = _playList.begin(); i != end; ++i) {
diff --git a/engines/sci/sound/music.h b/engines/sci/sound/music.h
index 6596c21c351..f30d7d5cd3b 100644
--- a/engines/sci/sound/music.h
+++ b/engines/sci/sound/music.h
@@ -193,6 +193,7 @@ private:
public:
void clearPlayList();
void pauseAll(bool pause);
+ void resetGlobalPauseCounter();
void stopAll();
void stopAllSamples();
diff --git a/engines/sci/sound/soundcmd.cpp b/engines/sci/sound/soundcmd.cpp
index 08cb38edf49..057c594cce4 100644
--- a/engines/sci/sound/soundcmd.cpp
+++ b/engines/sci/sound/soundcmd.cpp
@@ -918,6 +918,10 @@ void SoundCommandParser::pauseAll(bool pause) {
_music->pauseAll(pause);
}
+void SoundCommandParser::resetGlobalPauseCounter() {
+ _music->resetGlobalPauseCounter();
+}
+
MusicType SoundCommandParser::getMusicType() const {
assert(_music);
return _music->soundGetMusicType();
diff --git a/engines/sci/sound/soundcmd.h b/engines/sci/sound/soundcmd.h
index c0f721137ee..66f574b9d3f 100644
--- a/engines/sci/sound/soundcmd.h
+++ b/engines/sci/sound/soundcmd.h
@@ -55,6 +55,7 @@ public:
// Functions used for the ScummVM menus
void setMasterVolume(int vol);
void pauseAll(bool pause);
+ void resetGlobalPauseCounter();
#ifdef ENABLE_SCI32
void setVolume(const reg_t obj, const int vol);
#endif
More information about the Scummvm-git-logs
mailing list