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:

committed by
Jonathan G Rennison

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