aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sword1/animation.cpp15
-rw-r--r--engines/sword1/animation.h3
-rw-r--r--engines/sword2/animation.cpp13
-rw-r--r--engines/sword2/animation.h3
-rw-r--r--graphics/animation.cpp60
-rw-r--r--graphics/animation.h19
6 files changed, 23 insertions, 90 deletions
diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp
index 9c02c431c3..f33277f21e 100644
--- a/engines/sword1/animation.cpp
+++ b/engines/sword1/animation.cpp
@@ -186,6 +186,7 @@ void MoviePlayer::play(void) {
_scr->clearScreen();
_framesSkipped = 0;
_ticks = _sys->getMillis();
+ _bgSoundStream = Audio::AudioStream::openStreamFile(sequenceList[_id]);
if (_bgSoundStream) {
_snd->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSoundHandle, _bgSoundStream);
}
@@ -318,9 +319,6 @@ bool MoviePlayerDXA::load(uint32 id) {
_frameHeight = getHeight();
_frameX = (640 - _frameWidth) / 2;
_frameY = (480 - _frameHeight) / 2;
- if (!_bgSoundStream) {
- _bgSoundStream = Audio::AudioStream::openStreamFile(sequenceList[id]);
- }
return true;
}
return false;
@@ -395,8 +393,8 @@ void MoviePlayerMPEG::insertOverlay(OverlayColor *buf, uint8 *ovl, OverlayColor
bool MoviePlayerMPEG::load(uint32 id) {
if (MoviePlayer::load(id)) {
- _anim = new AnimationState(this, _scr, _snd, _sys);
- return _anim->init(sequenceList[id], _bgSoundStream);
+ _anim = new AnimationState(this, _scr, _sys);
+ return _anim->init(sequenceList[id]);
}
return false;
}
@@ -450,11 +448,8 @@ void MoviePlayerMPEG::processFrame(void) {
#endif
}
-void MoviePlayerMPEG::syncFrame(void) {
-}
-
-AnimationState::AnimationState(MoviePlayer *player, Screen *scr, Audio::Mixer *snd, OSystem *sys)
- : BaseAnimationState(snd, sys, 640, 400), _player(player), _scr(scr) {
+AnimationState::AnimationState(MoviePlayer *player, Screen *scr, OSystem *sys)
+ : BaseAnimationState(sys, 640, 400), _player(player), _scr(scr) {
}
AnimationState::~AnimationState(void) {
diff --git a/engines/sword1/animation.h b/engines/sword1/animation.h
index 1b484e9583..07aa5241f0 100644
--- a/engines/sword1/animation.h
+++ b/engines/sword1/animation.h
@@ -120,7 +120,7 @@ private:
Screen *_scr;
public:
- AnimationState(MoviePlayer *player, Screen *scr, Audio::Mixer *snd, OSystem *sys);
+ AnimationState(MoviePlayer *player, Screen *scr, OSystem *sys);
~AnimationState(void);
OverlayColor *giveRgbBuffer(void);
@@ -149,7 +149,6 @@ protected:
bool initOverlays(uint32 id);
bool decodeFrame(void);
void processFrame(void);
- void syncFrame(void);
void updateScreen(void);
void handleScreenChanged(void);
};
diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp
index 9f134621ec..bf60623f92 100644
--- a/engines/sword2/animation.cpp
+++ b/engines/sword2/animation.cpp
@@ -75,6 +75,7 @@ MoviePlayer::MoviePlayer(Sword2Engine *vm) {
_vm = vm;
_mixer = _vm->_mixer;
_system = _vm->_system;
+ _name = NULL;
_textSurface = NULL;
_bgSoundStream = NULL;
_ticks = 0;
@@ -96,6 +97,7 @@ MoviePlayer::MoviePlayer(Sword2Engine *vm) {
}
MoviePlayer::~MoviePlayer() {
+ free(_name);
}
void MoviePlayer::updatePalette(byte *pal, bool packed) {
@@ -278,6 +280,8 @@ bool MoviePlayer::load(const char *name, MovieTextObject *text[]) {
_currentText = 0;
_currentFrame = 0;
+ _name = strdup(name);
+
for (int i = 0; i < ARRAYSIZE(_movies); i++) {
if (scumm_stricmp(name, _movies[i].name) == 0) {
_seamless = _movies[i].seamless;
@@ -335,8 +339,8 @@ void MoviePlayer::play(int32 leadIn, int32 leadOut) {
#endif
_framesSkipped = 0;
-
_ticks = _system->getMillis();
+ _bgSoundStream = Audio::AudioStream::openStreamFile(_name);
if (_bgSoundStream) {
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSoundHandle, _bgSoundStream);
@@ -504,8 +508,6 @@ bool MoviePlayerDXA::load(const char *name, MovieTextObject *text[]) {
_frameX = (_vm->_screen->getScreenWide() - _frameWidth) / 2;
_frameY = (_vm->_screen->getScreenDeep() - _frameHeight) / 2;
- _bgSoundStream = Audio::AudioStream::openStreamFile(name);
-
return true;
}
@@ -566,11 +568,8 @@ bool MoviePlayerMPEG::decodeFrame() {
return result;
}
-void MoviePlayerMPEG::syncFrame() {
-}
-
AnimationState::AnimationState(Sword2Engine *vm, MoviePlayer *player)
- : BaseAnimationState(vm->_mixer, vm->_system, 640, 480) {
+ : BaseAnimationState(vm->_system, 640, 480) {
_vm = vm;
_player = player;
}
diff --git a/engines/sword2/animation.h b/engines/sword2/animation.h
index 337ee2b630..99c4231585 100644
--- a/engines/sword2/animation.h
+++ b/engines/sword2/animation.h
@@ -57,6 +57,8 @@ protected:
Audio::Mixer *_mixer;
OSystem *_system;
+ char *_name;
+
byte _originalPalette[4 * 256];
byte *_textSurface;
@@ -156,7 +158,6 @@ protected:
AnimationState *_anim;
virtual bool decodeFrame();
- virtual void syncFrame();
#ifndef BACKEND_8BIT
void handleScreenChanged();
diff --git a/graphics/animation.cpp b/graphics/animation.cpp
index a49d33e4a0..7951e7f2d6 100644
--- a/graphics/animation.cpp
+++ b/graphics/animation.cpp
@@ -22,7 +22,6 @@
#include "common/stdafx.h"
#include "graphics/animation.h"
-#include "sound/audiostream.h"
#include "common/config-manager.h"
#include "common/file.h"
#include "common/system.h"
@@ -31,8 +30,8 @@
namespace Graphics {
-BaseAnimationState::BaseAnimationState(Audio::Mixer *snd, OSystem *sys, int width, int height)
- : _movieWidth(width), _movieHeight(height), _frameWidth(width), _frameHeight(height), _snd(snd), _sys(sys) {
+BaseAnimationState::BaseAnimationState(OSystem *sys, int width, int height)
+ : _movieWidth(width), _movieHeight(height), _frameWidth(width), _frameHeight(height), _sys(sys) {
#ifndef BACKEND_8BIT
const int screenW = _sys->getOverlayWidth();
const int screenH = _sys->getOverlayHeight();
@@ -51,7 +50,6 @@ BaseAnimationState::BaseAnimationState(Audio::Mixer *snd, OSystem *sys, int widt
BaseAnimationState::~BaseAnimationState() {
#ifdef USE_MPEG2
- _snd->stopHandle(_bgSound);
if (_mpegDecoder)
mpeg2_close(_mpegDecoder);
delete _mpegFile;
@@ -61,18 +59,16 @@ BaseAnimationState::~BaseAnimationState() {
free(_colorTab);
free(_rgbToPix);
#endif
- delete _bgSoundStream;
#endif
}
-bool BaseAnimationState::init(const char *name, void *audioArg) {
+bool BaseAnimationState::init(const char *name) {
#ifdef USE_MPEG2
char tempFile[512];
_mpegDecoder = NULL;
_mpegFile = NULL;
- _bgSoundStream = NULL;
#ifdef BACKEND_8BIT
@@ -146,17 +142,6 @@ bool BaseAnimationState::init(const char *name, void *audioArg) {
_mpegInfo = mpeg2_info(_mpegDecoder);
_frameNum = 0;
- _frameSkipped = 0;
- _ticks = _sys->getMillis();
-
- // Play audio
- _bgSoundStream = createAudioStream(name, audioArg);
-
- if (_bgSoundStream != NULL) {
- _snd->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSound, _bgSoundStream, -1, 255, 0, false);
- } else {
- warning("Cutscene: Could not open Audio Track for %s", name);
- }
return true;
#else /* USE_MPEG2 */
@@ -164,10 +149,6 @@ bool BaseAnimationState::init(const char *name, void *audioArg) {
#endif
}
-Audio::AudioStream *BaseAnimationState::createAudioStream(const char *name, void *arg) {
- return Audio::AudioStream::openStreamFile(name);
-}
-
bool BaseAnimationState::decodeFrame() {
#ifdef USE_MPEG2
mpeg2_state_t state;
@@ -188,39 +169,8 @@ bool BaseAnimationState::decodeFrame() {
case STATE_SLICE:
case STATE_END:
if (_mpegInfo->display_fbuf) {
- /* simple audio video sync code:
- * we calculate the actual frame by taking the elapsed audio time and try
- * to stay inside +- 1 frame of this calculated frame number by dropping
- * frames if we run behind and delaying if we are too fast
- */
-
- if (checkPaletteSwitch() || (_bgSoundStream == NULL) ||
- ((_snd->getSoundElapsedTime(_bgSound) * 12) / 1000 < _frameNum + 1) ||
- _frameSkipped > 10) {
- if (_frameSkipped > 10) {
- warning("force frame %i redraw", _frameNum);
- _frameSkipped = 0;
- }
- drawYUV(sequence_i->width, sequence_i->height, _mpegInfo->display_fbuf->buf);
-
- if (_bgSoundStream && _snd->isSoundHandleActive(_bgSound)) {
- while (_snd->isSoundHandleActive(_bgSound) && (_snd->getSoundElapsedTime(_bgSound) * 12) / 1000 < _frameNum) {
- _sys->delayMillis(10);
- }
- // In case the background sound ends prematurely, update
- // _ticks so that we can still fall back on the no-sound
- // sync case for the subsequent frames.
- _ticks = _sys->getMillis();
- } else {
- _ticks += 83;
- while (_sys->getMillis() < _ticks)
- _sys->delayMillis(10);
- }
- } else {
- warning("dropped frame %i", _frameNum);
- _frameSkipped++;
- }
-
+ checkPaletteSwitch();
+ drawYUV(sequence_i->width, sequence_i->height, _mpegInfo->display_fbuf->buf);
#ifdef BACKEND_8BIT
buildLookup(_palNum + 1, _lutCalcNum);
#endif
diff --git a/graphics/animation.h b/graphics/animation.h
index 1881f0149c..aff644d2d3 100644
--- a/graphics/animation.h
+++ b/graphics/animation.h
@@ -25,12 +25,6 @@
#include "common/scummsys.h"
-#include "sound/mixer.h"
-
-namespace Audio {
- class AudioStream;
-}
-
// Uncomment this if you are using libmpeg2 0.3.1.
// #define USE_MPEG2_0_3_1
@@ -72,6 +66,8 @@ namespace Common {
class File;
}
+class OSystem;
+
namespace Graphics {
class BaseAnimationState {
@@ -86,12 +82,9 @@ protected:
int _movieScale;
#endif
- Audio::Mixer *_snd;
OSystem *_sys;
uint _frameNum;
- uint _frameSkipped;
- uint32 _ticks;
#ifdef USE_MPEG2
mpeg2dec_t *_mpegDecoder;
@@ -100,9 +93,6 @@ protected:
Common::File *_mpegFile;
- Audio::SoundHandle _bgSound;
- Audio::AudioStream *_bgSoundStream;
-
#ifdef BACKEND_8BIT
int _palNum;
int _maxPalNum;
@@ -129,10 +119,10 @@ protected:
#endif
public:
- BaseAnimationState(Audio::Mixer *snd, OSystem *sys, int width, int height);
+ BaseAnimationState(OSystem *sys, int width, int height);
virtual ~BaseAnimationState();
- bool init(const char *name, void *audioArg = NULL);
+ bool init(const char *name);
bool decodeFrame();
void handleScreenChanged();
void updateScreen();
@@ -147,7 +137,6 @@ public:
protected:
bool checkPaletteSwitch();
virtual void drawYUV(int width, int height, byte *const *dat) = 0;
- virtual Audio::AudioStream *createAudioStream(const char *name, void *arg);
#ifdef BACKEND_8BIT
void buildLookup(int p, int lines);