From c0a1a6a3fe5f8b0953ea08bc67f006cb0893431e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 4 Dec 2015 12:44:12 +0100 Subject: [PATCH] Move system->shutdown to runloop_ctl, turn it into a local static variable --- audio/drivers/ctr_csnd_audio.c | 4 +--- audio/drivers/ctr_dsp_audio.c | 4 +--- dynamic.c | 2 +- frontend/drivers/platform_ps3.c | 5 ++--- gfx/drivers_context/androidegl_ctx.c | 3 +-- gfx/drivers_context/bbqnx_ctx.c | 3 +-- input/drivers/android_input.c | 7 ++----- input/drivers/qnx_input.c | 3 +-- menu/menu_driver.c | 2 +- retroarch.c | 4 +--- runloop.c | 14 +++++++++++--- runloop.h | 3 +++ system.h | 1 - 13 files changed, 26 insertions(+), 29 deletions(-) diff --git a/audio/drivers/ctr_csnd_audio.c b/audio/drivers/ctr_csnd_audio.c index 624fc16843..542b73dbc1 100644 --- a/audio/drivers/ctr_csnd_audio.c +++ b/audio/drivers/ctr_csnd_audio.c @@ -19,7 +19,6 @@ #include "../audio_driver.h" #include "../../configuration.h" #include "../../performance.h" -#include "../../system.h" typedef struct { @@ -240,12 +239,11 @@ static bool ctr_csnd_audio_alive(void *data) static bool ctr_csnd_audio_start(void *data) { ctr_csnd_audio_t* ctr = (ctr_csnd_audio_t*)data; - rarch_system_info_t *system = rarch_system_info_get_ptr(); /* Prevents restarting audio when the menu * is toggled off on shutdown */ - if (system->shutdown) + if (runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL)) return true; #if 0 diff --git a/audio/drivers/ctr_dsp_audio.c b/audio/drivers/ctr_dsp_audio.c index 762dd271f4..616f20349a 100644 --- a/audio/drivers/ctr_dsp_audio.c +++ b/audio/drivers/ctr_dsp_audio.c @@ -19,7 +19,6 @@ #include "../audio_driver.h" #include "../../configuration.h" #include "../../performance.h" -#include "../../system.h" #include "../../ctr/ctr_debug.h" typedef struct @@ -164,12 +163,11 @@ static bool ctr_dsp_audio_alive(void *data) static bool ctr_dsp_audio_start(void *data) { ctr_dsp_audio_t* ctr = (ctr_dsp_audio_t*)data; - rarch_system_info_t *system = rarch_system_info_get_ptr(); /* Prevents restarting audio when the menu * is toggled off on shutdown */ - if (system->shutdown) + if (runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL)) return true; ndspSetMasterVol(1.0); diff --git a/dynamic.c b/dynamic.c index 41d1d8039f..0c5ba05e4f 100644 --- a/dynamic.c +++ b/dynamic.c @@ -767,7 +767,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) case RETRO_ENVIRONMENT_SHUTDOWN: RARCH_LOG("Environ SHUTDOWN.\n"); - system->shutdown = true; + runloop_ctl(RUNLOOP_CTL_SET_SHUTDOWN, NULL); runloop_ctl(RUNLOOP_CTL_SET_CORE_SHUTDOWN, NULL); break; diff --git a/frontend/drivers/platform_ps3.c b/frontend/drivers/platform_ps3.c index 9279885e44..4fcec26d18 100644 --- a/frontend/drivers/platform_ps3.c +++ b/frontend/drivers/platform_ps3.c @@ -81,12 +81,11 @@ static void callback_sysutil_exit(uint64_t status, case CELL_SYSUTIL_REQUEST_EXITGAME: { frontend_ctx_driver_t *frontend = frontend_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); - if (system) - system->shutdown = true; if (frontend) frontend->shutdown = frontend_ps3_shutdown; + + runloop_ctl(RUNLOOP_CTL_SET_SHUTDOWN, NULL); } break; } diff --git a/gfx/drivers_context/androidegl_ctx.c b/gfx/drivers_context/androidegl_ctx.c index edd9f2b07e..83c0cd5f1d 100644 --- a/gfx/drivers_context/androidegl_ctx.c +++ b/gfx/drivers_context/androidegl_ctx.c @@ -96,7 +96,6 @@ static void android_gfx_ctx_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { unsigned new_width, new_height; - rarch_system_info_t *system = rarch_system_info_get_ptr(); (void)frame_count; @@ -112,7 +111,7 @@ static void android_gfx_ctx_check_window(void *data, bool *quit, } /* Check if we are exiting. */ - if (system->shutdown) + if (runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL)) *quit = true; } diff --git a/gfx/drivers_context/bbqnx_ctx.c b/gfx/drivers_context/bbqnx_ctx.c index d64e4b6419..b14eb4995b 100644 --- a/gfx/drivers_context/bbqnx_ctx.c +++ b/gfx/drivers_context/bbqnx_ctx.c @@ -228,7 +228,6 @@ static void gfx_ctx_qnx_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { unsigned new_width, new_height; - rarch_system_info_t *system = rarch_system_info_get_ptr(); (void)data; (void)frame_count; @@ -244,7 +243,7 @@ static void gfx_ctx_qnx_check_window(void *data, bool *quit, } /* Check if we are exiting. */ - if (system->shutdown) + if (runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL)) *quit = true; } diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index c1920f316b..8477034256 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -31,7 +31,6 @@ #include "../../performance.h" #include "../../general.h" #include "../../driver.h" -#include "../../system.h" #define MAX_TOUCH 16 @@ -886,7 +885,6 @@ static void android_input_poll_memcpy(void *data) static void android_input_poll(void *data) { int ident; - rarch_system_info_t *system = rarch_system_info_get_ptr(); struct android_app *android_app = (struct android_app*)g_android; while ((ident = @@ -909,7 +907,7 @@ static void android_input_poll(void *data) if (android_app->destroyRequested != 0) { - system->shutdown = true; + runloop_ctl(RUNLOOP_CTL_SET_SHUTDOWN, NULL); return; } } @@ -919,7 +917,6 @@ static void android_input_poll(void *data) bool android_run_events(void *data) { - rarch_system_info_t *system = rarch_system_info_get_ptr(); struct android_app *android_app = (struct android_app*)g_android; if (ALooper_pollOnce(-1, NULL, NULL, NULL) == LOOPER_ID_MAIN) @@ -928,7 +925,7 @@ bool android_run_events(void *data) /* Check if we are exiting. */ if (android_app->destroyRequested != 0) { - system->shutdown = true; + runloop_ctl(RUNLOOP_CTL_SET_SHUTDOWN, NULL); return false; } diff --git a/input/drivers/qnx_input.c b/input/drivers/qnx_input.c index 2b55963265..c6e11056c5 100644 --- a/input/drivers/qnx_input.c +++ b/input/drivers/qnx_input.c @@ -586,7 +586,6 @@ static void qnx_handle_navigator_event( int rc; navigator_window_state_t state; bps_event_t *event_pause = NULL; - rarch_system_info_t *system = rarch_system_info_get_ptr(); (void)rc; @@ -617,7 +616,7 @@ static void qnx_handle_navigator_event( } else if (bps_event_get_code(event_pause) == NAVIGATOR_EXIT) { - system->shutdown = true; + runloop_ctl(RUNLOOP_CTL_SET_SHUTDOWN, NULL); break; } } diff --git a/menu/menu_driver.c b/menu/menu_driver.c index df54aff4d4..54c4f50778 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -322,7 +322,7 @@ void menu_driver_toggle(bool latch) } else { - if (!system->shutdown) + if (!runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL)) driver_set_nonblock_state(); if (settings && settings->menu.pause_libretro) diff --git a/retroarch.c b/retroarch.c index f5548a6eca..b051798b76 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1336,7 +1336,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) driver_t *driver = driver_get_ptr(); global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); switch(state) { @@ -1437,8 +1436,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) #endif break; case RARCH_CTL_QUIT: - if (global) - system->shutdown = true; + runloop_ctl(RUNLOOP_CTL_SET_SHUTDOWN, NULL); rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); break; case RARCH_CTL_FORCE_QUIT: diff --git a/runloop.c b/runloop.c index 1ba0fc5109..f0ad05ae64 100644 --- a/runloop.c +++ b/runloop.c @@ -357,6 +357,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) static bool runloop_idle = false; static bool runloop_exec = false; static bool runloop_slowmotion = false; + static bool runloop_shutdown_initiated = false; static bool runloop_core_shutdown_initiated = false; #ifdef HAVE_THREADS static slock_t *runloop_msg_queue_lock = NULL; @@ -790,6 +791,14 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) break; case RUNLOOP_CTL_IS_CORE_SHUTDOWN: return runloop_core_shutdown_initiated; + case RUNLOOP_CTL_SET_SHUTDOWN: + runloop_shutdown_initiated = true; + break; + case RUNLOOP_CTL_UNSET_SHUTDOWN: + runloop_shutdown_initiated = false; + break; + case RUNLOOP_CTL_IS_SHUTDOWN: + return runloop_shutdown_initiated; case RUNLOOP_CTL_SET_EXEC: runloop_exec = true; break; @@ -930,8 +939,7 @@ static void rarch_main_cmd_get_state( static INLINE int rarch_main_iterate_time_to_exit(bool quit_key_pressed) { settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); - bool time_to_exit = (system && system->shutdown) || quit_key_pressed; + bool time_to_exit = runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL) || quit_key_pressed; time_to_exit = time_to_exit || (video_driver_ctl(RARCH_DISPLAY_CTL_IS_ALIVE, NULL) == false); time_to_exit = time_to_exit || bsv_movie_ctl(BSV_MOVIE_CTL_END_EOF, NULL); time_to_exit = time_to_exit || runloop_ctl(RUNLOOP_CTL_IS_FRAME_COUNT_END, NULL); @@ -954,7 +962,7 @@ static INLINE int rarch_main_iterate_time_to_exit(bool quit_key_pressed) if (!runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL)) return -1; - system->shutdown = false; + runloop_ctl(RUNLOOP_CTL_UNSET_SHUTDOWN, NULL); runloop_ctl(RUNLOOP_CTL_UNSET_CORE_SHUTDOWN, NULL); return 0; diff --git a/runloop.h b/runloop.h index 500e76b2ba..9696fc706b 100644 --- a/runloop.h +++ b/runloop.h @@ -62,6 +62,9 @@ enum runloop_ctl_state RUNLOOP_CTL_SET_CORE_SHUTDOWN, RUNLOOP_CTL_UNSET_CORE_SHUTDOWN, RUNLOOP_CTL_IS_CORE_SHUTDOWN, + RUNLOOP_CTL_SET_SHUTDOWN, + RUNLOOP_CTL_UNSET_SHUTDOWN, + RUNLOOP_CTL_IS_SHUTDOWN, RUNLOOP_CTL_SET_EXEC, RUNLOOP_CTL_UNSET_EXEC, RUNLOOP_CTL_IS_EXEC, diff --git a/system.h b/system.h index 20fe8000d6..987ec07a91 100644 --- a/system.h +++ b/system.h @@ -31,7 +31,6 @@ typedef struct rarch_system_info struct retro_system_info info; unsigned rotation; - bool shutdown; unsigned performance_level; bool block_extract;