26 lines
1.1 KiB
Diff
26 lines
1.1 KiB
Diff
diff --git a/plugins/pinmame/Controller.cpp b/plugins/pinmame/Controller.cpp
|
|||
|
|
index 29c2405..a498fee 100644
|
||
|
|
--- a/plugins/pinmame/Controller.cpp
|
||
|
|
+++ b/plugins/pinmame/Controller.cpp
|
||
|
|
@@ -265,8 +265,20 @@ void Controller::Stop()
|
||
|
|
if (PinmameIsRunning())
|
||
|
|
{
|
||
|
|
PinmameStop();
|
||
|
|
+#ifdef __EMSCRIPTEN__
|
||
|
|
+ // PinmameStop() only sets a "please quit" flag here (see its own
|
||
|
|
+ // Emscripten branch) - there's no separate OS thread that will ever
|
||
|
|
+ // notice it and finish stopping on its own, so busy-waiting for
|
||
|
|
+ // PinmameIsRunning() to clear on this single thread would spin
|
||
|
|
+ // forever. Drive one more step directly instead: with the quit flag
|
||
|
|
+ // already set, it's a bounded, instant call that completes the
|
||
|
|
+ // pending teardown (calls cpu_post_run() and OnStateChange(0))
|
||
|
|
+ // synchronously right here.
|
||
|
|
+ PinmameEmscriptenStep();
|
||
|
|
+#else
|
||
|
|
while (PinmameIsRunning() != 0) // Wait until the machine is stopped
|
||
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(75));
|
||
|
|
+#endif
|
||
|
|
if (m_onGameEndHandler)
|
||
|
|
m_onGameEndHandler(this);
|
||
|
|
}
|