From 38b82fb585ba23db45dee094e7dc9a0b19939910 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sun, 5 Mar 2006 12:15:39 +0000 Subject: that should help for bug #1352486, smush sound tracks are not stopped immediately, but outside smush when sound data are depleted in sound mixer buffer. svn-id: r21094 --- engines/scumm/smush/smush_mixer.cpp | 21 ++++++++++++++++++++- engines/scumm/smush/smush_mixer.h | 1 + engines/scumm/smush/smush_player.cpp | 16 +++++++--------- 3 files changed, 28 insertions(+), 10 deletions(-) (limited to 'engines/scumm/smush') 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); } -- cgit v1.2.3