aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorTorbjörn Andersson2006-08-26 12:29:00 +0000
committerTorbjörn Andersson2006-08-26 12:29:00 +0000
commitcc3b4cdf9937f3d89bb058f9af652c1b371f7222 (patch)
tree7886990150583d75f427e6e44c16024ec16152c2 /graphics
parent96ec0d08ac6498f8d05996e048ae587b4bcb0c50 (diff)
downloadscummvm-rg350-cc3b4cdf9937f3d89bb058f9af652c1b371f7222.tar.gz
scummvm-rg350-cc3b4cdf9937f3d89bb058f9af652c1b371f7222.tar.bz2
scummvm-rg350-cc3b4cdf9937f3d89bb058f9af652c1b371f7222.zip
Now that the cutscene handling in both BS1 and BS2 has been extended to play
DXA movies (the MPEG movies still work, of course), there is no longer any need for the MPEG decoder to handle sound and frame syncing. That is now the responsibility of the player, not the decoder. The obvious next step, then, would be to put that in a new player class, and have both BS1 and BS2 use that. Maybe FF as well. svn-id: r23757
Diffstat (limited to 'graphics')
-rw-r--r--graphics/animation.cpp60
-rw-r--r--graphics/animation.h19
2 files changed, 9 insertions, 70 deletions
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);