From 2a2432207a319cec4b2073e7abe9f43972c12e39 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 11 Dec 2023 20:32:51 +0100 Subject: [PATCH] More fixes, the hard freeze is truly gone now. --- src/86box.c | 22 ++++++++++++---------- src/qt/qt_main.cpp | 10 ++++++++-- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/86box.c b/src/86box.c index 7ccc3c96d..25b073fda 100644 --- a/src/86box.c +++ b/src/86box.c @@ -111,7 +111,7 @@ /* Stuff that used to be globally declared in plat.h but is now extern there and declared here instead. */ -int dopause; /* system is paused */ +int dopause = 1; /* system is paused */ atomic_flag doresize; /* screen resize requested */ volatile int is_quit; /* system exit requested */ uint64_t timer_freq; @@ -236,8 +236,8 @@ int efscrnsz_y = SCREEN_RES_Y; static wchar_t mouse_msg[3][200]; -static volatile int do_pause_ack = 0; -static volatile int pause_ack = 0; +static volatile atomic_int do_pause_ack = 0; +static volatile atomic_int pause_ack = 0; #ifndef RELEASE_BUILD static char buff[1024]; @@ -1359,9 +1359,9 @@ _ui_window_title(void *s) void ack_pause(void) { - if (do_pause_ack) { - do_pause_ack = 0; - pause_ack = 1; + if (atomic_load(&do_pause_ack)) { + atomic_store(&do_pause_ack, 0); + atomic_store(&pause_ack, 1); } } @@ -1579,12 +1579,14 @@ get_actual_size_y(void) void do_pause(int p) { - if (p) + int old_p = dopause; + + if (p && !old_p) do_pause_ack = p; dopause = p; - if (p) { - while (!pause_ack) + if (p && !old_p) { + while (!atomic_load(&pause_ack)) ; } - pause_ack = 0; + atomic_store(&pause_ack, 0); } diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index 845ff705f..c859fe033 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -293,8 +293,6 @@ main(int argc, char *argv[]) // pc_reset_hard_init(); - /* Set the PAUSE mode depending on the renderer. */ - // plat_pause(0); QTimer onesec; QObject::connect(&onesec, &QTimer::timeout, &app, [] { pc_onesec(); @@ -323,6 +321,14 @@ main(int argc, char *argv[]) QTimer::singleShot(0, &app, [] { pc_reset_hard_init(); main_thread = new std::thread(main_thread_fn); + + /* Set the PAUSE mode depending on the renderer. */ +#ifdef USE_VNC + if (vnc_enabled && vid_api != 6) + plat_pause(1); + else +#endif + plat_pause(0); }); auto ret = app.exec();