diff options
author | Jussi Pitkanen | 2011-05-25 18:41:57 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2011-08-13 23:26:27 +0100 |
commit | 1f680ecbc83f34749911dd45be130b0580eb37a9 (patch) | |
tree | 8642ee3b23cc0bc52ac1105f206184a96303026d | |
parent | 010315dc0c1862de6778130e416880388b9d0bdf (diff) | |
download | scummvm-rg350-1f680ecbc83f34749911dd45be130b0580eb37a9.tar.gz scummvm-rg350-1f680ecbc83f34749911dd45be130b0580eb37a9.tar.bz2 scummvm-rg350-1f680ecbc83f34749911dd45be130b0580eb37a9.zip |
AGI: Detect the end of V1 sound resources correctly, fixing crashes
-rw-r--r-- | engines/agi/sound_pcjr.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/engines/agi/sound_pcjr.cpp b/engines/agi/sound_pcjr.cpp index f5cb5e7e1b..d5c6935139 100644 --- a/engines/agi/sound_pcjr.cpp +++ b/engines/agi/sound_pcjr.cpp @@ -126,6 +126,9 @@ SoundGenPCJr::SoundGenPCJr(AgiEngine *vm, Audio::Mixer *pMixer) : SoundGen(vm, p memset(_tchannel, 0, sizeof(_tchannel)); _mixer->playStream(Audio::Mixer::kMusicSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); + + _v1data = NULL; + _v1size = 0; } SoundGenPCJr::~SoundGenPCJr() { @@ -323,6 +326,17 @@ int SoundGenPCJr::getNextNote_v1(int ch, Tone *tone) { static bool fetched[4] = { false, false, false, false }; static int duration = 0; + + byte *data = _v1data; + uint32 len = _v1size; + int reg = 0; + + if (len <= 0 || data == NULL) { + _channel[ch].avail = 0; + _channel[ch].attenuation = 0x0F; + _channel[ch].attenuationCopy = 0x0F; + return -1; + } // Get previously fetched data if possible if (fetched[ch]) { @@ -348,13 +362,6 @@ int SoundGenPCJr::getNextNote_v1(int ch, Tone *tone) duration = 2 * CHAN_MAX; // Otherwise fetch a row of data for all channels - byte *data = _v1data; - uint32 len = _v1size; - int reg = 0; - - if (len <= 0 || data == NULL) - return -1; - fetched[0] = fetched[1] = fetched[2] = fetched[3] = true; while (*data) { |