diff options
author | Sven Hesse | 2010-08-08 01:02:49 +0000 |
---|---|---|
committer | Sven Hesse | 2010-08-08 01:02:49 +0000 |
commit | 5dc322454de75e25d5db8b8f284131a166d558e7 (patch) | |
tree | 31ff84698185553714842344e5e5c35b38271946 /engines | |
parent | 945103a43c9a15a4a9a07765197b0551593b4236 (diff) | |
download | scummvm-rg350-5dc322454de75e25d5db8b8f284131a166d558e7.tar.gz scummvm-rg350-5dc322454de75e25d5db8b8f284131a166d558e7.tar.bz2 scummvm-rg350-5dc322454de75e25d5db8b8f284131a166d558e7.zip |
GOB: Fix playing of sound VMDs with a starting frame != 0
svn-id: r51910
Diffstat (limited to 'engines')
-rw-r--r-- | engines/gob/inter_v6.cpp | 1 | ||||
-rw-r--r-- | engines/gob/videoplayer.cpp | 50 | ||||
-rw-r--r-- | engines/gob/videoplayer.h | 2 |
3 files changed, 43 insertions, 10 deletions
diff --git a/engines/gob/inter_v6.cpp b/engines/gob/inter_v6.cpp index d9bb6dd573..73ef46bf31 100644 --- a/engines/gob/inter_v6.cpp +++ b/engines/gob/inter_v6.cpp @@ -118,6 +118,7 @@ void Inter_v6::o6_playVmdOrMusic() { props.palStart = _vm->_game->_script->readValExpr(); props.palEnd = _vm->_game->_script->readValExpr(); props.palCmd = 1 << (props.flags & 0x3F); + props.forceSeek = true; debugC(1, kDebugVideo, "Playing video \"%s\" @ %d+%d, frames %d - %d, " "paletteCmd %d (%d - %d), flags %X", fileName, diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp index 83a70a648b..970d8dc9dd 100644 --- a/engines/gob/videoplayer.cpp +++ b/engines/gob/videoplayer.cpp @@ -39,8 +39,8 @@ namespace Gob { VideoPlayer::Properties::Properties() : type(kVideoTypeTry), sprite(Draw::kFrontSurface), x(-1), y(-1), width(-1), height(-1), flags(kFlagFrontSurface), - startFrame(-1), lastFrame(-1), endFrame(-1), breakKey(kShortKeyEscape), - palCmd(8), palStart(0), palEnd(255), palFrame(-1), + startFrame(-1), lastFrame(-1), endFrame(-1), forceSeek(false), + breakKey(kShortKeyEscape), palCmd(8), palStart(0), palEnd(255), palFrame(-1), fade(false), waitEndFrame(true), canceled(false) { } @@ -270,11 +270,38 @@ bool VideoPlayer::playFrame(int slot, Properties &properties) { bool primary = slot == 0; if (video->decoder->getCurFrame() != properties.startFrame) { - video->decoder->disableSound(); - video->decoder->seek(properties.startFrame + 1, SEEK_SET, true); - video->decoder->enableSound(); + + if (properties.startFrame != -1) { + // Seek into the middle of the video + + if (video->decoder->hasSound()) { + // But there's sound + + if (properties.forceSeek) { + // And we force seeking => Seek + + video->decoder->disableSound(); + video->decoder->seek(properties.startFrame + 1, SEEK_SET, true); + } + + } else + // No sound => We can safely seek + video->decoder->seek(properties.startFrame + 1, SEEK_SET, true); + + } else { + // Seek to the start => We can safely seek + + video->decoder->disableSound(); + video->decoder->seek(0, SEEK_SET, true); + video->decoder->enableSound(); + } + } + if (video->decoder->getCurFrame() > properties.startFrame) + // If the video is already beyond the wanted frame, skip + return true; + bool modifiedPal = false; if (primary) { @@ -297,10 +324,7 @@ bool VideoPlayer::playFrame(int slot, Properties &properties) { _vm->_draw->forceBlit(); } - Graphics::Surface *surface = video->decoder->decodeNextFrame(); - if (!surface) - return false; WRITE_VAR(11, video->decoder->getCurFrame()); @@ -310,7 +334,7 @@ bool VideoPlayer::playFrame(int slot, Properties &properties) { // state.left += 50; } - if (primary) { + if (surface && primary) { // Post-decoding palette and blitting, only for primary videos if (_needBlit) @@ -350,7 +374,9 @@ bool VideoPlayer::playFrame(int slot, Properties &properties) { } - _vm->_video->retrace(); + if ((video->decoder->getCurFrame() - 1) == properties.startFrame) + // Only retrace if we're playing the frame we actually want to play + _vm->_video->retrace(); /* // Subtitle @@ -365,6 +391,10 @@ bool VideoPlayer::playFrame(int slot, Properties &properties) { if (primary && properties.waitEndFrame) checkAbort(*video, properties); + if ((video->decoder->getCurFrame() - 1) < properties.startFrame) + // The video played a frame we actually didn't want, so we have to adjust + properties.startFrame--; + return true; } diff --git a/engines/gob/videoplayer.h b/engines/gob/videoplayer.h index e40142d26d..7cb9c013b6 100644 --- a/engines/gob/videoplayer.h +++ b/engines/gob/videoplayer.h @@ -78,6 +78,8 @@ public: int32 lastFrame; ///< Frame to stop playback at. int32 endFrame; ///< Last frame of this playback cycle. + bool forceSeek; ///< Force the seeking to the start frame. + int16 breakKey; ///< Keycode of the break/abort key. uint16 palCmd; ///< Palette command. |