diff options
author | Paweł Kołodziejski | 2006-10-10 12:16:21 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2006-10-10 12:16:21 +0000 |
commit | e85ab4b10fedf9660efffb386512ed6a36956422 (patch) | |
tree | 2d0bbc3814009f3527d7926cd0f5674fdfcace68 | |
parent | 89f79acb84071d56c3758281287d9c3b0c0ed545 (diff) | |
download | scummvm-rg350-e85ab4b10fedf9660efffb386512ed6a36956422.tar.gz scummvm-rg350-e85ab4b10fedf9660efffb386512ed6a36956422.tar.bz2 scummvm-rg350-e85ab4b10fedf9660efffb386512ed6a36956422.zip |
now SmushPlayer is class created once same as SmushMixer while scumm engine creation. this allow finish play smush audio track finished to the end instead immediately stopped as it was happen before
svn-id: r24263
-rw-r--r-- | engines/scumm/insane/insane.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/insane/insane_scenes.cpp | 4 | ||||
-rw-r--r-- | engines/scumm/intern.h | 2 | ||||
-rw-r--r-- | engines/scumm/script_v6.cpp | 7 | ||||
-rw-r--r-- | engines/scumm/script_v8.cpp | 4 | ||||
-rw-r--r-- | engines/scumm/scumm.cpp | 8 | ||||
-rw-r--r-- | engines/scumm/smush/smush_player.cpp | 29 | ||||
-rw-r--r-- | engines/scumm/smush/smush_player.h | 9 |
8 files changed, 36 insertions, 29 deletions
diff --git a/engines/scumm/insane/insane.cpp b/engines/scumm/insane/insane.cpp index 86deddeda1..919baa143b 100644 --- a/engines/scumm/insane/insane.cpp +++ b/engines/scumm/insane/insane.cpp @@ -620,7 +620,7 @@ void Insane::startVideo(const char *filename, int num, int argC, int frameRate, smush_setupSanFromStart(filename, 0, -1, -1, 0); } - _player->play(filename, offset, startFrame); + _player->play(filename, _speed, offset, startFrame); } void Insane::smush_warpMouse(int x, int y, int buttons) { diff --git a/engines/scumm/insane/insane_scenes.cpp b/engines/scumm/insane/insane_scenes.cpp index 5beca36999..dcc78a840b 100644 --- a/engines/scumm/insane/insane_scenes.cpp +++ b/engines/scumm/insane/insane_scenes.cpp @@ -36,7 +36,7 @@ namespace Scumm { void Insane::runScene(int arraynum) { _insaneIsRunning = true; - _player = new SmushPlayer(_vm, _speed); + _player = _vm->_splayer; _player->insanity(true); _numberArray = arraynum; @@ -170,8 +170,6 @@ void Insane::runScene(int arraynum) { } // insane_unlock(); // FIXME _vm->_sound->stopAllSounds(); // IMUSE_StopAllSounds(); - - delete _player; } int Insane::initScene(int sceneId) { diff --git a/engines/scumm/intern.h b/engines/scumm/intern.h index 721931f08d..413446fca2 100644 --- a/engines/scumm/intern.h +++ b/engines/scumm/intern.h @@ -30,6 +30,7 @@ namespace Scumm { class Insane; class SmushMixer; +class SmushPlayer; // This is to help devices with small memory (PDA, smartphones, ...) // to save abit of memory used by opcode names in the Scumm engine. @@ -598,6 +599,7 @@ public: bool _insaneRunning; // Used by IMuseDigital::flushTracks() SmushMixer *_smixer; + SmushPlayer *_splayer; public: ScummEngine_v6(OSystem *syst, const DetectorResult &dr); diff --git a/engines/scumm/script_v6.cpp b/engines/scumm/script_v6.cpp index 87660c6db3..0b507979bd 100644 --- a/engines/scumm/script_v6.cpp +++ b/engines/scumm/script_v6.cpp @@ -2526,15 +2526,12 @@ void ScummEngine_v6::o6_kernelSetFunctions() { if (strcmp((char *)getStringAddressVar(VAR_VIDEONAME), "sq3.san") == 0) _smushFrameRate = 14; - SmushPlayer *sp = new SmushPlayer((ScummEngine_v7 *)this, _smushFrameRate); - // Correct incorrect smush filename in Macintosh FT demo if ((_game.id == GID_FT) && (_game.features & GF_DEMO) && (_game.platform == Common::kPlatformMacintosh) && (strcmp((char *)getStringAddressVar(VAR_VIDEONAME), "jumpgorge.san") == 0)) - sp->play("jumpgorg.san"); + _splayer->play("jumpgorg.san", _smushFrameRate); else - sp->play((char *)getStringAddressVar(VAR_VIDEONAME)); - delete sp; + _splayer->play((char *)getStringAddressVar(VAR_VIDEONAME), _smushFrameRate); if (_game.id == GID_DIG) { _disableFadeInEffect = true; diff --git a/engines/scumm/script_v8.cpp b/engines/scumm/script_v8.cpp index dc45095570..a6e8587a50 100644 --- a/engines/scumm/script_v8.cpp +++ b/engines/scumm/script_v8.cpp @@ -1176,9 +1176,7 @@ void ScummEngine_v8::o8_systemOps() { void ScummEngine_v8::o8_startVideo() { int len = resStrLen(_scriptPointer); - SmushPlayer *sp = new SmushPlayer(this, 12); - sp->play((const char*)_scriptPointer); - delete sp; + _splayer->play((const char*)_scriptPointer, 12); _scriptPointer += len + 1; } diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 9ccf8b3838..fc47b5cbc4 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -42,6 +42,7 @@ #include "scumm/imuse/imuse.h" #include "scumm/imuse_digi/dimuse.h" #include "scumm/smush/smush_mixer.h" +#include "scumm/smush/smush_player.h" #include "scumm/insane/insane.h" #include "scumm/intern.h" #include "scumm/he/animation_he.h" @@ -779,6 +780,7 @@ ScummEngine_v7::ScummEngine_v7(OSystem *syst, const DetectorResult &dr) _smushActive = false; _insaneRunning = false; _smixer = NULL; + _splayer = NULL; _existLanguageFile = false; _languageBuffer = NULL; @@ -791,6 +793,10 @@ ScummEngine_v7::~ScummEngine_v7() { _smixer->stop(); delete _smixer; } + if (_splayer) { + _splayer->release(); + delete _splayer; + } free(_languageBuffer); free(_languageIndex); @@ -1107,6 +1113,8 @@ void ScummEngine_v7::setupScumm() { _insane = 0; _smixer = new SmushMixer(_mixer); + + _splayer = new SmushPlayer(this); } #endif diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp index 7eade65a97..4f47994cec 100644 --- a/engines/scumm/smush/smush_player.cpp +++ b/engines/scumm/smush/smush_player.cpp @@ -235,11 +235,11 @@ void SmushPlayer::timerCallback(void *refCon) { #endif } -SmushPlayer::SmushPlayer(ScummEngine_v7 *scumm, int speed) { +SmushPlayer::SmushPlayer(ScummEngine_v7 *scumm) { _vm = scumm; _version = -1; _nbframes = 0; - _smixer = 0; + _smixer = NULL; _strings = NULL; _sf[0] = NULL; _sf[1] = NULL; @@ -261,7 +261,7 @@ SmushPlayer::SmushPlayer(ScummEngine_v7 *scumm, int speed) { _IACTpos = 0; _soundFrequency = 22050; _initDone = false; - _speed = speed; + _speed = -1; _insanity = false; _middleAudio = false; _skipPalette = false; @@ -278,12 +278,13 @@ SmushPlayer::SmushPlayer(ScummEngine_v7 *scumm, int speed) { } SmushPlayer::~SmushPlayer() { - release(); } -void SmushPlayer::init() { +void SmushPlayer::init(int32 speed) { _frame = 0; + _speed = speed; _alreadyInit = false; + _endOfFile = false; _vm->_smushVideoShouldFinish = false; _vm->_smushActive = true; @@ -302,6 +303,8 @@ void SmushPlayer::init() { _vm->virtscr[0].pitch = _vm->virtscr[0].w; _vm->_gdi->_numStrips = _vm->virtscr[0].w / 8; + _vm->_mixer->stopHandle(_compressedFileSoundHandle); + _vm->_mixer->stopHandle(_IACTchannel); _vm->_smixer->stop(); Common::g_timer->installTimerProc(&timerCallback, 1000000 / _speed, this); @@ -340,9 +343,6 @@ void SmushPlayer::release() { free(_frameBuffer); _frameBuffer = NULL; - _vm->_mixer->stopHandle(_compressedFileSoundHandle); - - _vm->_mixer->stopHandle(_IACTchannel); _IACTstream = NULL; _vm->_smushActive = false; @@ -1115,6 +1115,7 @@ void SmushPlayer::parseNextFrame() { assert(_base); if (_base->eof()) { _vm->_smushVideoShouldFinish = true; + _endOfFile = true; return; } @@ -1273,7 +1274,7 @@ void SmushPlayer::tryCmpFile(const char *filename) { #endif } -void SmushPlayer::play(const char *filename, int32 offset, int32 startFrame) { +void SmushPlayer::play(const char *filename, int32 speed, int32 offset, int32 startFrame) { // Verify the specified file exists ScummFile f; @@ -1299,7 +1300,7 @@ void SmushPlayer::play(const char *filename, int32 offset, int32 startFrame) { _base = 0; setupAnim(filename); - init(); + init(speed); for (;;) { if (_warpNeeded) { @@ -1345,12 +1346,14 @@ void SmushPlayer::play(const char *filename, int32 offset, int32 startFrame) { _inTimerCount = 0; #endif } - if (_vm->_quit || _vm->_saveLoadFlag) { + if (_endOfFile) + break; + if (_vm->_quit || _vm->_saveLoadFlag || _vm->_smushVideoShouldFinish) { _smixer->stop(); + _vm->_mixer->stopHandle(_compressedFileSoundHandle); + _vm->_mixer->stopHandle(_IACTchannel); break; } - if (_vm->_smushVideoShouldFinish || _vm->_quit || _vm->_saveLoadFlag) - break; _vm->_system->delayMillis(10); } diff --git a/engines/scumm/smush/smush_player.h b/engines/scumm/smush/smush_player.h index 455f1414b9..34728b9e4f 100644 --- a/engines/scumm/smush/smush_player.h +++ b/engines/scumm/smush/smush_player.h @@ -73,6 +73,7 @@ private: bool _initDone; int _speed; bool _outputSound; + bool _endOfFile; byte *_dst; bool _updateNeeded; @@ -94,10 +95,11 @@ private: Common::Mutex _mutex; public: - SmushPlayer(ScummEngine_v7 *scumm, int speed); + SmushPlayer(ScummEngine_v7 *scumm); ~SmushPlayer(); - void play(const char *filename, int32 offset = 0, int32 startFrame = 0); + void play(const char *filename, int32 speed, int32 offset = 0, int32 startFrame = 0); + void release(); void warpMouse(int x, int y, int buttons); protected: @@ -115,8 +117,7 @@ protected: private: void parseNextFrame(); - void init(); - void release(); + void init(int32 spped); void setupAnim(const char *file); void updateScreen(); void tryCmpFile(const char *filename); |