[Scummvm-cvs-logs] CVS: scummvm/sword2/driver animation.cpp,1.18,1.19 animation.h,1.16,1.17

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Thu Feb 12 09:01:09 CET 2004


Update of /cvsroot/scummvm/scummvm/sword2/driver
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11766

Modified Files:
	animation.cpp animation.h 
Log Message:
Changed the playback code to use the new "elapsed time" function instead.
This fixes bug #880484 for me, but may need some fine-tuning.


Index: animation.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/animation.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- animation.cpp	8 Feb 2004 14:02:43 -0000	1.18
+++ animation.cpp	12 Feb 2004 16:55:18 -0000	1.19
@@ -65,7 +65,7 @@
 
 #ifdef BACKEND_8BIT
 
-	int i, p;
+	uint i, p;
 
 	// Load lookup palettes
 	// TODO: Binary format so we can use File class
@@ -336,22 +336,19 @@
 		case STATE_END:
 			if (info->display_fbuf) {
 				/* simple audio video sync code:
-				 * we calculate the actual frame by taking the delivered audio samples
-				 * we add 2 frames as the number of samples delivered is higher than the
-				 * number actually played due to buffering
-				 *
-				 * we then try to stay inside +- 1 frame of this calculated frame number by
-				 * dropping frames if we run behind and delaying if we are too fast
+				 * we calculate the actual frame by taking the elapsed audio time and try
+				 * to stay inside +- 1 frame of this calculated frame number by dropping
+				 * frames if we run behind and delaying if we are too fast
 				 */
 
 #ifdef BACKEND_8BIT
 				if (checkPaletteSwitch() || (bgSoundStream == NULL) ||
-					(bgSoundStream->getSamplesPlayed() * 12 / bgSoundStream->getRate()) < (framenum + 3)){
+					((_vm->_mixer->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum + 1)) {
 
 					_vm->_graphics->plotYUV(lut, sequence_i->width, sequence_i->height, info->display_fbuf->buf);
 
 					if (bgSoundStream) {
-						while ((bgSoundStream->getSamplesPlayed() * 12 / bgSoundStream->getRate()) < framenum + 1)
+						while ((_vm->_mixer->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum)
 							_vm->_system->delay_msecs(10);
 					} else {
 						ticks += 83;
@@ -368,12 +365,12 @@
 #else
 
 				if ((bgSoundStream == NULL) ||
-					(bgSoundStream->getSamplesPlayed() * 12 / bgSoundStream->getRate()) < (framenum+3)){
+					((_vm->_mixer->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum + 1)) {
 
 					plotYUV(lookup, sequence_i->width, sequence_i->height, info->display_fbuf->buf);
 
 					if (bgSoundStream) {
-						while ((bgSoundStream->getSamplesPlayed() * 12 / bgSoundStream->getRate()) < framenum + 1)
+						while ((_vm->_mixer->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum)
 							_vm->_system->delay_msecs(10);
 					} else {
 						ticks += 83;

Index: animation.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/animation.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- animation.h	5 Feb 2004 14:19:06 -0000	1.16
+++ animation.h	12 Feb 2004 16:55:18 -0000	1.17
@@ -71,7 +71,7 @@
 private:
 	Sword2Engine *_vm;
 
-	int framenum;
+	uint framenum;
 	int ticks;
 
 #ifdef USE_MPEG2
@@ -101,8 +101,8 @@
 	int pos;
 
 	struct {
-		int cnt;
-		int end;
+		uint cnt;
+		uint end;
 		byte pal[4 * 256];
 	} palettes[50];
 #else





More information about the Scummvm-git-logs mailing list