From df3b090d7a6e7a546d2e3d59f80890c60e631567 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 09:37:21 +0200 Subject: [PATCH] Revert "Create runloop_get_system_info/runloop_free_system_info/runloop_init_system_info" This reverts commit 35bf38e05cfbaa3ed4efbfdfd2afdcedc2c57b8a. --- command.c | 12 ++-- configuration.c | 4 +- content.c | 4 +- dynamic.c | 6 +- frontend/frontend.c | 2 +- gfx/video_driver.c | 2 +- location/location_driver.c | 4 +- menu/cbs/menu_cbs_deferred_push.c | 3 +- menu/cbs/menu_cbs_get_value.c | 6 +- menu/cbs/menu_cbs_ok.c | 2 +- menu/drivers/materialui.c | 2 +- menu/menu_displaylist.c | 6 +- menu/menu_entries.c | 2 +- menu/menu_setting.c | 12 ++-- network/netplay_common.c | 2 +- retroarch.c | 28 ++++----- runloop.c | 98 +++++++++++++++---------------- runloop.h | 12 ++-- 18 files changed, 97 insertions(+), 110 deletions(-) diff --git a/command.c b/command.c index d19de50906..57762309db 100644 --- a/command.c +++ b/command.c @@ -733,7 +733,7 @@ static void command_event_disk_control_set_eject(bool new_state, bool print_log) rarch_system_info_t *info = NULL; const struct retro_disk_control_callback *control = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (info) control = (const struct retro_disk_control_callback*)&info->disk_control_cb; @@ -781,7 +781,7 @@ static void command_event_disk_control_set_index(unsigned idx) rarch_system_info_t *info = NULL; const struct retro_disk_control_callback *control = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (info) control = (const struct retro_disk_control_callback*)&info->disk_control_cb; @@ -838,7 +838,7 @@ static bool command_event_disk_control_append_image(const char *path) const struct retro_disk_control_callback *control = NULL; rarch_system_info_t *sysinfo = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sysinfo); if (sysinfo) control = (const struct retro_disk_control_callback*) @@ -983,7 +983,7 @@ static void command_event_init_controllers(void) settings_t *settings = config_get_ptr(); rarch_system_info_t *info = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); for (i = 0; i < MAX_USERS; i++) { @@ -1236,7 +1236,7 @@ static bool command_event_init_core(enum rarch_core_type *data) if (!core_init_symbols(data)) return false; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_INIT, NULL); /* auto overrides: apply overrides */ if(settings->auto_overrides_enable) @@ -1591,7 +1591,7 @@ bool command_event(enum event_command cmd, void *data) settings_t *settings = config_get_ptr(); rarch_system_info_t *info = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); (void)i; diff --git a/configuration.c b/configuration.c index 3767670826..2adf63d908 100644 --- a/configuration.c +++ b/configuration.c @@ -1965,7 +1965,7 @@ bool config_load_override(void) settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (system) core_name = system->info.library_name; @@ -2143,7 +2143,7 @@ bool config_load_remap(void) settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (system) core_name = system->info.library_name; diff --git a/content.c b/content.c index 026d25415c..7804333047 100644 --- a/content.c +++ b/content.c @@ -1329,7 +1329,7 @@ static bool load_content_from_compressed_archive( settings_t *settings = config_get_ptr(); rarch_system_info_t *sys_info= NULL; - runloop_get_system_info((void**)sys_info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sys_info); if (sys_info && sys_info->info.block_extract) return true; @@ -1648,7 +1648,7 @@ static bool content_file_init(struct string_list *temporary_content) rarch_system_info_t *system = NULL; global_t *global = global_get_ptr(); - runloop_get_system_info((void**)system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (*global->subsystem) { diff --git a/dynamic.c b/dynamic.c index e2297bcd4b..edefb1fd1c 100644 --- a/dynamic.c +++ b/dynamic.c @@ -578,9 +578,7 @@ void uninit_libretro_sym(struct retro_core_t *current_core) memset(current_core, 0, sizeof(struct retro_core_t)); runloop_ctl(RUNLOOP_CTL_CORE_OPTIONS_DEINIT, NULL); - - runloop_free_system_info(); - + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_FREE, NULL); runloop_ctl(RUNLOOP_CTL_FRAME_TIME_FREE, NULL); camera_driver_ctl(RARCH_CAMERA_CTL_UNSET_ACTIVE, NULL); location_driver_ctl(RARCH_LOCATION_CTL_UNSET_ACTIVE, NULL); @@ -742,7 +740,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) global_t *global = global_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (ignore_environment_cb) return false; diff --git a/frontend/frontend.c b/frontend/frontend.c index 24f5ae7c3c..3708bb64d9 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -130,7 +130,7 @@ int rarch_main(int argc, char *argv[], void *data) return 0; } - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); if (content_is_inited() || content_does_not_need_content()) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 3c380cd5e4..7af875e3e4 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -598,7 +598,7 @@ static bool init_video(void) struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); init_video_filter(video_driver_state.pix_fmt); command_event(CMD_EVENT_SHADER_DIR_INIT, NULL); diff --git a/location/location_driver.c b/location/location_driver.c index e8cec5b048..4921fb1a92 100644 --- a/location/location_driver.c +++ b/location/location_driver.c @@ -203,7 +203,7 @@ void init_location(void) { rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); /* Resource leaks will follow if location interface is initialized twice. */ if (location_data) @@ -227,7 +227,7 @@ static void uninit_location(void) { rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (location_data && location_driver) { diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 8c7dd23034..afa343df23 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -345,8 +345,7 @@ static int general_push(menu_displaylist_info_t *info, core_info_get_list(&list); menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system_menu); - - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); switch (id) { diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 8e6a569801..6ab52e6106 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -778,8 +778,7 @@ static void menu_action_setting_disp_set_label_menu_disk_index( rarch_system_info_t *system = NULL; struct retro_disk_control_callback *control = NULL; - runloop_get_system_info((void**)&system); - + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!system) return; @@ -1165,8 +1164,7 @@ static void menu_action_setting_disp_set_label_core_option_create( rarch_system_info_t *system = NULL; global_t *global = global_get_ptr(); - runloop_get_system_info((void**)&system); - + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!system) return; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 5f61e41dc8..c9d9a25328 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1013,7 +1013,7 @@ static int generic_action_ok_remap_file_save(const char *path, const char *game_name = NULL; const char *core_name = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (info) core_name = info->info.library_name; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 0290b56631..49c88ed897 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -685,7 +685,7 @@ static int mui_get_core_title(char *s, size_t len) core_name = system->library_name; core_version = system->library_version; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (!settings->menu.core_enable) return -1; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 5b8aa3bc3d..66fdcd1c7f 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2157,7 +2157,7 @@ static int menu_displaylist_parse_load_content_settings( { rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); menu_entries_add(info->list, menu_hash_to_str(MENU_LABEL_VALUE_RESUME_CONTENT), @@ -2518,7 +2518,7 @@ static int menu_displaylist_parse_options_remappings( if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return -1; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); for (p = 0; p < settings->input.max_users; p++) { @@ -3326,7 +3326,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) case DISPLAYLIST_MAIN_MENU: { rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) menu_displaylist_parse_settings(menu, info, diff --git a/menu/menu_entries.c b/menu/menu_entries.c index f79da5fb0e..9b430e2c26 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -448,7 +448,7 @@ int menu_entries_get_core_title(char *s, size_t len) core_name = system->library_name; core_version = system->library_version; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (!settings->menu.core_enable) return -1; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index d6b69d3307..0959b2ccc7 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1068,7 +1068,7 @@ static void setting_get_string_representation_uint_libretro_device(void *data, settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!setting) return; @@ -2290,7 +2290,7 @@ static int setting_action_start_libretro_device_type(void *data) settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (setting_generic_action_start_default(setting) != 0) return -1; @@ -2440,7 +2440,7 @@ static int setting_action_left_libretro_device_type( settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!setting) return -1; @@ -2505,7 +2505,7 @@ static int setting_action_right_libretro_device_type( settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!setting) return -1; @@ -2888,7 +2888,7 @@ void general_write_handler(void *data) uint32_t hash = setting ? menu_hash_calculate(setting->name) : 0; uint64_t flags = menu_setting_get_flags(setting); - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!setting) return; @@ -3238,7 +3238,7 @@ static bool setting_append_list_input_player_options( (user == 0) ? retro_keybinds_1 : retro_keybinds_rest; rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); snprintf(buffer[user], sizeof(buffer[user]), "%s %u", menu_hash_to_str(MENU_VALUE_USER), user + 1); diff --git a/network/netplay_common.c b/network/netplay_common.c index 40b2e3b853..f6bc3deb0b 100644 --- a/network/netplay_common.c +++ b/network/netplay_common.c @@ -169,7 +169,7 @@ uint32_t np_impl_magic(void) api = api_info.version; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (info) lib = info->info.library_name; diff --git a/retroarch.c b/retroarch.c index 4fcdae0caf..f4c5fb3ba5 100644 --- a/retroarch.c +++ b/retroarch.c @@ -412,8 +412,7 @@ static void retroarch_set_paths_redirect(const char *path) settings_t *settings = config_get_ptr(); rarch_system_info_t *info = NULL; - runloop_get_system_info((void**)&info); - + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (!global) { RARCH_WARN("retroarch_set_paths_redirect was sent a NULL \"global\" pointer."); @@ -1067,9 +1066,9 @@ static void retroarch_parse_input(int argc, char *argv[]) static void retroarch_init_savefile_paths(void) { global_t *global = global_get_ptr(); - rarch_system_info_t *info = NULL; + rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); command_event(CMD_EVENT_SAVEFILES_DEINIT, NULL); @@ -1081,15 +1080,14 @@ static void retroarch_init_savefile_paths(void) /* For subsystems, we know exactly which RAM types are supported. */ unsigned i, j; - const struct retro_subsystem_info *subsystem_info = + const struct retro_subsystem_info *info = libretro_find_subsystem_info( - info->subsystem.data, - info->subsystem.size, + system->subsystem.data, + system->subsystem.size, global->subsystem); /* We'll handle this error gracefully later. */ - unsigned num_content = MIN(info - ? subsystem_info->num_roms : 0, + unsigned num_content = MIN(info ? info->num_roms : 0, global->subsystem_fullpaths ? global->subsystem_fullpaths->size : 0); @@ -1097,14 +1095,14 @@ static void retroarch_init_savefile_paths(void) for (i = 0; i < num_content; i++) { - for (j = 0; j < subsystem_info->roms[i].num_memory; j++) + for (j = 0; j < info->roms[i].num_memory; j++) { union string_list_elem_attr attr; char path[PATH_MAX_LENGTH] = {0}; char ext[32] = {0}; const struct retro_subsystem_memory_info *mem = (const struct retro_subsystem_memory_info*) - &subsystem_info->roms[i].memory[j]; + &info->roms[i].memory[j]; snprintf(ext, sizeof(ext), ".%s", mem->extension); @@ -1174,12 +1172,12 @@ bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) const char *game_name = NULL; global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); - rarch_system_info_t *info = NULL; + rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); - if (info) - core_name = info->info.library_name; + if (system) + core_name = system->info.library_name; if (global) game_name = path_basename(global->name.base); diff --git a/runloop.c b/runloop.c index 4d75054087..ce0f8f18a4 100644 --- a/runloop.c +++ b/runloop.c @@ -740,57 +740,6 @@ bool runloop_prepare_dummy(void) return true; } -bool runloop_get_system_info(void **data) -{ - rarch_system_info_t **system = (rarch_system_info_t**)data; - if (!system) - return false; - *system = &runloop_system; - return true; -} - -void runloop_init_system_info(void) -{ - core_get_system_info(&runloop_system.info); - - if (!runloop_system.info.library_name) - runloop_system.info.library_name = msg_hash_to_str(MSG_UNKNOWN); - if (!runloop_system.info.library_version) - runloop_system.info.library_version = "v0"; - - video_driver_set_title_buf(); - - strlcpy(runloop_system.valid_extensions, - runloop_system.info.valid_extensions ? - runloop_system.info.valid_extensions : DEFAULT_EXT, - sizeof(runloop_system.valid_extensions)); -} - -void runloop_free_system_info(void) -{ - /* No longer valid. */ - if (runloop_system.subsystem.data) - free(runloop_system.subsystem.data); - runloop_system.subsystem.data = NULL; - runloop_system.subsystem.size = 0; - - if (runloop_system.ports.data) - free(runloop_system.ports.data); - runloop_system.ports.data = NULL; - runloop_system.ports.size = 0; - - if (runloop_system.mmaps.descriptors) - free((void *)runloop_system.mmaps.descriptors); - runloop_system.mmaps.descriptors = NULL; - runloop_system.mmaps.num_descriptors = 0; - - runloop_key_event = NULL; - runloop_frontend_key_event = NULL; - - audio_driver_unset_callback(); - memset(&runloop_system, 0, sizeof(rarch_system_info_t)); -} - bool runloop_ctl(enum runloop_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); @@ -802,6 +751,21 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) break; case RUNLOOP_CTL_SHADER_DIR_INIT: return shader_dir_init(&runloop_shader_dir); + case RUNLOOP_CTL_SYSTEM_INFO_INIT: + core_get_system_info(&runloop_system.info); + + if (!runloop_system.info.library_name) + runloop_system.info.library_name = msg_hash_to_str(MSG_UNKNOWN); + if (!runloop_system.info.library_version) + runloop_system.info.library_version = "v0"; + + video_driver_set_title_buf(); + + strlcpy(runloop_system.valid_extensions, + runloop_system.info.valid_extensions ? + runloop_system.info.valid_extensions : DEFAULT_EXT, + sizeof(runloop_system.valid_extensions)); + break; case RUNLOOP_CTL_GET_CORE_OPTION_SIZE: { unsigned *idx = (unsigned*)data; @@ -820,6 +784,38 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) *coreopts = runloop_core_options; } break; + case RUNLOOP_CTL_SYSTEM_INFO_GET: + { + rarch_system_info_t **system = (rarch_system_info_t**)data; + if (!system) + return false; + *system = &runloop_system; + } + break; + case RUNLOOP_CTL_SYSTEM_INFO_FREE: + + /* No longer valid. */ + if (runloop_system.subsystem.data) + free(runloop_system.subsystem.data); + runloop_system.subsystem.data = NULL; + runloop_system.subsystem.size = 0; + + if (runloop_system.ports.data) + free(runloop_system.ports.data); + runloop_system.ports.data = NULL; + runloop_system.ports.size = 0; + + if (runloop_system.mmaps.descriptors) + free((void *)runloop_system.mmaps.descriptors); + runloop_system.mmaps.descriptors = NULL; + runloop_system.mmaps.num_descriptors = 0; + + runloop_key_event = NULL; + runloop_frontend_key_event = NULL; + + audio_driver_unset_callback(); + memset(&runloop_system, 0, sizeof(rarch_system_info_t)); + break; case RUNLOOP_CTL_SET_FRAME_TIME_LAST: runloop_frame_time_last_enable = true; break; diff --git a/runloop.h b/runloop.h index d92643b929..3c7f5ad9b6 100644 --- a/runloop.h +++ b/runloop.h @@ -99,7 +99,10 @@ enum runloop_ctl_state RUNLOOP_CTL_CORE_OPTIONS_DEINIT, RUNLOOP_CTL_CORE_OPTIONS_FREE, RUNLOOP_CTL_SHADER_DIR_DEINIT, - RUNLOOP_CTL_SHADER_DIR_INIT + RUNLOOP_CTL_SHADER_DIR_INIT, + RUNLOOP_CTL_SYSTEM_INFO_GET, + RUNLOOP_CTL_SYSTEM_INFO_INIT, + RUNLOOP_CTL_SYSTEM_INFO_FREE }; typedef int (*transfer_cb_t)(void *data, size_t len); @@ -293,14 +296,9 @@ char* runloop_msg_queue_pull(void); bool runloop_prepare_dummy(void); -void runloop_init_system_info(void); - -void runloop_free_system_info(void); - -bool runloop_get_system_info(void **data); - bool runloop_ctl(enum runloop_ctl_state state, void *data); + #ifdef __cplusplus } #endif