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);
}
_player->play(filename, offset, startFrame);
_player->play(filename, _speed, offset, startFrame);
}
void Insane::smush_warpMouse(int x, int y, int buttons) {

View file

@ -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) {

View file

@ -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);

View file

@ -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;

View file

@ -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;
}

View file

@ -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

View file

@ -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);
}

View file

@ -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);