aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sound
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci/sound')
-rw-r--r--engines/sci/sound/audio.cpp13
-rw-r--r--engines/sci/sound/drivers/adlib.cpp4
-rw-r--r--engines/sci/sound/drivers/cms.cpp2
-rw-r--r--engines/sci/sound/drivers/fb01.cpp2
-rw-r--r--engines/sci/sound/soundcmd.cpp16
5 files changed, 17 insertions, 20 deletions
diff --git a/engines/sci/sound/audio.cpp b/engines/sci/sound/audio.cpp
index 528bb51393..8f405b0fa5 100644
--- a/engines/sci/sound/audio.cpp
+++ b/engines/sci/sound/audio.cpp
@@ -324,7 +324,10 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32
// Calculate samplelen from WAVE header
int waveSize = 0, waveRate = 0;
byte waveFlags = 0;
- Audio::loadWAVFromStream(*waveStream, waveSize, waveRate, waveFlags);
+ bool ret = Audio::loadWAVFromStream(*waveStream, waveSize, waveRate, waveFlags);
+ if (!ret)
+ error("Failed to load WAV from stream");
+
*sampleLen = (waveFlags & Audio::FLAG_16BITS ? waveSize >> 1 : waveSize) * 60 / waveRate;
waveStream->seek(0, SEEK_SET);
@@ -336,7 +339,10 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32
// Calculate samplelen from AIFF header
int waveSize = 0, waveRate = 0;
byte waveFlags = 0;
- Audio::loadAIFFFromStream(*waveStream, waveSize, waveRate, waveFlags);
+ bool ret = Audio::loadAIFFFromStream(*waveStream, waveSize, waveRate, waveFlags);
+ if (!ret)
+ error("Failed to load AIFF from stream");
+
*sampleLen = (waveFlags & Audio::FLAG_16BITS ? waveSize >> 1 : waveSize) * 60 / waveRate;
waveStream->seek(0, SEEK_SET);
@@ -347,6 +353,9 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32
Common::SeekableReadStream *sndStream = new Common::MemoryReadStream(audioRes->data, audioRes->size, DisposeAfterUse::NO);
audioSeekStream = Audio::makeMacSndStream(sndStream, DisposeAfterUse::YES);
+ if (!audioSeekStream)
+ error("Failed to load Mac sound stream");
+
} else {
// SCI1 raw audio
size = audioRes->size;
diff --git a/engines/sci/sound/drivers/adlib.cpp b/engines/sci/sound/drivers/adlib.cpp
index 191e13db0a..3229fd7071 100644
--- a/engines/sci/sound/drivers/adlib.cpp
+++ b/engines/sci/sound/drivers/adlib.cpp
@@ -512,7 +512,7 @@ int MidiDriver_AdLib::findVoiceBasic(int channel) {
}
if (voice == -1) {
- if (oldestVoice != -1) {
+ if (oldestVoice >= 0) {
voiceOff(oldestVoice);
voice = oldestVoice;
} else {
@@ -550,7 +550,7 @@ int MidiDriver_AdLib::findVoice(int channel) {
}
if (voice == -1) {
- if (oldestVoice != -1) {
+ if (oldestVoice >= 0) {
voiceOff(oldestVoice);
voice = oldestVoice;
} else {
diff --git a/engines/sci/sound/drivers/cms.cpp b/engines/sci/sound/drivers/cms.cpp
index dbcbf3d431..fd60863177 100644
--- a/engines/sci/sound/drivers/cms.cpp
+++ b/engines/sci/sound/drivers/cms.cpp
@@ -422,7 +422,7 @@ int MidiDriver_CMS::findVoiceBasic(int channel) {
}
if (voice == -1) {
- if (oldestVoice != -1) {
+ if (oldestVoice >= 0) {
voiceOff(oldestVoice);
voice = oldestVoice;
} else {
diff --git a/engines/sci/sound/drivers/fb01.cpp b/engines/sci/sound/drivers/fb01.cpp
index 9f3945bbec..b16473e62e 100644
--- a/engines/sci/sound/drivers/fb01.cpp
+++ b/engines/sci/sound/drivers/fb01.cpp
@@ -250,7 +250,7 @@ int MidiPlayer_Fb01::findVoice(int channel) {
}
if (voice == -1) {
- if (oldestVoice != -1) {
+ if (oldestVoice >= 0) {
voiceOff(oldestVoice);
voice = oldestVoice;
} else {
diff --git a/engines/sci/sound/soundcmd.cpp b/engines/sci/sound/soundcmd.cpp
index 873a16cc73..daba976f50 100644
--- a/engines/sci/sound/soundcmd.cpp
+++ b/engines/sci/sound/soundcmd.cpp
@@ -177,18 +177,6 @@ void SoundCommandParser::processPlaySound(reg_t obj) {
writeSelectorValue(_segMan, obj, SELECTOR(state), kSoundPlaying);
}
- // WORKAROUND: Songs 1840, 1843 and 1849 in the Windows version of KQ5CD
- // are all missing their channel 15 (all played during its ending
- // sequences, when fighting with Mordack). This makes the game scripts
- // wait indefinitely for the missing signals in these songs. In the
- // original interpreter, this bug manifests as an "Out of heap" error. We
- // signal the game scripts to stop waiting forever by setting the song's
- // dataInc selector to something other than 0. This causes Mordack's
- // appearing animation to occur a bit earlier than expected, but at least
- // the game doesn't freeze at that point. Fixes bug #3605269.
- if (g_sci->getGameId() == GID_KQ5 && (resourceId == 1840 || resourceId == 1843 || resourceId == 1849))
- musicSlot->dataInc = 1;
-
musicSlot->loop = readSelectorValue(_segMan, obj, SELECTOR(loop));
musicSlot->priority = readSelectorValue(_segMan, obj, SELECTOR(priority));
// Reset hold when starting a new song. kDoSoundSetHold is always called after
@@ -395,7 +383,7 @@ reg_t SoundCommandParser::kDoSoundFade(int argc, reg_t *argv, reg_t acc) {
if (musicSlot->fadeTo == musicSlot->volume)
return acc;
- // sometimes we get objects in that position, fix it up (ffs. workarounds)
+ // Sometimes we get objects in that position, so fix the value (refer to workarounds.cpp)
if (!argv[1].getSegment())
musicSlot->fadeStep = volume > musicSlot->fadeTo ? -argv[3].toUint16() : argv[3].toUint16();
else
@@ -749,7 +737,7 @@ void SoundCommandParser::updateSci0Cues() {
}
if (noOnePlaying && pWaitingForPlay) {
- // If there is a queued entry, play it now ffs: SciMusic::soundPlay()
+ // If there is a queued entry, play it now - check SciMusic::soundPlay()
pWaitingForPlay->isQueued = false;
_music->soundPlay(pWaitingForPlay);
}