diff options
-rw-r--r-- | engines/scumm/scumm.cpp | 10 | ||||
-rw-r--r-- | engines/scumm/scumm.h | 2 | ||||
-rw-r--r-- | engines/scumm/smush/smush_mixer.cpp | 21 | ||||
-rw-r--r-- | engines/scumm/smush/smush_mixer.h | 1 | ||||
-rw-r--r-- | engines/scumm/smush/smush_player.cpp | 16 |
5 files changed, 40 insertions, 10 deletions
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 22c10291c4..4e86da1e73 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -43,6 +43,7 @@ #include "scumm/file.h" #include "scumm/imuse/imuse.h" #include "scumm/imuse_digi/dimuse.h" +#include "scumm/smush/smush_mixer.h" #include "scumm/insane/insane.h" #include "scumm/intern.h" #include "scumm/he/intern_he.h" @@ -502,6 +503,7 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS // Init all vars _imuse = NULL; _imuseDigital = NULL; + _smixer = NULL; _musicEngine = NULL; _verbs = NULL; _objs = NULL; @@ -932,6 +934,10 @@ ScummEngine::~ScummEngine() { delete _musicEngine; } +#ifndef DISABLE_SCUMM_7_8 + _smixer->stop(); + delete _smixer; +#endif _mixer->stopAll(); delete [] _actors; @@ -1649,6 +1655,7 @@ void ScummEngine::setupMusic(int midi) { if (_game.features & GF_DIGI_IMUSE) { #ifndef DISABLE_SCUMM_7_8 _musicEngine = _imuseDigital = new IMuseDigital(this, 10); + _smixer = new SmushMixer(_mixer); #endif } else if (_game.platform == Common::kPlatformC64) { // TODO @@ -2076,6 +2083,9 @@ load_game: if ( ((_game.id == GID_DIG) && (!(_game.features & GF_DEMO))) || (_game.id == GID_CMI) ) _imuseDigital->refreshScripts(); } + if (_smixer) { + _smixer->flush(); + } #endif camera._last = camera._cur; diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index bee33b8aaa..38203f6f79 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -55,6 +55,7 @@ class CharsetRenderer; class IMuse; class IMuseDigital; class Insane; +class SmushMixer; class MusicEngine; class ScummEngine; class ScummDebugger; @@ -429,6 +430,7 @@ public: IMuseDigital *_imuseDigital; MusicEngine *_musicEngine; Sound *_sound; + SmushMixer *_smixer; VerbSlot *_verbs; ObjectData *_objs; diff --git a/engines/scumm/smush/smush_mixer.cpp b/engines/scumm/smush/smush_mixer.cpp index 63ac6e445c..a7b8fb9b27 100644 --- a/engines/scumm/smush/smush_mixer.cpp +++ b/engines/scumm/smush/smush_mixer.cpp @@ -153,10 +153,29 @@ bool SmushMixer::stop() { _channels[i].chan = NULL; if (_channels[i].stream) { _channels[i].stream->finish(); - _channels[i].stream = 0; + _channels[i].stream = NULL; } } } + + return true; +} + +bool SmushMixer::flush() { + Common::StackLock lock(_mutex); + debugC(DEBUG_SMUSH, "SmushMixer::flush()"); + for (int i = 0; i < NUM_CHANNELS; i++) { + if (_channels[i].id != -1) { + if (_channels[i].stream->endOfStream()) { + _mixer->stopHandle(_channels[i].handle); + delete _channels[i].chan; + _channels[i].id = -1; + _channels[i].chan = NULL; + _channels[i].stream = NULL; + } + } + } + return true; } diff --git a/engines/scumm/smush/smush_mixer.h b/engines/scumm/smush/smush_mixer.h index 2a7c2d3ebc..82b233873d 100644 --- a/engines/scumm/smush/smush_mixer.h +++ b/engines/scumm/smush/smush_mixer.h @@ -56,6 +56,7 @@ public: void addChannel(SmushChannel *c); bool handleFrame(); bool stop(); + bool flush(); bool update(); }; diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp index a96456b44f..ebbea35dfa 100644 --- a/engines/scumm/smush/smush_player.cpp +++ b/engines/scumm/smush/smush_player.cpp @@ -265,6 +265,7 @@ SmushPlayer::SmushPlayer(ScummEngine_v6 *scumm, int speed) { _middleAudio = false; _skipPalette = false; _IACTstream = NULL; + _smixer = _vm->_smixer; #ifdef _WIN32_WCE _inTimer = false; _inTimerCount = 0; @@ -297,7 +298,8 @@ void SmushPlayer::init() { _vm->virtscr[0].pitch = _vm->virtscr[0].w; _vm->gdi._numStrips = _vm->virtscr[0].w / 8; - _smixer = new SmushMixer(_vm->_mixer); + _vm->_smixer->stop(); + Common::g_timer->installTimerProc(&timerCallback, 1000000 / _speed, this); _initDone = true; @@ -325,12 +327,6 @@ void SmushPlayer::release() { delete _strings; _strings = NULL; - if (_smixer) - _smixer->stop(); - - delete _smixer; - _smixer = NULL; - delete _base; _base = NULL; @@ -343,7 +339,7 @@ void SmushPlayer::release() { _vm->_mixer->stopHandle(_compressedFileSoundHandle); _vm->_mixer->stopHandle(_IACTchannel); - _IACTstream = 0; + _IACTstream = NULL; _vm->_fullRedraw = true; @@ -1371,8 +1367,10 @@ void SmushPlayer::play(const char *filename, int32 offset, int32 startFrame) { debugC(DEBUG_SMUSH, "Smush stats: BackendUpdateScreen( %03d )", end_time - start_time); } - if (_vm->_smushVideoShouldFinish || _vm->_quit || _vm->_saveLoadFlag) + if (_vm->_smushVideoShouldFinish || _vm->_quit || _vm->_saveLoadFlag) { + _smixer->stop(); break; + } _vm->_system->delayMillis(10); } |