aboutsummaryrefslogtreecommitdiff
path: root/sword2/driver
diff options
context:
space:
mode:
authorTorbjörn Andersson2004-02-12 16:55:18 +0000
committerTorbjörn Andersson2004-02-12 16:55:18 +0000
commit5447cd09b589990d7ffaf4df23725614420e48d4 (patch)
treed9ffd6ebaa78a62f3c4a3ad82553b470eddf91b4 /sword2/driver
parent9003dbbcb325cdf30b15822bc9bbf29c04884579 (diff)
downloadscummvm-rg350-5447cd09b589990d7ffaf4df23725614420e48d4.tar.gz
scummvm-rg350-5447cd09b589990d7ffaf4df23725614420e48d4.tar.bz2
scummvm-rg350-5447cd09b589990d7ffaf4df23725614420e48d4.zip
Changed the playback code to use the new "elapsed time" function instead.
This fixes bug #880484 for me, but may need some fine-tuning. svn-id: r12830
Diffstat (limited to 'sword2/driver')
-rw-r--r--sword2/driver/animation.cpp19
-rw-r--r--sword2/driver/animation.h6
2 files changed, 11 insertions, 14 deletions
diff --git a/sword2/driver/animation.cpp b/sword2/driver/animation.cpp
index 3517d87fc6..f6f74cd3d7 100644
--- a/sword2/driver/animation.cpp
+++ b/sword2/driver/animation.cpp
@@ -65,7 +65,7 @@ bool AnimationState::init(const char *name) {
#ifdef BACKEND_8BIT
- int i, p;
+ uint i, p;
// Load lookup palettes
// TODO: Binary format so we can use File class
@@ -336,22 +336,19 @@ bool AnimationState::decodeFrame() {
case STATE_END:
if (info->display_fbuf) {
/* simple audio video sync code:
- * we calculate the actual frame by taking the delivered audio samples
- * we add 2 frames as the number of samples delivered is higher than the
- * number actually played due to buffering
- *
- * we then 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
+ * 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
*/
#ifdef BACKEND_8BIT
if (checkPaletteSwitch() || (bgSoundStream == NULL) ||
- (bgSoundStream->getSamplesPlayed() * 12 / bgSoundStream->getRate()) < (framenum + 3)){
+ ((_vm->_mixer->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum + 1)) {
_vm->_graphics->plotYUV(lut, sequence_i->width, sequence_i->height, info->display_fbuf->buf);
if (bgSoundStream) {
- while ((bgSoundStream->getSamplesPlayed() * 12 / bgSoundStream->getRate()) < framenum + 1)
+ while ((_vm->_mixer->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum)
_vm->_system->delay_msecs(10);
} else {
ticks += 83;
@@ -368,12 +365,12 @@ bool AnimationState::decodeFrame() {
#else
if ((bgSoundStream == NULL) ||
- (bgSoundStream->getSamplesPlayed() * 12 / bgSoundStream->getRate()) < (framenum+3)){
+ ((_vm->_mixer->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum + 1)) {
plotYUV(lookup, sequence_i->width, sequence_i->height, info->display_fbuf->buf);
if (bgSoundStream) {
- while ((bgSoundStream->getSamplesPlayed() * 12 / bgSoundStream->getRate()) < framenum + 1)
+ while ((_vm->_mixer->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum)
_vm->_system->delay_msecs(10);
} else {
ticks += 83;
diff --git a/sword2/driver/animation.h b/sword2/driver/animation.h
index a7371fcd69..b1e17a104a 100644
--- a/sword2/driver/animation.h
+++ b/sword2/driver/animation.h
@@ -71,7 +71,7 @@ class AnimationState {
private:
Sword2Engine *_vm;
- int framenum;
+ uint framenum;
int ticks;
#ifdef USE_MPEG2
@@ -101,8 +101,8 @@ private:
int pos;
struct {
- int cnt;
- int end;
+ uint cnt;
+ uint end;
byte pal[4 * 256];
} palettes[50];
#else