diff options
-rw-r--r-- | engines/scumm/imuse_digi/dimuse.cpp | 47 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_script.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_track.cpp | 12 |
3 files changed, 29 insertions, 32 deletions
diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp index afb707504c..71a2977b83 100644 --- a/engines/scumm/imuse_digi/dimuse.cpp +++ b/engines/scumm/imuse_digi/dimuse.cpp @@ -339,11 +339,10 @@ void IMuseDigital::callback() { void IMuseDigital::switchToNextRegion(Track *track) { assert(track); - debug(5, "switchToNextRegion(track:%d)", track->trackId); if (track->trackId >= MAX_DIGITAL_TRACKS) { flushTrack(track); - debug(5, "exit (fadetrack can't go next region) switchToNextRegion(trackId:%d)", track->trackId); + debug(5, "SwToNeReg(trackId:%d) - fadetrack can't go next region, exiting SwToNeReg", track->trackId); return; } @@ -352,20 +351,21 @@ void IMuseDigital::switchToNextRegion(Track *track) { if (++track->curRegion == num_regions) { flushTrack(track); - debug(5, "exit (end of regions) switchToNextRegion(track:%d)", track->trackId); + debug(5, "SwToNeReg(trackId:%d) - end of region, exiting SwToNeReg", track->trackId); return; } ImuseDigiSndMgr::SoundDesc *soundDesc = track->soundDesc; if (_triggerUsed && track->soundDesc->numMarkers) { if (_sound->checkForTriggerByRegionAndMarker(soundDesc, track->curRegion, _triggerParams.marker)) { - debug(5, "trigger %s reached, switchToNextRegion(track:%d)", _triggerParams.marker, track->trackId); - debug(5, "exit current region, switchToNextRegion(track:%d)", track->trackId); + debug(5, "SwToNeReg(trackId:%d) - trigger %s reached", track->trackId, _triggerParams.marker); + debug(5, "SwToNeReg(trackId:%d) - exit current region %d", track->trackId, track->curRegion); + debug(5, "SwToNeReg(trackId:%d) - call cloneToFadeOutTrack(delay:%d)", track->trackId, _triggerParams.fadeOutDelay); Track *fadeTrack = cloneToFadeOutTrack(track, _triggerParams.fadeOutDelay); if (fadeTrack) { fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundDesc, fadeTrack->curRegion); fadeTrack->regionOffset = 0; - debug(5, "switchToNextRegion-sound(%d) select region %d, curHookId: %d", fadeTrack->soundId, fadeTrack->curRegion, fadeTrack->curHookId); + debug(5, "SwToNeReg(trackId:%d)-sound(%d) select region %d, curHookId: %d", fadeTrack->trackId, fadeTrack->soundId, fadeTrack->curRegion, fadeTrack->curHookId); fadeTrack->curHookId = 0; } flushTrack(track); @@ -376,46 +376,39 @@ void IMuseDigital::switchToNextRegion(Track *track) { } int jumpId = _sound->getJumpIdByRegionAndHookId(soundDesc, track->curRegion, track->curHookId); - if (jumpId == -1) - jumpId = _sound->getJumpIdByRegionAndHookId(soundDesc, track->curRegion, 0); if (jumpId != -1) { int region = _sound->getRegionIdByJumpId(soundDesc, jumpId); assert(region != -1); int sampleHookId = _sound->getJumpHookId(soundDesc, jumpId); assert(sampleHookId != -1); int fadeDelay = (60 * _sound->getJumpFade(soundDesc, jumpId)) / 1000; - if (sampleHookId != 0) { - if (track->curHookId == sampleHookId) { - if (fadeDelay != 0 && previous_region != -1) { - Track *fadeTrack = cloneToFadeOutTrack(track, fadeDelay); - if (fadeTrack) { - fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundDesc, fadeTrack->curRegion); - fadeTrack->regionOffset = 0; - debug(5, "switchToNextRegion-sound(%d) select region %d, curHookId: %d", fadeTrack->soundId, fadeTrack->curRegion, fadeTrack->curHookId); - fadeTrack->curHookId = 0; - } - } - track->curRegion = region; - debug(5, "switchToNextRegion-sound(%d) jump to region %d, curHookId: %d", track->soundId, track->curRegion, track->curHookId); - track->curHookId = 0; - } - } else { + debug(5, "SwToNeReg(trackId:%d) - JUMP found - sound:%d, track hookId:%d, data hookId:%d", track->trackId, track->soundId, track->curHookId, sampleHookId); + if (track->curHookId == sampleHookId) { + debug(5, "SwToNeReg(trackId:%d) - sound(%d) match hookId", track->trackId, track->soundId); if (fadeDelay != 0 && previous_region != -1) { + debug(5, "SwToNeReg(trackId:%d) - call cloneToFadeOutTrack(delay:%d)", track->trackId, fadeDelay); Track *fadeTrack = cloneToFadeOutTrack(track, fadeDelay); if (fadeTrack) { fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundDesc, fadeTrack->curRegion); fadeTrack->regionOffset = 0; - debug(5, "switchToNextRegion-sound(%d) select region %d, curHookId: %d", fadeTrack->soundId, fadeTrack->curRegion, fadeTrack->curHookId); + debug(5, "SwToNeReg(trackId:%d) - sound(%d) faded track, select region %d, curHookId: %d", fadeTrack->trackId, fadeTrack->soundId, fadeTrack->curRegion, fadeTrack->curHookId); + fadeTrack->curHookId = 0; } } track->curRegion = region; - debug(5, "switchToNextRegion-sound(%d) jump to region %d, curHookId: %d", track->soundId, track->curRegion, track->curHookId); + debug(5, "SwToNeReg(trackId:%d) - sound(%d) jump to region %d, curHookId: %d", track->trackId, track->soundId, track->curRegion, track->curHookId); + track->curHookId = 0; + } else { + debug(5, "SwToNeReg(trackId:%d) - Normal switch region, sound(%d), hookId(%d)", track->trackId, track->soundId, track->curHookId); } + } else { + debug(5, "SwToNeReg(trackId:%d) - Normal switch region, sound(%d), hookId(%d)", track->trackId, track->soundId, track->curHookId); } - debug(5, "switchToNextRegion-sound(%d) select region %d, curHookId: %d", track->soundId, track->curRegion, track->curHookId); + debug(5, "SwToNeReg(trackId:%d) - sound(%d), select region %d", track->trackId, track->soundId, track->curRegion); track->dataOffset = _sound->getRegionOffset(soundDesc, track->curRegion); track->regionOffset = 0; + debug(5, "SwToNeReg(trackId:%d) - end of func", track->trackId); } } // End of namespace Scumm diff --git a/engines/scumm/imuse_digi/dimuse_script.cpp b/engines/scumm/imuse_digi/dimuse_script.cpp index 76c349d4b6..83ccebb1be 100644 --- a/engines/scumm/imuse_digi/dimuse_script.cpp +++ b/engines/scumm/imuse_digi/dimuse_script.cpp @@ -405,7 +405,7 @@ int32 IMuseDigital::getCurMusicLipSyncHeight(int syncId) { void IMuseDigital::stopAllSounds() { Common::StackLock lock(_mutex, "IMuseDigital::stopAllSounds()"); - debug(0, "IMuseDigital::stopAllSounds"); + debug(5, "IMuseDigital::stopAllSounds"); for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) { Track *track = _track[l]; diff --git a/engines/scumm/imuse_digi/dimuse_track.cpp b/engines/scumm/imuse_digi/dimuse_track.cpp index d91e272c2d..00ec708438 100644 --- a/engines/scumm/imuse_digi/dimuse_track.cpp +++ b/engines/scumm/imuse_digi/dimuse_track.cpp @@ -83,13 +83,14 @@ int IMuseDigital::allocSlot(int priority) { void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, int volGroupId, Audio::AudioStream *input, int hookId, int volume, int priority, Track *otherTrack) { Common::StackLock lock(_mutex, "IMuseDigital::startSound()"); - debug(5, "IMuseDigital::startSound(%d)", soundId); + debug(5, "IMuseDigital::startSound(%d) - begin func", soundId); int l = allocSlot(priority); if (l == -1) { warning("IMuseDigital::startSound() Can't start sound - no free slots"); return; } + debug(5, "IMuseDigital::startSound(%d)(trackId:%d)", soundId, l); Track *track = _track[l]; @@ -104,6 +105,7 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, track->soundPriority = priority; track->curRegion = -1; track->soundType = soundType; + track->trackId = l; int bits = 0, freq = 0, channels = 0; @@ -329,10 +331,10 @@ Track *IMuseDigital::cloneToFadeOutTrack(Track *track, int fadeDelay) { assert(track); Track *fadeTrack; - debug(0, "IMuseDigital::cloneToFadeOutTrack(%d, %d)", track->trackId, fadeDelay); + debug(5, "cloneToFadeOutTrack(%d, %d) - begin of func", track->trackId, fadeDelay); if (track->toBeRemoved) { - error("IMuseDigital::cloneToFadeOutTrack: Tried to clone a track to be removed"); + error("cloneToFadeOutTrack: Tried to clone a track to be removed. exit func"); return NULL; } @@ -340,7 +342,7 @@ Track *IMuseDigital::cloneToFadeOutTrack(Track *track, int fadeDelay) { fadeTrack = _track[track->trackId + MAX_DIGITAL_TRACKS]; if (fadeTrack->used) { - warning("IMuseDigital::cloneToFadeOutTrack: No free fade track, force flush"); + warning("cloneToFadeOutTrack: No free fade track, force flush"); flushTrack(fadeTrack); _mixer->stopHandle(fadeTrack->mixChanHandle); } @@ -364,6 +366,8 @@ Track *IMuseDigital::cloneToFadeOutTrack(Track *track, int fadeDelay) { _mixer->playInputStream(track->getType(), &fadeTrack->mixChanHandle, fadeTrack->stream, -1, fadeTrack->getVol(), fadeTrack->getPan()); fadeTrack->used = true; + debug(5, "cloneToFadeOutTrack() - end of func, track %d, fadeTrackId %d", track->trackId, fadeTrack->trackId); + return fadeTrack; } |