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

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Sat Jan 3 14:31:23 CET 2009


Revision: 35698
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35698&view=rev
Author:   drmccoy
Date:     2009-01-03 13:31:23 +0000 (Sat, 03 Jan 2009)

Log Message:
-----------
Proper lag calculation even if the SMK has no audio

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

Modified: scummvm/trunk/graphics/video/smk_player.cpp
===================================================================
--- scummvm/trunk/graphics/video/smk_player.cpp	2009-01-03 13:11:42 UTC (rev 35697)
+++ scummvm/trunk/graphics/video/smk_player.cpp	2009-01-03 13:31:23 UTC (rev 35698)
@@ -370,13 +370,23 @@
 }
 
 int32 SMKPlayer::getAudioLag() {
-	if (!_fileStream || !_audioStream)
+	if (!_fileStream)
 		return 0;
 
 	int32 frameDelay = getFrameDelay();
 	int32 videoTime = _currentSMKFrame * frameDelay;
-	int32 audioTime = (((int32) _mixer->getSoundElapsedTime(_audioHandle)) * 100);
+	int32 audioTime;
 
+	if (!_audioStream) {
+		/* No audio.
+		   Calculate the lag by how much time has gone by since the first frame
+		   and how much time *should* have passed.
+		*/
+
+		audioTime = (g_system->getMillis() - _startTime) * 100;
+	} else
+		audioTime = (((int32) _mixer->getSoundElapsedTime(_audioHandle)) * 100);
+
 	return videoTime - audioTime;
 }
 
@@ -546,6 +556,9 @@
 
 	uint32 startPos = _fileStream->pos();
 
+	if (_currentSMKFrame == 0)
+		_startTime = g_system->getMillis();
+
 	// Check if we got a frame with palette data, and
 	// call back the virtual setPalette function to set
 	// the current palette

Modified: scummvm/trunk/graphics/video/smk_player.h
===================================================================
--- scummvm/trunk/graphics/video/smk_player.h	2009-01-03 13:11:42 UTC (rev 35697)
+++ scummvm/trunk/graphics/video/smk_player.h	2009-01-03 13:31:23 UTC (rev 35698)
@@ -184,6 +184,7 @@
 	Audio::SoundHandle _audioHandle;
 
 	uint32 _currentSMKFrame;
+	uint32 _startTime;
 
 	BigHuffmanTree *_MMapTree;
 	BigHuffmanTree *_MClrTree;


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