Codechange: Acquire video buffer before taking game state lock to prevent erratic fast forward behaviour (#9140)

(cherry picked from commit 20762f9117)
pull/259/head
Milek7 3 years ago committed by Jonathan G Rennison
parent 01d40812fa
commit deb2ad8997

@ -127,6 +127,9 @@ void VideoDriver::Tick()
auto now = std::chrono::steady_clock::now();
if (this->HasGUI() && now >= this->next_draw_tick) {
/* 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);
@ -151,8 +154,6 @@ void VideoDriver::Tick()
* new values when-ever we can. */
InteractiveRandom();
this->LockVideoBuffer();
this->DrainCommandQueue();
while (this->PollEvent()) {}

Loading…
Cancel
Save