From 0a7eef8cf072582640c72d9a74604d939ff0ce61 Mon Sep 17 00:00:00 2001 From: Jason Millard Date: Fri, 20 Sep 2024 22:50:18 -0400 Subject: [PATCH] libpinmame: fix timefence, move time_to_quit into cpu_timeslice --- src/cpuexec.c | 8 +++++++- src/usrintrf.c | 7 ------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/cpuexec.c b/src/cpuexec.c index f93779942..ff2b620c6 100644 --- a/src/cpuexec.c +++ b/src/cpuexec.c @@ -897,7 +897,7 @@ void time_fence_post() int time_fence_wait(double secs) { - int ns = max((int)ceil(secs * 1000000000.), 1); + int64_t ns = max((int64_t)ceil(secs * 1000000000.), (int64_t)1); dispatch_time_t wait_length = dispatch_time(DISPATCH_TIME_NOW, ns); return time_fence_is_supported() && (dispatch_semaphore_wait(time_fence_semaphore, wait_length) == 0); } @@ -967,6 +967,12 @@ static void cpu_timeslice(void) win_process_events(); #endif +#if defined(LIBPINMAME) + extern int libpinmame_time_to_quit(void); + if (libpinmame_time_to_quit()) + time_to_quit = 1; +#endif + // PinMAME: allow external synchronization by suspending emulation when a time fence is reached // NOTE: if debugging stutter issues or the like, disable this mechanism in the core scripts, or directly here if (options.time_fence != 0.0 && time_fence_is_supported()) diff --git a/src/usrintrf.c b/src/usrintrf.c index d58c105d5..31f55e29f 100644 --- a/src/usrintrf.c +++ b/src/usrintrf.c @@ -45,10 +45,6 @@ extern unsigned int coinlockedout[COIN_COUNTERS]; static int game_paused = 0; /* not zero if the game is paused */ #endif -#if defined(LIBPINMAME) -extern int libpinmame_time_to_quit(void); -#endif - /*************************************************************************** @@ -3877,9 +3873,6 @@ int handle_user_interface(struct mame_bitmap *bitmap) #if defined(PINMAME) && defined(PROC_SUPPORT) || code_pressed(PROC_ESC_SEQ) #endif /* PINMAME && PROC_SUPPORT */ -#if defined(LIBPINMAME) - || libpinmame_time_to_quit() -#endif /* LIBPINMAME_SUPPORT */ #if defined(LISY_SUPPORT) //check in lisy for SIGUSR1 //and quit if we received it