diff options
author | Milek7 <Milek7@users.noreply.github.com> | 2021-05-02 20:10:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-02 19:10:07 +0100 |
commit | 20762f9117c8dfbc5cc72771926563b4893592c0 (patch) | |
tree | 5258f9198f91cca09282a8a45d9df21bf073b06c /src/video | |
parent | 756034fa279bb6c3b81efbe13385583eb8a42d0f (diff) | |
download | openttd-20762f9117c8dfbc5cc72771926563b4893592c0.tar.xz |
Codechange: Acquire video buffer before taking game state lock to prevent erratic fast forward behaviour (#9140)
Diffstat (limited to 'src/video')
-rw-r--r-- | src/video/video_driver.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/video/video_driver.cpp b/src/video/video_driver.cpp index 2f8efc4ad..0af716f05 100644 --- a/src/video/video_driver.cpp +++ b/src/video/video_driver.cpp @@ -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()) {} |