diff options
author | Max Horn | 2003-03-19 19:09:51 +0000 |
---|---|---|
committer | Max Horn | 2003-03-19 19:09:51 +0000 |
commit | dcd6a8d29d3cbc3450dcb86987779a16265c2b2e (patch) | |
tree | 8b3b1f1ae4aa8e5cd1351ed9f4ff7d682d6d0baa /scumm | |
parent | 1baa7e30d08e4c819700423406ff7671d6f23c99 (diff) | |
download | scummvm-rg350-dcd6a8d29d3cbc3450dcb86987779a16265c2b2e.tar.gz scummvm-rg350-dcd6a8d29d3cbc3450dcb86987779a16265c2b2e.tar.bz2 scummvm-rg350-dcd6a8d29d3cbc3450dcb86987779a16265c2b2e.zip |
use a mutex to sync smush screen updates (should avoid crash caused by a race condition)
svn-id: r6837
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/smush/smush_player.cpp | 42 | ||||
-rw-r--r-- | scumm/smush/smush_player.h | 4 |
2 files changed, 22 insertions, 24 deletions
diff --git a/scumm/smush/smush_player.cpp b/scumm/smush/smush_player.cpp index 4406bb8afa..e145f28623 100644 --- a/scumm/smush/smush_player.cpp +++ b/scumm/smush/smush_player.cpp @@ -218,10 +218,14 @@ SmushPlayer::SmushPlayer(Scumm *scumm, int speed, bool subtitles) { _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::setPalette(byte *palette) { } 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 @@ void SmushPlayer::play(const char *filename, const char *directory) { return; } - _whileUpdate = false; - _whileCopyRect = false; _updateNeeded = false; setupAnim(filename, directory); @@ -887,17 +887,15 @@ void SmushPlayer::play(const char *filename, const char *directory) { _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); - - _whileUpdate = false; - } + _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); + + _scumm->_system->unlock_mutex(_mutex); } if (_scumm->_videoFinished == true) break; diff --git a/scumm/smush/smush_player.h b/scumm/smush/smush_player.h index 52c79aad3a..24952b1079 100644 --- a/scumm/smush/smush_player.h +++ b/scumm/smush/smush_player.h @@ -62,14 +62,14 @@ private: 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); |