diff --git a/command_event.c b/command_event.c index 888906d07a..b63288f18d 100644 --- a/command_event.c +++ b/command_event.c @@ -894,8 +894,8 @@ static bool event_update_system_info(struct retro_system_info *_info, libretro_get_system_info(settings->libretro, _info, load_no_content); #endif - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_GET, &core_info); - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &core_info_list); + core_info_ctl(CORE_INFO_CTL_CURRENT_CORE_GET, &core_info); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &core_info_list); if (!core_info_list) return false; @@ -1274,13 +1274,13 @@ bool event_cmd_ctl(enum event_command cmd, void *data) settings->content_history_size); break; case EVENT_CMD_CORE_INFO_DEINIT: - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_FREE, NULL); + core_info_ctl(CORE_INFO_CTL_LIST_DEINIT, NULL); break; case EVENT_CMD_CORE_INFO_INIT: event_cmd_ctl(EVENT_CMD_CORE_INFO_DEINIT, NULL); if (*settings->libretro_directory) - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_INIT, NULL); + core_info_ctl(CORE_INFO_CTL_LIST_INIT, NULL); break; case EVENT_CMD_CORE_DEINIT: { diff --git a/core_info.c b/core_info.c index b8c8861840..7750c12abf 100644 --- a/core_info.c +++ b/core_info.c @@ -484,7 +484,7 @@ bool core_info_does_support_file(const core_info_t *core, const char *path) const char *core_info_list_get_all_extensions(void) { core_info_list_t *list = NULL; - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); if (!list) return NULL; return list->all_ext; @@ -662,10 +662,29 @@ void core_info_list_get_missing_firmware( bool core_info_ctl(enum core_info_state state, void *data) { + static core_info_t *core_info_current = NULL; static core_info_list_t *core_info_curr_list = NULL; switch (state) { + case CORE_INFO_CTL_CURRENT_CORE_FREE: + if (core_info_current) + free(core_info_current); + core_info_current = NULL; + return true; + case CORE_INFO_CTL_CURRENT_CORE_INIT: + core_info_current = (core_info_t*)calloc(1, sizeof(core_info_t)); + if (!core_info_current) + return false; + return true; + case CORE_INFO_CTL_CURRENT_CORE_GET: + { + core_info_t **core = (core_info_t**)data; + if (!core) + return false; + *core = core_info_current; + } + return true; case CORE_INFO_CTL_LIST_DEINIT: if (core_info_curr_list) core_info_list_free(core_info_curr_list); diff --git a/core_info.h b/core_info.h index 4d4ccb8854..77c1509ae4 100644 --- a/core_info.h +++ b/core_info.h @@ -29,7 +29,10 @@ enum core_info_state CORE_INFO_CTL_NONE = 0, CORE_INFO_CTL_LIST_DEINIT, CORE_INFO_CTL_LIST_INIT, - CORE_INFO_CTL_LIST_GET + CORE_INFO_CTL_LIST_GET, + CORE_INFO_CTL_CURRENT_CORE_FREE, + CORE_INFO_CTL_CURRENT_CORE_INIT, + CORE_INFO_CTL_CURRENT_CORE_GET }; typedef struct diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 9939baf86f..6454f72b88 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -1068,7 +1068,7 @@ static void menu_action_setting_disp_set_label(file_list_t* list, char buf[PATH_MAX_LENGTH]; core_info_list_t *list = NULL; - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); if (core_info_list_get_display_name(list, s, buf, sizeof(buf))) strlcpy(s, buf, len); diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 2f6372e0ba..368eda4fe6 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -299,7 +299,7 @@ static int playlist_association_left(unsigned type, const char *label, const char *path = path_basename(label); core_info_list_t *list = NULL; - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); if (!list) return -1; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 6c77928154..25c907ee40 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -478,7 +478,7 @@ static int file_load_with_detect_core_wrapper(size_t idx, size_t entry_idx, fill_pathname_join(menu_path_new, menu->scratch2_buf, menu->scratch_buf, sizeof(menu_path_new)); - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); def_info.data = list; def_info.dir = menu_path_new; @@ -640,7 +640,7 @@ static int action_ok_playlist_entry(const char *path, bool found_associated_core = menu_playlist_find_associated_core( path_base, new_core_path, sizeof(new_core_path)); - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); if (!(core_info = core_info_find(list, new_core_path))) found_associated_core = false; @@ -2041,7 +2041,7 @@ static int action_ok_load_archive_detect_core(const char *path, if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &idx)) return false; - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); def_info.data = list; def_info.dir = menu_path; diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 174a1942b3..61c1416812 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -316,7 +316,7 @@ static int playlist_association_right(unsigned type, const char *label, const char *path = path_basename(label); core_info_list_t *list = NULL; - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); if (!list) return -1; diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index 43747659f1..c24a29a807 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -271,7 +271,7 @@ static int action_start_playlist_association(unsigned type, const char *label) settings_t *settings = config_get_ptr(); const char *path = path_basename(label); - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); if (!list) return -1; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 40851c66c2..0c54787be3 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1333,7 +1333,7 @@ static int mui_list_push(void *data, void *userdata, menu_hash_to_str(MENU_LABEL_LOAD_CONTENT), MENU_SETTING_ACTION, 0, 0); - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); if (core_info_list_num_info_files(list)) { menu_entries_push(info->list, diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 33b96e8151..38e3d11744 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -675,7 +675,7 @@ static int zarch_zui_render_lay_root_load(zui_t *zui, zui_tabbed_t *tabbed) if (!zui->load_dlist) { core_info_t *core_info = NULL; - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_GET, &core_info); + core_info_ctl(CORE_INFO_CTL_CURRENT_CORE_GET, &core_info); zui->load_dlist = dir_list_new(zui->load_cwd, core_info->supported_extensions, true, true); dir_list_sort(zui->load_dlist, true); @@ -752,7 +752,7 @@ static int zarch_zui_render_lay_root_load(zui_t *zui, zui_tabbed_t *tabbed) zui->pick_supported = 0; strncpy(zui->pick_content, path, sizeof(zui->pick_content)-1); - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); core_info_list_get_supported_cores(list, path, &zui->pick_cores, &zui->pick_supported); diff --git a/menu/menu_content.c b/menu/menu_content.c index ea936bed42..01f18ec32c 100644 --- a/menu/menu_content.c +++ b/menu/menu_content.c @@ -277,7 +277,7 @@ static bool menu_content_find_first_core(void *data) * going to use the current core to load this. */ if (menu_label_hash == MENU_LABEL_LOAD_CONTENT) { - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_GET, (void*)&info); + core_info_ctl(CORE_INFO_CTL_CURRENT_CORE_GET, (void*)&info); if (info) { RARCH_LOG("Use the current core (%s) to load this content...\n", diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 82aceb346d..7f3b4d92ae 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -163,7 +163,7 @@ static int menu_displaylist_parse_core_info(menu_displaylist_info_t *info) settings_t *settings = config_get_ptr(); core_info_t *core_info = NULL; - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_GET, &core_info); + core_info_ctl(CORE_INFO_CTL_CURRENT_CORE_GET, &core_info); if (!core_info || !core_info->config_data) { @@ -271,7 +271,7 @@ static int menu_displaylist_parse_core_info(menu_displaylist_info_t *info) { core_info_list_t *list = NULL; - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); core_info_list_update_missing_firmware(list, core_info->path, settings->system_directory); @@ -2194,7 +2194,7 @@ static int menu_displaylist_parse_generic(menu_displaylist_info_t *info, bool ho settings_t *settings = config_get_ptr(); uint32_t hash_label = menu_hash_calculate(info->label); - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); (void)device; @@ -2539,7 +2539,7 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) rarch_system_info_t *system = NULL; core_info_list_t *list = NULL; - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (menu_driver_list_push(info, type)) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 89a665611f..b26e613463 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -27,6 +27,7 @@ #include "menu_shader.h" #include "../content.h" +#include "../core_info.h" #include "../general.h" #include "../system.h" #include "../defaults.h" @@ -173,8 +174,8 @@ static void menu_free(menu_handle_t *menu) event_cmd_ctl(EVENT_CMD_HISTORY_DEINIT, NULL); - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_FREE, NULL); - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_FREE, NULL); + core_info_ctl(CORE_INFO_CTL_LIST_DEINIT, NULL); + core_info_ctl(CORE_INFO_CTL_CURRENT_CORE_FREE, NULL); free(menu); } @@ -233,7 +234,7 @@ static void *menu_init(const void *data) if (!menu_entries_ctl(MENU_ENTRIES_CTL_INIT, NULL)) goto error; - if (!runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_INIT, NULL)) + if (!core_info_ctl(CORE_INFO_CTL_CURRENT_CORE_INIT, NULL)) goto error; #ifdef HAVE_SHADER_MANAGER diff --git a/runloop.c b/runloop.c index 67a410c53e..6cf1084243 100644 --- a/runloop.c +++ b/runloop.c @@ -435,7 +435,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) #ifdef HAVE_THREADS static slock_t *runloop_msg_queue_lock = NULL; #endif - static core_info_t *core_info_current = NULL; static msg_queue_t *runloop_msg_queue = NULL; settings_t *settings = config_get_ptr(); @@ -487,30 +486,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) return true; case RUNLOOP_CTL_HAS_CORE_OPTIONS: return runloop_system.core_options; - case RUNLOOP_CTL_CURRENT_CORE_LIST_FREE: - return core_info_ctl(CORE_INFO_CTL_LIST_DEINIT, NULL); - case RUNLOOP_CTL_CURRENT_CORE_LIST_INIT: - return core_info_ctl(CORE_INFO_CTL_LIST_INIT, NULL); - case RUNLOOP_CTL_CURRENT_CORE_LIST_GET: - return core_info_ctl(CORE_INFO_CTL_LIST_GET, data); - case RUNLOOP_CTL_CURRENT_CORE_FREE: - if (core_info_current) - free(core_info_current); - core_info_current = NULL; - return true; - case RUNLOOP_CTL_CURRENT_CORE_INIT: - core_info_current = (core_info_t*)calloc(1, sizeof(core_info_t)); - if (!core_info_current) - return false; - return true; - case RUNLOOP_CTL_CURRENT_CORE_GET: - { - core_info_t **core = (core_info_t**)data; - if (!core) - return false; - *core = core_info_current; - } - return true; case RUNLOOP_CTL_SYSTEM_INFO_GET: { rarch_system_info_t **system = (rarch_system_info_t**)data; diff --git a/runloop.h b/runloop.h index 55143692e0..1142e65659 100644 --- a/runloop.h +++ b/runloop.h @@ -72,12 +72,6 @@ enum runloop_ctl_state RUNLOOP_CTL_SET_PERFCNT_ENABLE, RUNLOOP_CTL_UNSET_PERFCNT_ENABLE, RUNLOOP_CTL_IS_PERFCNT_ENABLE, - RUNLOOP_CTL_CURRENT_CORE_LIST_FREE, - RUNLOOP_CTL_CURRENT_CORE_LIST_INIT, - RUNLOOP_CTL_CURRENT_CORE_LIST_GET, - RUNLOOP_CTL_CURRENT_CORE_FREE, - RUNLOOP_CTL_CURRENT_CORE_INIT, - RUNLOOP_CTL_CURRENT_CORE_GET, RUNLOOP_CTL_FRONTEND_KEY_EVENT_GET, RUNLOOP_CTL_KEY_EVENT_GET, RUNLOOP_CTL_DATA_DEINIT, diff --git a/string_list_special.c b/string_list_special.c index bdbfcbcdf4..aafa30f9b2 100644 --- a/string_list_special.c +++ b/string_list_special.c @@ -152,7 +152,7 @@ struct string_list *string_list_new_special(enum string_list_type type, } break; case STRING_LIST_SUPPORTED_CORES_PATHS: - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &core_info_list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &core_info_list); core_info_list_get_supported_cores(core_info_list, (const char*)data, &core_info, list_size); @@ -174,7 +174,7 @@ struct string_list *string_list_new_special(enum string_list_type type, } break; case STRING_LIST_CORES_PATHS: - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &core_info_list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &core_info_list); for (i = 0; i < core_info_list_num_info_files(core_info_list); i++) { @@ -190,7 +190,7 @@ struct string_list *string_list_new_special(enum string_list_type type, } break; case STRING_LIST_SUPPORTED_CORES_NAMES: - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &core_info_list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &core_info_list); core_info_list_get_supported_cores(core_info_list, (const char*)data, &core_info, list_size); @@ -211,7 +211,7 @@ struct string_list *string_list_new_special(enum string_list_type type, } break; case STRING_LIST_CORES_NAMES: - runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &core_info_list); + core_info_ctl(CORE_INFO_CTL_LIST_GET, &core_info_list); for (i = 0; i < core_info_list_num_info_files(core_info_list); i++) { const char *opt = NULL;