mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
Codechange: Acquire video buffer before taking game state lock to prevent erratic fast forward behaviour (#9140)
(cherry picked from commit 20762f9117
)
This commit is contained in:
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…
Reference in New Issue
Block a user