Skip to content

Commit

Permalink
Codechange: Acquire video buffer before taking game state lock to pre…
Browse files Browse the repository at this point in the history
…vent erratic fast forward behaviour (#9140)
  • Loading branch information
Milek7 authored and LordAro committed May 3, 2021
1 parent 72090f3 commit 8b5bd34
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/video/video_driver.cpp
Expand Up @@ -131,13 +131,14 @@ void VideoDriver::Tick()
this->fast_forward_via_key = false;
}

/* Locking video buffer can block (especially with vsync enabled), do it before taking game state lock. */
this->LockVideoBuffer();

{
/* Tell the game-thread to stop so we can have a go. */
std::lock_guard<std::mutex> lock_wait(this->game_thread_wait_mutex);
std::lock_guard<std::mutex> lock_state(this->game_state_mutex);

this->LockVideoBuffer();

this->DrainCommandQueue();

while (this->PollEvent()) {}
Expand Down

0 comments on commit 8b5bd34

Please sign in to comment.