[Scummvm-cvs-logs] CVS: scummvm/scumm/smush smush_player.cpp,1.168,1.169 smush_player.h,1.50,1.51

Max Horn fingolfin at users.sourceforge.net
Sat Jun 25 08:18:05 CEST 2005


Update of /cvsroot/scummvm/scummvm/scumm/smush
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4288

Modified Files:
	smush_player.cpp smush_player.h 
Log Message:
Move file handling in SMUSH code to a single thread (unless I overlooked some cases)

Index: smush_player.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_player.cpp,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -d -r1.168 -r1.169
--- smush_player.cpp	24 Jun 2005 15:23:39 -0000	1.168
+++ smush_player.cpp	25 Jun 2005 15:17:13 -0000	1.169
@@ -238,6 +238,8 @@
 	_base = NULL;
 	_frameBuffer = NULL;
 	_specialBuffer = NULL;
+	
+	_seekPos = -1;
 
 	_skipNext = false;
 	_subtitles = ConfMan.getBool("subtitles");
@@ -368,9 +370,7 @@
 		_smixer->addChannel(c);
 	}
 
-	if ((_middleAudio) && (index != 0)) {
-		c->setParameters(max_frames, flags, vol, pan, index);
-	} else if (index == 0) {
+	if (_middleAudio || (index == 0)) {
 		c->setParameters(max_frames, flags, vol, pan, index);
 	} else {
 		c->checkParameters(index, max_frames, flags, vol, pan);
@@ -982,15 +982,9 @@
 }
 
 void SmushPlayer::setupAnim(const char *file) {
-	Chunk *sub;
 	int i;
 	char file_font[11];
 
-	_base = new FileChunk(file);
-	sub = _base->subBlock();
-	checkBlock(*sub, TYPE_AHDR);
-	handleAnimHeader(*sub);
-
 	if (_insanity) {
 		if (!((_vm->_features & GF_DEMO) && (_vm->_platform == Common::kPlatformPC)))
 			readString("mineroad.trs");
@@ -1027,22 +1021,59 @@
 	} else {
 		error("SmushPlayer::setupAnim() Unknown font setup for game");
 	}	
-
-	delete sub;
 }
 
 void SmushPlayer::parseNextFrame() {
 	Common::StackLock lock(_mutex);
+	
+	Chunk *sub;
 
 	if (_vm->_smushPaused)
 		return;
+	
+	if (_seekPos >= 0) {
+		if (_smixer)
+			_smixer->stop();
+	
+		if (_seekFile.size() > 0) {
+			if (_base) {
+				delete _base;
+			}
+			_base = new FileChunk(_seekFile);
+	
+			if (_seekPos > 0) {
+				assert(_seekPos > 8);
+				// In this case we need to get palette and number of frames
+				sub = _base->subBlock();
+				checkBlock(*sub, TYPE_AHDR);
+				handleAnimHeader(*sub);
+				delete sub;
+	
+				_middleAudio = true;
+				_seekPos -= 8;
+			} else {
+				// We need this in Full Throttle when entering/leaving
+				// the old mine road.
+				tryCmpFile(_seekFile.c_str());
+			}
+			_skipPalette = false;
+		} else {
+			_skipPalette = true;
+		}
+	
+		_base->seek(_seekPos, FileChunk::seek_start);
+		_frame = _seekFrame;
+		
+		_seekPos = -1;
+	}
 
+	assert(_base);
 	if (_base->eof()) {
 		_vm->_smushVideoShouldFinish = true;
 		return;
 	}
 
-	Chunk *sub = _base->subBlock();
+	sub = _base->subBlock();
 
 	switch (sub->getType()) {
 	case TYPE_AHDR: // FT INSANE may seek file to the beginning
@@ -1153,39 +1184,9 @@
 void SmushPlayer::seekSan(const char *file, int32 pos, int32 contFrame) {
 	Common::StackLock lock(_mutex);
 
-	if (_smixer)
-		_smixer->stop();
-
-	if (file) {
-		if (_base) {
-			_base->seek(0, FileChunk::seek_end);
-			delete _base;
-		}
-
-		_base = new FileChunk(file);
-		if (pos) {
-			assert(pos != 8);
-			// In this case we need to get palette and number of frames
-			Chunk *sub = _base->subBlock();
-			checkBlock(*sub, TYPE_AHDR);
-			handleAnimHeader(*sub);
-			delete sub;
-
-			_middleAudio = true;
-			pos -= 8;
-		} else {
-			// We need this in Full Throttle when entering/leaving
-			// the old mine road.
-			tryCmpFile(file);
-		}
-		_skipPalette = false;
-	} else {
-		_skipPalette = true;
-	}
-
-	_base->seek(pos, FileChunk::seek_start);
-
-	_frame = contFrame;
+	_seekFile = file ? file : "";
+	_seekPos = pos;
+	_seekFrame = contFrame;
 }
 
 void SmushPlayer::tryCmpFile(const char *filename) {
@@ -1198,8 +1199,10 @@
 	if (i == NULL) {
 		error("invalid filename : %s", filename);
 	}
-#ifdef USE_MAD
+#if defined(USE_MAD) || defined(USE_VORBIS)
 	char fname[260];
+#endif
+#ifdef USE_MAD
 	memcpy(fname, filename, i - filename);
 	strcpy(fname + (i - filename), ".mp3");
 	_compressedFile.open(fname);
@@ -1234,8 +1237,6 @@
 	}
 	f.close();
 
-	tryCmpFile(filename);
-
 	_updateNeeded = false;
 	_warpNeeded = false;
 	_palDirtyMin = 256;
@@ -1245,15 +1246,14 @@
 	bool oldMouseState = _vm->_system->showMouse(false);
 
 	// Load the video
+	_seekFile = filename;
+	_seekPos = offset;
+	_seekFrame = startFrame;
+	_base = 0;
+
 	setupAnim(filename);
 	init();
 
-	if (offset) {
-		_base->seek(offset - 8, FileChunk::seek_start);
-		_frame = startFrame;
-		_middleAudio = true;
-	}
-
 	for (;;) {
 		if (_warpNeeded) {
 			_vm->_system->warpMouse(_warpX, _warpY);
@@ -1280,7 +1280,6 @@
 			_palDirtyMin = 256;
 		}
 		if (_updateNeeded) {
-			
 			uint32 end_time, start_time;
 			
 			start_time = _vm->_system->getMillis();

Index: smush_player.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_player.h,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- smush_player.h	28 May 2005 02:26:14 -0000	1.50
+++ smush_player.h	25 Jun 2005 15:17:14 -0000	1.51
@@ -51,6 +51,10 @@
 	byte *_frameBuffer;
 	byte *_specialBuffer;
 
+	Common::String _seekFile;
+	int32 _seekPos;
+	int32 _seekFrame;
+
 	bool _skipNext;
 	bool _subtitles;
 	bool _skips[37];





More information about the Scummvm-git-logs mailing list