mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-29 09:29:10 +00:00
Codechange: Acquire video buffer before taking game state lock to prevent erratic fast forward behaviour (#9140)
This commit is contained in:
@@ -131,13 +131,14 @@ void VideoDriver::Tick()
|
|||||||
this->fast_forward_via_key = false;
|
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. */
|
/* 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_wait(this->game_thread_wait_mutex);
|
||||||
std::lock_guard<std::mutex> lock_state(this->game_state_mutex);
|
std::lock_guard<std::mutex> lock_state(this->game_state_mutex);
|
||||||
|
|
||||||
this->LockVideoBuffer();
|
|
||||||
|
|
||||||
this->DrainCommandQueue();
|
this->DrainCommandQueue();
|
||||||
|
|
||||||
while (this->PollEvent()) {}
|
while (this->PollEvent()) {}
|
||||||
|
Reference in New Issue
Block a user