Merge pull request #22142 from darkguy2008/libretro-pause-handshake

libretro: restore emu-thread pause handshake so retro_serialize can't deadlock
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2026-08-25 17:36:58 +02:00
commit a0c10a0ea6
2 files changed
+7 -2

No files matched your search

+1
View File
@@ -100,6 +100,7 @@ extern retro_hw_context_type backend;
enum class EmuThreadState {
DISABLED,
RUNNING,
PAUSE_REQUESTED,
PAUSED,
QUIT_REQUESTED,
STOPPED,
+6 -2
View File
@@ -1392,6 +1392,9 @@ namespace Libretro {
case EmuThreadState::RUNNING:
EmuFrame();
break;
case EmuThreadState::PAUSE_REQUESTED:
emuThreadState = EmuThreadState::PAUSED;
[[fallthrough]];
case EmuThreadState::PAUSED:
sleep_ms(1, "libretro-paused");
break;
@@ -1441,7 +1444,7 @@ namespace Libretro {
if (emuThreadState != EmuThreadState::RUNNING)
return;
emuThreadState = EmuThreadState::PAUSED;
emuThreadState = EmuThreadState::PAUSE_REQUESTED;
// Is this safe?
ctx->ThreadFrame(); // Eat 1 frame
@@ -1715,7 +1718,8 @@ void retro_run(void) {
// Handle thread pumping.
if (useEmuThread) {
if (emuThreadState == EmuThreadState::PAUSED) {
if (emuThreadState == EmuThreadState::PAUSED ||
emuThreadState == EmuThreadState::PAUSE_REQUESTED) {
VsyncSwapIntervalDetect();
ctx->SwapBuffers();
return;