From 4f51ae998842324c268a08a6b88ca9e6f8b84c4e Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 22 Aug 2004 15:02:53 +0000 Subject: Basic start on freddemo (old version) svn-id: r14685 --- scumm/sound.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'scumm/sound.cpp') diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 1770287002..d32301bd8e 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -160,6 +160,7 @@ void Sound::playSound(int soundID, int offset) { int size = -1; int rate; byte flags = SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE; + bool music = false; debugC(DEBUG_SOUND, "playSound #%d (room %d)", soundID, _vm->getResourceRoomNr(rtSound, soundID)); @@ -189,20 +190,24 @@ void Sound::playSound(int soundID, int offset) { music_offs = musicFile.readUint32LE(); size = musicFile.readUint32LE(); - if (music_offs > total_size || (size + music_offs) > total_size) - error("Bad music offsets"); + if (music_offs > total_size || (size + music_offs) > total_size) { + warning("Bad music offsets"); + musicFile.close(); + return; + } musicFile.seek(music_offs, SEEK_SET); ptr = (byte *) calloc(size, 1); musicFile.read(ptr, size); musicFile.close(); + _currentMusic = soundID; + music = true; if (_vm->_heversion == 70) { // Allocate a sound buffer, copy the data into it, and play sound = (char *)malloc(size); memcpy(sound, ptr, size); free(ptr); - _currentMusic = soundID; _vm->_mixer->stopHandle(_musicChannelHandle); _vm->_mixer->playRaw(&_musicChannelHandle, sound, size, 11025, flags, soundID); return; @@ -251,7 +256,12 @@ void Sound::playSound(int soundID, int offset) { // Allocate a sound buffer, copy the data into it, and play sound = (char *)malloc(size); memcpy(sound, ptr + offset + 8, size); - _vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID); + + if (music == true) { + _vm->_mixer->stopHandle(_musicChannelHandle); + _vm->_mixer->playRaw(&_musicChannelHandle, sound, size, rate, flags, soundID); + } else + _vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID); } else if (READ_UINT32(ptr) == MKID('MRAW')) { // pcm music in 3DO humongous games -- cgit v1.2.3