[Scummvm-cvs-logs] SF.net SVN: scummvm:[35431] scummvm/trunk/graphics

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Fri Dec 19 01:14:18 CET 2008


Revision: 35431
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35431&view=rev
Author:   drmccoy
Date:     2008-12-19 00:14:18 +0000 (Fri, 19 Dec 2008)

Log Message:
-----------
Adding convenience functions to get the time to wait for the next frame, while keeping A/V sync

Modified Paths:
--------------
    scummvm/trunk/graphics/smk_player.cpp
    scummvm/trunk/graphics/smk_player.h

Modified: scummvm/trunk/graphics/smk_player.cpp
===================================================================
--- scummvm/trunk/graphics/smk_player.cpp	2008-12-18 23:50:59 UTC (rev 35430)
+++ scummvm/trunk/graphics/smk_player.cpp	2008-12-19 00:14:18 UTC (rev 35431)
@@ -351,6 +351,38 @@
 	return _header.frameRate;
 }
 
+int32 SMKPlayer::getFrameDelay() {
+	if (!_fileStream)
+		return 0;
+
+	if (_header.frameRate > 0)
+		return _header.frameRate * 100;
+	if (_header.frameRate < 0)
+		return -_header.frameRate;
+
+	return 10000;
+}
+
+int32 SMKPlayer::getAudioLag() {
+	if (!_fileStream || !_audioStream)
+		return 0;
+
+	int32 frameDelay = getFrameDelay();
+	int32 videoTime = _currentSMKFrame * frameDelay;
+	int32 audioTime = (((int32) _mixer->getSoundElapsedTime(_audioHandle)) * 100);
+
+	return videoTime - audioTime;
+}
+
+uint32 SMKPlayer::getFrameWaitTime() {
+	int32 waitTime = (getFrameDelay() + getAudioLag()) / 100;
+
+	if (waitTime < 0)
+		return 0;
+
+	return waitTime;
+}
+
 bool SMKPlayer::loadFile(const char *fileName) {
 	closeFile();
 

Modified: scummvm/trunk/graphics/smk_player.h
===================================================================
--- scummvm/trunk/graphics/smk_player.h	2008-12-18 23:50:59 UTC (rev 35430)
+++ scummvm/trunk/graphics/smk_player.h	2008-12-19 00:14:18 UTC (rev 35431)
@@ -83,6 +83,26 @@
 	int32 getFrameRate();
 
 	/**
+	 * Returns the time to wait for each frame in 1/100 ms
+	 * @return the time to wait for each frame in 1/100 ms
+	 */
+	int32 getFrameDelay();
+
+	/**
+	 * Returns the current A/V lag in 1/100 ms
+	 * If > 0, audio lags behind
+	 * If < 0, video lags behind
+	 * @return the current A/V lag in 1/100 ms
+	 */
+	int32 getAudioLag();
+
+	/**
+	 * Returns the time to wait until the next frame in ms, minding any lag
+	 * @return the time to wait until the next frame in ms
+	 */
+	uint32 getFrameWaitTime();
+
+	/**
 	 * Load an SMK encoded video file
 	 * @param filename	the filename to load
 	 */


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