GRIM/EMI: Draw movie subtitles while holding frame lock

This prevents a crash that occurs if the movie player deletes the
active subtitle while the main loop is still in the process of drawing
it.
This commit is contained in:
Dries Harnie 2020-05-17 13:48:22 +02:00
parent 8c95812106
commit 49a4de702f
4 changed files with 17 additions and 3 deletions

View File

@ -619,9 +619,9 @@ void GrimEngine::updateDisplayScene() {
}
// Draw Primitives
_iris->draw();
if (_movieSubtitle) {
_movieSubtitle->draw();
}
g_movie->drawMovieSubtitle();
} else if (_mode == NormalMode || _mode == OverworldMode) {
updateNormalMode();
} else if (_mode == DrawMode) {
@ -1356,6 +1356,11 @@ void GrimEngine::setMovieSubtitle(TextObject *to) {
}
}
void GrimEngine::drawMovieSubtitle() {
if (_movieSubtitle)
_movieSubtitle->draw();
}
void GrimEngine::setMovieSetup() {
_movieSetup = _currSet->getCurrSetup()->_name;
}

View File

@ -161,6 +161,7 @@ public:
bool areActorsTalking() const;
void immediatelyRemoveActor(Actor *actor);
void drawMovieSubtitle();
void setMovieSubtitle(TextObject *to);
void setMovieSetup();

View File

@ -123,6 +123,11 @@ Graphics::Surface *MoviePlayer::getDstSurface() {
return _externalSurface;
}
void MoviePlayer::drawMovieSubtitle() {
Common::StackLock lock(_frameMutex);
g_grim->drawMovieSubtitle();
}
void MoviePlayer::init() {
if (!_timerStarted) {
g_system->getTimerManager()->installTimerProc(&timerCallback, 10000, this, "movieLoop");

View File

@ -79,6 +79,9 @@ public:
virtual void clearUpdateNeeded() { _updateNeeded = false; }
virtual int32 getMovieTime() { return (int32)_movieTime; }
/* Draw the subtitles, guarded by _drawMutex */
void drawMovieSubtitle();
/**
* Saves the state of the video to a savegame
* @param state The state to save to