[Scummvm-cvs-logs] CVS: scummvm/scumm/smush smush_player.cpp,1.9,1.10 smush_player.h,1.3,1.4

Max Horn fingolfin at users.sourceforge.net
Wed Mar 19 11:10:07 CET 2003


Update of /cvsroot/scummvm/scummvm/scumm/smush
In directory sc8-pr-cvs1:/tmp/cvs-serv21002

Modified Files:
	smush_player.cpp smush_player.h 
Log Message:
use a mutex to sync smush screen updates (should avoid crash caused by a race condition)

Index: smush_player.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_player.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- smush_player.cpp	18 Mar 2003 16:13:52 -0000	1.9
+++ smush_player.cpp	19 Mar 2003 19:09:50 -0000	1.10
@@ -218,10 +218,14 @@
 	_speed = speed;
 	_subtitles = subtitles;
 	_smushProcessFrame = false;
+	
+	_mutex = _scumm->_system->create_mutex();
 }
 
 SmushPlayer::~SmushPlayer() {
 	deinit();
+	if (_mutex)
+		_scumm->_system->delete_mutex (_mutex);
 }
 
 void SmushPlayer::init() {
@@ -855,17 +859,15 @@
 }
 
 void SmushPlayer::updateScreen() {
-	if (_whileUpdate == false) {
-		_whileCopyRect = true;
+	_scumm->_system->lock_mutex(_mutex);
 
-		uint32 end_time, start_time = _scumm->_system->get_msecs();
-		_scumm->_system->copy_rect(_data, _width, 0, 0, _width, _height);
-		_updateNeeded = true;
-		end_time = _scumm->_system->get_msecs();
-		debug(4, "Smush stats: updateScreen( %03d )", end_time - start_time);
+	uint32 end_time, start_time = _scumm->_system->get_msecs();
+	_scumm->_system->copy_rect(_data, _width, 0, 0, _width, _height);
+	_updateNeeded = true;
+	end_time = _scumm->_system->get_msecs();
+	debug(4, "Smush stats: updateScreen( %03d )", end_time - start_time);
 
-		_whileCopyRect = false;
-	}
+	_scumm->_system->unlock_mutex(_mutex);
 }
 
 void SmushPlayer::play(const char *filename, const char *directory) {
@@ -876,8 +878,6 @@
 		return;
 	}
 
-	_whileUpdate = false;
-	_whileCopyRect = false;
 	_updateNeeded = false;
 
 	setupAnim(filename, directory);
@@ -887,17 +887,15 @@
 		_scumm->processKbd();
 		_scumm->waitForTimer(1);
 		if(_updateNeeded == true) {
-			if(_whileCopyRect == false) {
-				_whileUpdate = true;
-
-				uint32 end_time, start_time = _scumm->_system->get_msecs();
-				_scumm->_system->update_screen();
-				_updateNeeded = false;
-				end_time = _scumm->_system->get_msecs();
-				debug(4, "Smush stats: BackendUpdateScreen( %03d )", end_time - start_time);
+			_scumm->_system->lock_mutex(_mutex);
+			
+			uint32 end_time, start_time = _scumm->_system->get_msecs();
+			_scumm->_system->update_screen();
+			_updateNeeded = false;
+			end_time = _scumm->_system->get_msecs();
+			debug(4, "Smush stats: BackendUpdateScreen( %03d )", end_time - start_time);
 
-				_whileUpdate = false;
-			}
+			_scumm->_system->unlock_mutex(_mutex);
 		}
 		if (_scumm->_videoFinished == true)
 			break;

Index: smush_player.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_player.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- smush_player.h	17 Mar 2003 19:10:12 -0000	1.3
+++ smush_player.h	19 Mar 2003 19:09:51 -0000	1.4
@@ -62,14 +62,14 @@
 	bool _alreadyInit;
 	int _speed;
 	bool _outputSound;
+	
+	void *_mutex;
 
 public:
 
 	int _width, _height;
 	byte *_data;
 	bool _smushProcessFrame;
-	bool _whileUpdate;
-	bool _whileCopyRect;
 	bool _updateNeeded;
 
 	SmushPlayer(Scumm *, int, bool);





More information about the Scummvm-git-logs mailing list