try a new technique to just unstick the frontend when the n64 emulation thread dies

This commit is contained in:
zeromus 2018-11-07 15:37:37 -05:00
parent aee7358a6d
commit 2eade372fd
4 changed files with 20 additions and 3 deletions

View File

@ -400,9 +400,9 @@ namespace BizHawk.Common
/// <summary> /// <summary>
/// functionally the same as WaitOne, but does not message pump /// functionally the same as WaitOne, but does not message pump
/// </summary> /// </summary>
public static void HackyPinvokeWaitOne(WaitHandle handle) public static void HackyPinvokeWaitOne(WaitHandle handle, uint timeout = 0xFFFFFFFF)
{ {
NativeMethods.WaitForSingleObject(handle.SafeWaitHandle, 0xFFFFFFFF); NativeMethods.WaitForSingleObject(handle.SafeWaitHandle, timeout);
} }
/// <summary> /// <summary>

View File

@ -733,6 +733,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
public void frame_advance() public void frame_advance()
{ {
if (!emulator_running)
return;
event_frameend = false; event_frameend = false;
m64pCoreDoCommandPtr(m64p_command.M64CMD_ADVANCE_FRAME, 0, IntPtr.Zero); m64pCoreDoCommandPtr(m64p_command.M64CMD_ADVANCE_FRAME, 0, IntPtr.Zero);
@ -751,7 +754,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
for(;;) for(;;)
{ {
BizHawk.Common.Win32ThreadHacks.HackyPinvokeWaitOne(m64pEvent); BizHawk.Common.Win32ThreadHacks.HackyPinvokeWaitOne(m64pEvent, 200);
if (event_frameend) if (event_frameend)
break; break;
if (event_breakpoint) if (event_breakpoint)
@ -771,7 +774,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
event_breakpoint = false; event_breakpoint = false;
Resume(); Resume();
continue;
} }
//no event.. must be a timeout
//check if the core crashed and bail if it did
//otherwise wait longer (could be inside slow emulation or lua logic)
if (!emulator_running)
break;
} }
} }

View File

@ -211,7 +211,15 @@ EXPORT m64p_error CALL CoreDoCommand(m64p_command Command, int ParamInt, void *P
/* print out plugin-related warning messages */ /* print out plugin-related warning messages */
plugin_check(); plugin_check();
/* the main_run() function will not return until the player has quit the game */ /* the main_run() function will not return until the player has quit the game */
__try
{
rval = main_run((void (*)(void))ParamPtr); rval = main_run((void (*)(void))ParamPtr);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
printf("exception swallowed because mupen is crashy when being fuzzed\n");
rval = M64ERR_INTERNAL;
}
return rval; return rval;
case M64CMD_STOP: case M64CMD_STOP:
if (!g_EmulatorRunning) if (!g_EmulatorRunning)

Binary file not shown.