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
This commit is contained in:
Paweł Kołodziejski 2006-10-10 12:16:21 +00:00
parent 89f79acb84
commit e85ab4b10f
8 changed files with 36 additions and 29 deletions

View file

@ -620,7 +620,7 @@ void Insane::startVideo(const char *filename, int num, int argC, int frameRate,
smush_setupSanFromStart(filename, 0, -1, -1, 0); 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) { void Insane::smush_warpMouse(int x, int y, int buttons) {

View file

@ -36,7 +36,7 @@ namespace Scumm {
void Insane::runScene(int arraynum) { void Insane::runScene(int arraynum) {
_insaneIsRunning = true; _insaneIsRunning = true;
_player = new SmushPlayer(_vm, _speed); _player = _vm->_splayer;
_player->insanity(true); _player->insanity(true);
_numberArray = arraynum; _numberArray = arraynum;
@ -170,8 +170,6 @@ void Insane::runScene(int arraynum) {
} }
// insane_unlock(); // FIXME // insane_unlock(); // FIXME
_vm->_sound->stopAllSounds(); // IMUSE_StopAllSounds(); _vm->_sound->stopAllSounds(); // IMUSE_StopAllSounds();
delete _player;
} }
int Insane::initScene(int sceneId) { int Insane::initScene(int sceneId) {

View file

@ -30,6 +30,7 @@ namespace Scumm {
class Insane; class Insane;
class SmushMixer; class SmushMixer;
class SmushPlayer;
// This is to help devices with small memory (PDA, smartphones, ...) // This is to help devices with small memory (PDA, smartphones, ...)
// to save abit of memory used by opcode names in the Scumm engine. // to save abit of memory used by opcode names in the Scumm engine.
@ -598,6 +599,7 @@ public:
bool _insaneRunning; // Used by IMuseDigital::flushTracks() bool _insaneRunning; // Used by IMuseDigital::flushTracks()
SmushMixer *_smixer; SmushMixer *_smixer;
SmushPlayer *_splayer;
public: public:
ScummEngine_v6(OSystem *syst, const DetectorResult &dr); ScummEngine_v6(OSystem *syst, const DetectorResult &dr);

View file

@ -2526,15 +2526,12 @@ void ScummEngine_v6::o6_kernelSetFunctions() {
if (strcmp((char *)getStringAddressVar(VAR_VIDEONAME), "sq3.san") == 0) if (strcmp((char *)getStringAddressVar(VAR_VIDEONAME), "sq3.san") == 0)
_smushFrameRate = 14; _smushFrameRate = 14;
SmushPlayer *sp = new SmushPlayer((ScummEngine_v7 *)this, _smushFrameRate);
// Correct incorrect smush filename in Macintosh FT demo // Correct incorrect smush filename in Macintosh FT demo
if ((_game.id == GID_FT) && (_game.features & GF_DEMO) && (_game.platform == Common::kPlatformMacintosh) && if ((_game.id == GID_FT) && (_game.features & GF_DEMO) && (_game.platform == Common::kPlatformMacintosh) &&
(strcmp((char *)getStringAddressVar(VAR_VIDEONAME), "jumpgorge.san") == 0)) (strcmp((char *)getStringAddressVar(VAR_VIDEONAME), "jumpgorge.san") == 0))
sp->play("jumpgorg.san"); _splayer->play("jumpgorg.san", _smushFrameRate);
else else
sp->play((char *)getStringAddressVar(VAR_VIDEONAME)); _splayer->play((char *)getStringAddressVar(VAR_VIDEONAME), _smushFrameRate);
delete sp;
if (_game.id == GID_DIG) { if (_game.id == GID_DIG) {
_disableFadeInEffect = true; _disableFadeInEffect = true;

View file

@ -1176,9 +1176,7 @@ void ScummEngine_v8::o8_systemOps() {
void ScummEngine_v8::o8_startVideo() { void ScummEngine_v8::o8_startVideo() {
int len = resStrLen(_scriptPointer); int len = resStrLen(_scriptPointer);
SmushPlayer *sp = new SmushPlayer(this, 12); _splayer->play((const char*)_scriptPointer, 12);
sp->play((const char*)_scriptPointer);
delete sp;
_scriptPointer += len + 1; _scriptPointer += len + 1;
} }

View file

@ -42,6 +42,7 @@
#include "scumm/imuse/imuse.h" #include "scumm/imuse/imuse.h"
#include "scumm/imuse_digi/dimuse.h" #include "scumm/imuse_digi/dimuse.h"
#include "scumm/smush/smush_mixer.h" #include "scumm/smush/smush_mixer.h"
#include "scumm/smush/smush_player.h"
#include "scumm/insane/insane.h" #include "scumm/insane/insane.h"
#include "scumm/intern.h" #include "scumm/intern.h"
#include "scumm/he/animation_he.h" #include "scumm/he/animation_he.h"
@ -779,6 +780,7 @@ ScummEngine_v7::ScummEngine_v7(OSystem *syst, const DetectorResult &dr)
_smushActive = false; _smushActive = false;
_insaneRunning = false; _insaneRunning = false;
_smixer = NULL; _smixer = NULL;
_splayer = NULL;
_existLanguageFile = false; _existLanguageFile = false;
_languageBuffer = NULL; _languageBuffer = NULL;
@ -791,6 +793,10 @@ ScummEngine_v7::~ScummEngine_v7() {
_smixer->stop(); _smixer->stop();
delete _smixer; delete _smixer;
} }
if (_splayer) {
_splayer->release();
delete _splayer;
}
free(_languageBuffer); free(_languageBuffer);
free(_languageIndex); free(_languageIndex);
@ -1107,6 +1113,8 @@ void ScummEngine_v7::setupScumm() {
_insane = 0; _insane = 0;
_smixer = new SmushMixer(_mixer); _smixer = new SmushMixer(_mixer);
_splayer = new SmushPlayer(this);
} }
#endif #endif

View file

@ -235,11 +235,11 @@ void SmushPlayer::timerCallback(void *refCon) {
#endif #endif
} }
SmushPlayer::SmushPlayer(ScummEngine_v7 *scumm, int speed) { SmushPlayer::SmushPlayer(ScummEngine_v7 *scumm) {
_vm = scumm; _vm = scumm;
_version = -1; _version = -1;
_nbframes = 0; _nbframes = 0;
_smixer = 0; _smixer = NULL;
_strings = NULL; _strings = NULL;
_sf[0] = NULL; _sf[0] = NULL;
_sf[1] = NULL; _sf[1] = NULL;
@ -261,7 +261,7 @@ SmushPlayer::SmushPlayer(ScummEngine_v7 *scumm, int speed) {
_IACTpos = 0; _IACTpos = 0;
_soundFrequency = 22050; _soundFrequency = 22050;
_initDone = false; _initDone = false;
_speed = speed; _speed = -1;
_insanity = false; _insanity = false;
_middleAudio = false; _middleAudio = false;
_skipPalette = false; _skipPalette = false;
@ -278,12 +278,13 @@ SmushPlayer::SmushPlayer(ScummEngine_v7 *scumm, int speed) {
} }
SmushPlayer::~SmushPlayer() { SmushPlayer::~SmushPlayer() {
release();
} }
void SmushPlayer::init() { void SmushPlayer::init(int32 speed) {
_frame = 0; _frame = 0;
_speed = speed;
_alreadyInit = false; _alreadyInit = false;
_endOfFile = false;
_vm->_smushVideoShouldFinish = false; _vm->_smushVideoShouldFinish = false;
_vm->_smushActive = true; _vm->_smushActive = true;
@ -302,6 +303,8 @@ void SmushPlayer::init() {
_vm->virtscr[0].pitch = _vm->virtscr[0].w; _vm->virtscr[0].pitch = _vm->virtscr[0].w;
_vm->_gdi->_numStrips = _vm->virtscr[0].w / 8; _vm->_gdi->_numStrips = _vm->virtscr[0].w / 8;
_vm->_mixer->stopHandle(_compressedFileSoundHandle);
_vm->_mixer->stopHandle(_IACTchannel);
_vm->_smixer->stop(); _vm->_smixer->stop();
Common::g_timer->installTimerProc(&timerCallback, 1000000 / _speed, this); Common::g_timer->installTimerProc(&timerCallback, 1000000 / _speed, this);
@ -340,9 +343,6 @@ void SmushPlayer::release() {
free(_frameBuffer); free(_frameBuffer);
_frameBuffer = NULL; _frameBuffer = NULL;
_vm->_mixer->stopHandle(_compressedFileSoundHandle);
_vm->_mixer->stopHandle(_IACTchannel);
_IACTstream = NULL; _IACTstream = NULL;
_vm->_smushActive = false; _vm->_smushActive = false;
@ -1115,6 +1115,7 @@ void SmushPlayer::parseNextFrame() {
assert(_base); assert(_base);
if (_base->eof()) { if (_base->eof()) {
_vm->_smushVideoShouldFinish = true; _vm->_smushVideoShouldFinish = true;
_endOfFile = true;
return; return;
} }
@ -1273,7 +1274,7 @@ void SmushPlayer::tryCmpFile(const char *filename) {
#endif #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 // Verify the specified file exists
ScummFile f; ScummFile f;
@ -1299,7 +1300,7 @@ void SmushPlayer::play(const char *filename, int32 offset, int32 startFrame) {
_base = 0; _base = 0;
setupAnim(filename); setupAnim(filename);
init(); init(speed);
for (;;) { for (;;) {
if (_warpNeeded) { if (_warpNeeded) {
@ -1345,12 +1346,14 @@ void SmushPlayer::play(const char *filename, int32 offset, int32 startFrame) {
_inTimerCount = 0; _inTimerCount = 0;
#endif #endif
} }
if (_vm->_quit || _vm->_saveLoadFlag) { if (_endOfFile)
break;
if (_vm->_quit || _vm->_saveLoadFlag || _vm->_smushVideoShouldFinish) {
_smixer->stop(); _smixer->stop();
_vm->_mixer->stopHandle(_compressedFileSoundHandle);
_vm->_mixer->stopHandle(_IACTchannel);
break; break;
} }
if (_vm->_smushVideoShouldFinish || _vm->_quit || _vm->_saveLoadFlag)
break;
_vm->_system->delayMillis(10); _vm->_system->delayMillis(10);
} }

View file

@ -73,6 +73,7 @@ private:
bool _initDone; bool _initDone;
int _speed; int _speed;
bool _outputSound; bool _outputSound;
bool _endOfFile;
byte *_dst; byte *_dst;
bool _updateNeeded; bool _updateNeeded;
@ -94,10 +95,11 @@ private:
Common::Mutex _mutex; Common::Mutex _mutex;
public: public:
SmushPlayer(ScummEngine_v7 *scumm, int speed); SmushPlayer(ScummEngine_v7 *scumm);
~SmushPlayer(); ~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); void warpMouse(int x, int y, int buttons);
protected: protected:
@ -115,8 +117,7 @@ protected:
private: private:
void parseNextFrame(); void parseNextFrame();
void init(); void init(int32 spped);
void release();
void setupAnim(const char *file); void setupAnim(const char *file);
void updateScreen(); void updateScreen();
void tryCmpFile(const char *filename); void tryCmpFile(const char *filename);