aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sound/audio32.cpp
diff options
context:
space:
mode:
authorColin Snover2017-06-04 22:04:46 -0500
committerColin Snover2017-07-30 19:22:35 -0500
commitcaa8293fcec4441bd0470ba545877aaf8145d81f (patch)
tree6145f32d11a165080811f9d9f4a813318167cdd6 /engines/sci/sound/audio32.cpp
parent5c3a2cf16afe29d950df4b6511b2d6c999561608 (diff)
downloadscummvm-rg350-caa8293fcec4441bd0470ba545877aaf8145d81f.tar.gz
scummvm-rg350-caa8293fcec4441bd0470ba545877aaf8145d81f.tar.bz2
scummvm-rg350-caa8293fcec4441bd0470ba545877aaf8145d81f.zip
SCI32: Make sure audio is not paused from the future
This can occur when a save game from the past is loaded and the audio system was paused prior to loading the save game. This was fixed eventually in SSCI somewhere around GK2, since it pauses all audio before restoring a game and then resumes it after the save game is loaded (after all of the audio channels have been added from the save game). Since this would seem to be a problem for earlier games as well, this change is applied universally instead of being conditionally applied only to the games with interpreters containing this change. This patch contains some additional sanity checks that emit warnings if individual channels end up being started from the future. There was never such checking in SSCI, and it does not seem likely to ever happen, but it is unclear right now if this is an actual problem or not.
Diffstat (limited to 'engines/sci/sound/audio32.cpp')
-rw-r--r--engines/sci/sound/audio32.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/engines/sci/sound/audio32.cpp b/engines/sci/sound/audio32.cpp
index be3f99dcea..7622305adb 100644
--- a/engines/sci/sound/audio32.cpp
+++ b/engines/sci/sound/audio32.cpp
@@ -842,6 +842,9 @@ uint16 Audio32::play(int16 channelIndex, const ResourceId resourceId, const bool
channel.startedAtTick = now;
if (_numActiveChannels == 1) {
+ if (_pausedAtTick) {
+ _pausedAtTick = now;
+ }
_startedAtTick = now;
}
@@ -868,18 +871,29 @@ bool Audio32::resume(const int16 channelIndex) {
AudioChannel &channel = getChannel(i);
if (!channel.pausedAtTick) {
channel.startedAtTick += now - _pausedAtTick;
+ if (channel.startedAtTick > now) {
+ warning("%s is being resumed in the future", channel.id.toString().c_str());
+ }
}
}
_startedAtTick += now - _pausedAtTick;
+ if (_startedAtTick > now) {
+ warning("Audio32 is being resumed in the future");
+ }
_pausedAtTick = 0;
return true;
} else if (channelIndex == kRobotChannel) {
for (int i = 0; i < _numActiveChannels; ++i) {
AudioChannel &channel = getChannel(i);
if (channel.robot) {
- channel.startedAtTick += now - channel.pausedAtTick;
- channel.pausedAtTick = 0;
+ if (channel.pausedAtTick) {
+ channel.startedAtTick += now - channel.pausedAtTick;
+ if (channel.startedAtTick > now) {
+ warning("Robot audio is being resumed in the future");
+ }
+ channel.pausedAtTick = 0;
+ }
return true;
}
}
@@ -887,6 +901,9 @@ bool Audio32::resume(const int16 channelIndex) {
AudioChannel &channel = getChannel(channelIndex);
if (channel.pausedAtTick) {
channel.startedAtTick += now - channel.pausedAtTick;
+ if (channel.startedAtTick > now) {
+ warning("%s is being resumed in the future", channel.id.toString().c_str());
+ }
channel.pausedAtTick = 0;
return true;
}