From 20762f9117c8dfbc5cc72771926563b4893592c0 Mon Sep 17 00:00:00 2001 From: Milek7 Date: Sun, 2 May 2021 20:10:07 +0200 Subject: Codechange: Acquire video buffer before taking game state lock to prevent erratic fast forward behaviour (#9140) --- src/video/video_driver.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/video') 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 lock_wait(this->game_thread_wait_mutex); std::lock_guard lock_state(this->game_state_mutex); - this->LockVideoBuffer(); - this->DrainCommandQueue(); while (this->PollEvent()) {} -- cgit v1.2.3-70-g09d2