From d8796732aabf5a966a2413ce6f66eb8a440d0141 Mon Sep 17 00:00:00 2001 From: Sven <40953353+RetroSven@users.noreply.github.com> Date: Tue, 11 Sep 2018 13:29:20 -0400 Subject: [PATCH 1/3] provide a means for cores to coordinate with the frontend when shutting down multiple threads gracefully --- dynamic.c | 21 ++++++++++++++++++--- libretro-common/include/libretro.h | 14 ++++++++++++++ retroarch.h | 2 -- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/dynamic.c b/dynamic.c index 462628eb5d..73e593298d 100644 --- a/dynamic.c +++ b/dynamic.c @@ -1042,6 +1042,16 @@ static void core_performance_counter_stop(struct retro_perf_counter *perf) perf->total += cpu_features_get_perf_counter() - perf->start; } +bool rarch_clear_all_thread_waits(unsigned clear_threads, void *data) +{ + if ( clear_threads > 0) + audio_driver_start(false) ; + else + audio_driver_stop() ; + + return true ; +} + /** * rarch_environment_cb: * @cmd : Identifier of command. @@ -1833,8 +1843,8 @@ bool rarch_environment_cb(unsigned cmd, void *data) int* result_p = (int*)data; *result_p = result; } + break; } - break; case RETRO_ENVIRONMENT_GET_MIDI_INTERFACE: { @@ -1849,16 +1859,21 @@ bool rarch_environment_cb(unsigned cmd, void *data) midi_interface->write = midi_driver_write; midi_interface->flush = midi_driver_flush; } + break; } - break; case RETRO_ENVIRONMENT_GET_FASTFORWARDING: { extern bool runloop_fastmotion; *(bool *)data = runloop_fastmotion; + break; } - break; + case RETRO_ENVIRONMENT_GET_CLEAR_ALL_THREAD_WAITS_CB: + { + *(retro_environment_t *)data = rarch_clear_all_thread_waits; + break; + } default: RARCH_LOG("Environ UNSUPPORTED (#%u).\n", cmd); diff --git a/libretro-common/include/libretro.h b/libretro-common/include/libretro.h index 78e67a0781..bd95d508f6 100644 --- a/libretro-common/include/libretro.h +++ b/libretro-common/include/libretro.h @@ -1195,6 +1195,20 @@ struct retro_led_interface * fastforwarding mode. */ +#define RETRO_ENVIRONMENT_SET_SAVE_STATE_IN_BACKGROUND (50 | RETRO_ENVIRONMENT_EXPERIMENTAL) + /* bool * -- + * Boolean value that tells the front end to save states in the + * background or not. + */ + +#define RETRO_ENVIRONMENT_GET_CLEAR_ALL_THREAD_WAITS_CB (51 | RETRO_ENVIRONMENT_EXPERIMENTAL) + /* retro_environment_t * -- + * Provides the callback to the frontend method which will cancel + * all currently waiting threads. Used when coordination is needed + * between the core and the frontend to gracefully stop all threads. + */ + + /* Retrieves the current state of the MIDI input. * Returns true if it's enabled, false otherwise. */ typedef bool (RETRO_CALLCONV *retro_midi_input_enabled_t)(void); diff --git a/retroarch.h b/retroarch.h index dda1628c29..46d882deed 100644 --- a/retroarch.h +++ b/retroarch.h @@ -33,8 +33,6 @@ RETRO_BEGIN_DECLS -#define RETRO_ENVIRONMENT_SET_SAVE_STATE_IN_BACKGROUND RETRO_ENVIRONMENT_PRIVATE+1 - enum rarch_ctl_state { RARCH_CTL_NONE = 0, From b771a3e0f58e786833f941e14d64a11dd062833f Mon Sep 17 00:00:00 2001 From: Sven <40953353+RetroSven@users.noreply.github.com> Date: Tue, 11 Sep 2018 18:45:01 -0400 Subject: [PATCH 2/3] move libretro.h defines to retroarch.h --- libretro-common/include/libretro.h | 18 ------------------ retroarch.h | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/libretro-common/include/libretro.h b/libretro-common/include/libretro.h index bd95d508f6..a0966bf3d1 100644 --- a/libretro-common/include/libretro.h +++ b/libretro-common/include/libretro.h @@ -1189,24 +1189,6 @@ struct retro_led_interface * Returns a MIDI interface that can be used for raw data I/O. */ -#define RETRO_ENVIRONMENT_GET_FASTFORWARDING (49 | RETRO_ENVIRONMENT_EXPERIMENTAL) - /* bool * -- - * Boolean value that indicates whether or not the frontend is in - * fastforwarding mode. - */ - -#define RETRO_ENVIRONMENT_SET_SAVE_STATE_IN_BACKGROUND (50 | RETRO_ENVIRONMENT_EXPERIMENTAL) - /* bool * -- - * Boolean value that tells the front end to save states in the - * background or not. - */ - -#define RETRO_ENVIRONMENT_GET_CLEAR_ALL_THREAD_WAITS_CB (51 | RETRO_ENVIRONMENT_EXPERIMENTAL) - /* retro_environment_t * -- - * Provides the callback to the frontend method which will cancel - * all currently waiting threads. Used when coordination is needed - * between the core and the frontend to gracefully stop all threads. - */ /* Retrieves the current state of the MIDI input. diff --git a/retroarch.h b/retroarch.h index 46d882deed..9d8823ea26 100644 --- a/retroarch.h +++ b/retroarch.h @@ -33,6 +33,27 @@ RETRO_BEGIN_DECLS +#define RETRO_ENVIRONMENT_RETROARCH_START_BLOCK 0x800000 + +#define RETRO_ENVIRONMENT_GET_FASTFORWARDING (1 | RETRO_ENVIRONMENT_RETROARCH_START_BLOCK) + /* bool * -- + * Boolean value that indicates whether or not the frontend is in + * fastforwarding mode. + */ + +#define RETRO_ENVIRONMENT_SET_SAVE_STATE_IN_BACKGROUND (2 | RETRO_ENVIRONMENT_RETROARCH_START_BLOCK) + /* bool * -- + * Boolean value that tells the front end to save states in the + * background or not. + */ + +#define RETRO_ENVIRONMENT_GET_CLEAR_ALL_THREAD_WAITS_CB (3 | RETRO_ENVIRONMENT_RETROARCH_START_BLOCK) + /* retro_environment_t * -- + * Provides the callback to the frontend method which will cancel + * all currently waiting threads. Used when coordination is needed + * between the core and the frontend to gracefully stop all threads. + */ + enum rarch_ctl_state { RARCH_CTL_NONE = 0, From 3c0eadbdf2ea96ba3f0150d1ee43622e9733e8b4 Mon Sep 17 00:00:00 2001 From: Sven <40953353+RetroSven@users.noreply.github.com> Date: Tue, 11 Sep 2018 18:52:51 -0400 Subject: [PATCH 3/3] per request --- libretro-common/include/libretro.h | 6 ++++++ retroarch.h | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libretro-common/include/libretro.h b/libretro-common/include/libretro.h index a0966bf3d1..dd015e9a75 100644 --- a/libretro-common/include/libretro.h +++ b/libretro-common/include/libretro.h @@ -1189,6 +1189,12 @@ struct retro_led_interface * Returns a MIDI interface that can be used for raw data I/O. */ +#define RETRO_ENVIRONMENT_GET_FASTFORWARDING (49 | RETRO_ENVIRONMENT_EXPERIMENTAL) + /* bool * -- + * Boolean value that indicates whether or not the frontend is in + * fastforwarding mode. + */ + /* Retrieves the current state of the MIDI input. diff --git a/retroarch.h b/retroarch.h index 9d8823ea26..596dce7d54 100644 --- a/retroarch.h +++ b/retroarch.h @@ -35,11 +35,6 @@ RETRO_BEGIN_DECLS #define RETRO_ENVIRONMENT_RETROARCH_START_BLOCK 0x800000 -#define RETRO_ENVIRONMENT_GET_FASTFORWARDING (1 | RETRO_ENVIRONMENT_RETROARCH_START_BLOCK) - /* bool * -- - * Boolean value that indicates whether or not the frontend is in - * fastforwarding mode. - */ #define RETRO_ENVIRONMENT_SET_SAVE_STATE_IN_BACKGROUND (2 | RETRO_ENVIRONMENT_RETROARCH_START_BLOCK) /* bool * --