aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/videoplayer.cpp
diff options
context:
space:
mode:
authorSven Hesse2011-01-19 18:57:43 +0000
committerSven Hesse2011-01-19 18:57:43 +0000
commitbad7f1ce9a67e71eaaa390ac56ae5a3720c3fb7a (patch)
tree49de1da704aa8cfc8f65f4e551e7b7ec66e44b33 /engines/gob/videoplayer.cpp
parent878bedf454a8440b3d3c8887bc021a698dbb5605 (diff)
downloadscummvm-rg350-bad7f1ce9a67e71eaaa390ac56ae5a3720c3fb7a.tar.gz
scummvm-rg350-bad7f1ce9a67e71eaaa390ac56ae5a3720c3fb7a.tar.bz2
scummvm-rg350-bad7f1ce9a67e71eaaa390ac56ae5a3720c3fb7a.zip
GOB: Implement "live" (non-blocking) videos
Many thanks to SylvainTV. :) Urban Runner might actually be completeable now. One caveat: Hotspots at that hotel sequence are a bit glitchy... svn-id: r55333
Diffstat (limited to 'engines/gob/videoplayer.cpp')
-rw-r--r--engines/gob/videoplayer.cpp42
1 files changed, 40 insertions, 2 deletions
diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp
index 1c5f1c1a72..c22a67ac16 100644
--- a/engines/gob/videoplayer.cpp
+++ b/engines/gob/videoplayer.cpp
@@ -45,7 +45,7 @@ VideoPlayer::Properties::Properties() : type(kVideoTypeTry), sprite(Draw::kFront
}
-VideoPlayer::Video::Video() : decoder(0) {
+VideoPlayer::Video::Video() : decoder(0), live(false) {
}
bool VideoPlayer::Video::isEmpty() const {
@@ -58,6 +58,8 @@ void VideoPlayer::Video::close() {
decoder = 0;
fileName.clear();
surface.reset();
+
+ live = false;
}
@@ -240,6 +242,13 @@ bool VideoPlayer::play(int slot, Properties &properties) {
properties.canceled = false;
+ if (primary && (properties.flags & kFlagNonBlocking)) {
+ video->live = true;
+ properties.waitEndFrame = false;
+ _liveProperties = properties;
+ return true;
+ }
+
while ((properties.startFrame != properties.lastFrame) &&
(properties.startFrame < (int32)(video->decoder->getFrameCount() - 1))) {
@@ -274,6 +283,35 @@ void VideoPlayer::waitEndFrame(int slot, bool onlySound) {
_vm->_util->delay(video->decoder->getTimeToNextFrame());
}
+void VideoPlayer::updateLive() {
+ Video *video = getVideoBySlot(0);
+ if (!video || !video->live)
+ return;
+
+ if ((_liveProperties.startFrame == _liveProperties.lastFrame) ||
+ (_liveProperties.startFrame >= (int32)(video->decoder->getFrameCount() - 1))) {
+
+ WRITE_VAR_OFFSET(212, (uint32)-1);
+ _vm->_vidPlayer->closeVideo();
+ return;
+ }
+
+ if (video->decoder->getTimeToNextFrame() > 0)
+ return;
+
+ WRITE_VAR_OFFSET(212, _liveProperties.startFrame + 1);
+
+ bool backwards = _liveProperties.startFrame > _liveProperties.lastFrame;
+ playFrame(0, _liveProperties);
+
+ _liveProperties.startFrame += backwards ? -1 : 1;
+
+ if (_liveProperties.fade) {
+ _vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0);
+ _liveProperties.fade = false;
+ }
+}
+
bool VideoPlayer::playFrame(int slot, Properties &properties) {
Video *video = getVideoBySlot(slot);
if (!video)
@@ -387,7 +425,7 @@ bool VideoPlayer::playFrame(int slot, Properties &properties) {
}
- if ((video->decoder->getCurFrame() - 1) == properties.startFrame)
+ if (!video->live && ((video->decoder->getCurFrame() - 1) == properties.startFrame))
// Only retrace if we're playing the frame we actually want to play
_vm->_video->retrace();