diff options
author | Torbjörn Andersson | 2004-02-12 17:16:38 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2004-02-12 17:16:38 +0000 |
commit | 447e8d93869a614dd521644a2df62bf96859007e (patch) | |
tree | 21fdd92c9004d23610eb6616bf97b229982405b0 /sword1 | |
parent | 5447cd09b589990d7ffaf4df23725614420e48d4 (diff) | |
download | scummvm-rg350-447e8d93869a614dd521644a2df62bf96859007e.tar.gz scummvm-rg350-447e8d93869a614dd521644a2df62bf96859007e.tar.bz2 scummvm-rg350-447e8d93869a614dd521644a2df62bf96859007e.zip |
Updated the cutscene playback code to use the new "elapsed time" mixer
function.
svn-id: r12831
Diffstat (limited to 'sword1')
-rw-r--r-- | sword1/animation.cpp | 27 | ||||
-rw-r--r-- | sword1/animation.h | 6 |
2 files changed, 11 insertions, 22 deletions
diff --git a/sword1/animation.cpp b/sword1/animation.cpp index 7a132e7703..0a07acd627 100644 --- a/sword1/animation.cpp +++ b/sword1/animation.cpp @@ -59,7 +59,7 @@ bool AnimationState::init(const char *basename) { #ifdef BACKEND_8BIT - int i, p; + uint i, p; // Load lookup palettes // TODO: Binary format so we can use File class @@ -301,29 +301,18 @@ 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 - */ - - /* FIXME: We shouldn't use delay_msecs() here. - * We should use something like the delay() - * function in SwordEngine, so that events are - * handled properly. For now, at least call the - * backend's event handler so that redraw - * events are processed. + * 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)){ + ((_snd->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum + 1)) { _scr->plotYUV(lut, sequence_i->width, sequence_i->height, info->display_fbuf->buf); if (bgSoundStream) { - while ((bgSoundStream->getSamplesPlayed()*12/bgSoundStream->getRate()) < framenum+1) + while ((_snd->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum) _sys->delay_msecs(10); } else { ticks += 83; @@ -338,11 +327,11 @@ bool AnimationState::decodeFrame() { #else - if ((bgSoundStream == NULL) || (bgSoundStream->getSamplesPlayed()*12/bgSoundStream->getRate()) < (framenum+3)){ + if ((bgSoundStream == NULL) || ((_snd->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 ((_snd->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum) _sys->delay_msecs(10); } else { ticks += 83; diff --git a/sword1/animation.h b/sword1/animation.h index cee94f341f..fdb78cd99a 100644 --- a/sword1/animation.h +++ b/sword1/animation.h @@ -76,7 +76,7 @@ private: SoundMixer *_snd; OSystem *_sys; - int framenum; + uint framenum; uint32 ticks; #ifdef USE_MPEG2 @@ -106,8 +106,8 @@ private: int pos; struct { - int cnt; - int end; + uint cnt; + uint end; byte pal[4 * 256]; } palettes[50]; #else |