From 33f0f72adc67395aaa8351026e0c4c7d3f5d295f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 10 Feb 2016 04:30:33 +0100 Subject: [PATCH] Cleanups --- command_event.c | 24 ++++++++---------------- command_event.h | 4 ---- driver.h | 1 - retroarch.c | 39 +++++++++++++++++++++++---------------- 4 files changed, 31 insertions(+), 37 deletions(-) diff --git a/command_event.c b/command_event.c index ea3bad039b..a23330a04c 100644 --- a/command_event.c +++ b/command_event.c @@ -402,7 +402,10 @@ static void event_deinit_core(bool reinit) core_ctl(CORE_CTL_RETRO_DEINIT, NULL); if (reinit) - event_cmd_ctl(EVENT_CMD_DRIVERS_DEINIT, NULL); + { + int flags = DRIVERS_CMD_ALL; + driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags); + } /* auto overrides: reload the original config */ if (runloop_ctl(RUNLOOP_CTL_IS_OVERRIDES_ACTIVE, NULL)) @@ -1307,18 +1310,6 @@ bool event_cmd_ctl(enum event_command cmd, void *data) input_overlay_set_alpha_mod(settings->input.overlay_opacity); #endif break; - case EVENT_CMD_DRIVERS_DEINIT: - { - int flags = DRIVERS_CMD_ALL; - driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags); - } - break; - case EVENT_CMD_DRIVERS_INIT: - { - int flags = DRIVERS_CMD_ALL; - driver_ctl(RARCH_DRIVER_CTL_INIT, &flags); - } - break; case EVENT_CMD_AUDIO_REINIT: { int flags = DRIVER_AUDIO; @@ -1328,17 +1319,18 @@ bool event_cmd_ctl(enum event_command cmd, void *data) break; case EVENT_CMD_RESET_CONTEXT: { - /* EVENT_CMD_DRIVERS_DEINIT clears the callback struct so we + /* RARCH_DRIVER_CTL_UNINIT clears the callback struct so we * need to make sure to keep a copy */ struct retro_hw_render_callback hw_render; + int flags = DRIVERS_CMD_ALL; memcpy(&hw_render, video_driver_callback(), sizeof(hw_render)); - event_cmd_ctl(EVENT_CMD_DRIVERS_DEINIT, NULL); + driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags); memcpy(video_driver_callback(), &hw_render, sizeof(hw_render)); - event_cmd_ctl(EVENT_CMD_DRIVERS_INIT, NULL); + driver_ctl(RARCH_DRIVER_CTL_INIT, &flags); } break; case EVENT_CMD_QUIT_RETROARCH: diff --git a/command_event.h b/command_event.h index ddae7c7390..854931d30f 100644 --- a/command_event.h +++ b/command_event.h @@ -178,10 +178,6 @@ enum event_command EVENT_CMD_REMOTE_INIT, /* Deinitializes remote gamepad interface. */ EVENT_CMD_REMOTE_DEINIT, - /* Deinitializes drivers. */ - EVENT_CMD_DRIVERS_DEINIT, - /* Initializes drivers. */ - EVENT_CMD_DRIVERS_INIT, /* Reinitializes audio driver. */ EVENT_CMD_AUDIO_REINIT, /* Resizes windowed scale. Will reinitialize video driver. */ diff --git a/driver.h b/driver.h index 38d9b3f94c..47327400d3 100644 --- a/driver.h +++ b/driver.h @@ -83,7 +83,6 @@ extern "C" { #define GET_HAT_DIR(x) (x & HAT_MASK) #define GET_HAT(x) (x & (~HAT_MASK)) -/* Drivers for EVENT_CMD_DRIVERS_DEINIT and EVENT_CMD_DRIVERS_INIT */ #define DRIVERS_CMD_ALL \ ( DRIVER_AUDIO \ | DRIVER_VIDEO \ diff --git a/retroarch.c b/retroarch.c index 0dd0d08298..0129f63508 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1171,6 +1171,7 @@ bool rarch_game_options_validate(char *s, size_t len, bool mkdir) static int rarch_main_init(int argc, char *argv[]) { int sjlj_ret; + int flags = DRIVERS_CMD_ALL; bool *verbosity = NULL; init_state(); @@ -1251,7 +1252,7 @@ static int rarch_main_init(int argc, char *argv[]) if (!event_cmd_ctl(EVENT_CMD_CORE_INIT, ¤t_core_type)) goto error; - event_cmd_ctl(EVENT_CMD_DRIVERS_INIT, NULL); + driver_ctl(RARCH_DRIVER_CTL_INIT, &flags); event_cmd_ctl(EVENT_CMD_COMMAND_INIT, NULL); event_cmd_ctl(EVENT_CMD_REMOTE_INIT, NULL); event_cmd_ctl(EVENT_CMD_REWIND_INIT, NULL); @@ -1349,26 +1350,32 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) rarch_is_inited = true; break; case RARCH_CTL_DESTROY: - rarch_is_inited = false; - rarch_error_on_init = false; - rarch_block_config_read = false; - rarch_force_fullscreen = false; + { + int flags = DRIVERS_CMD_ALL; - runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_DRIVERS_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_LOG_FILE_DEINIT, NULL); + rarch_is_inited = false; + rarch_error_on_init = false; + rarch_block_config_read = false; + rarch_force_fullscreen = false; - runloop_ctl(RUNLOOP_CTL_STATE_FREE, NULL); - runloop_ctl(RUNLOOP_CTL_GLOBAL_FREE, NULL); - runloop_ctl(RUNLOOP_CTL_DATA_DEINIT, NULL); - config_free(); + runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_DEINIT, NULL); + driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags); + event_cmd_ctl(EVENT_CMD_LOG_FILE_DEINIT, NULL); + + runloop_ctl(RUNLOOP_CTL_STATE_FREE, NULL); + runloop_ctl(RUNLOOP_CTL_GLOBAL_FREE, NULL); + runloop_ctl(RUNLOOP_CTL_DATA_DEINIT, NULL); + config_free(); + } break; case RARCH_CTL_DEINIT: - if (!rarch_ctl(RARCH_CTL_IS_INITED, NULL)) - return false; + { + int flags = DRIVERS_CMD_ALL; + if (!rarch_ctl(RARCH_CTL_IS_INITED, NULL)) + return false; - event_cmd_ctl(EVENT_CMD_DRIVERS_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_DRIVERS_INIT, NULL); + driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags); + } break; case RARCH_CTL_PREINIT: if (!config_realloc())