[Scummvm-cvs-logs] SF.net SVN: scummvm:[51910] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Sun Aug 8 03:02:49 CEST 2010


Revision: 51910
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51910&view=rev
Author:   drmccoy
Date:     2010-08-08 01:02:49 +0000 (Sun, 08 Aug 2010)

Log Message:
-----------
GOB: Fix playing of sound VMDs with a starting frame != 0

Modified Paths:
--------------
    scummvm/trunk/engines/gob/inter_v6.cpp
    scummvm/trunk/engines/gob/videoplayer.cpp
    scummvm/trunk/engines/gob/videoplayer.h

Modified: scummvm/trunk/engines/gob/inter_v6.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v6.cpp	2010-08-08 01:02:19 UTC (rev 51909)
+++ scummvm/trunk/engines/gob/inter_v6.cpp	2010-08-08 01:02:49 UTC (rev 51910)
@@ -118,6 +118,7 @@
 	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,

Modified: scummvm/trunk/engines/gob/videoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/videoplayer.cpp	2010-08-08 01:02:19 UTC (rev 51909)
+++ scummvm/trunk/engines/gob/videoplayer.cpp	2010-08-08 01:02:49 UTC (rev 51910)
@@ -39,8 +39,8 @@
 
 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 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 @@
 			_vm->_draw->forceBlit();
 	}
 
-
 	Graphics::Surface *surface = video->decoder->decodeNextFrame();
-	if (!surface)
-		return false;
 
 	WRITE_VAR(11, video->decoder->getCurFrame());
 
@@ -310,7 +334,7 @@
 		// state.left += 50;
 	}
 
-	if (primary) {
+	if (surface && primary) {
 		// Post-decoding palette and blitting, only for primary videos
 
 		if (_needBlit)
@@ -350,7 +374,9 @@
 
 		}
 
-		_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 @@
 	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;
 }
 

Modified: scummvm/trunk/engines/gob/videoplayer.h
===================================================================
--- scummvm/trunk/engines/gob/videoplayer.h	2010-08-08 01:02:19 UTC (rev 51909)
+++ scummvm/trunk/engines/gob/videoplayer.h	2010-08-08 01:02:49 UTC (rev 51910)
@@ -78,6 +78,8 @@
 		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.


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list