From 0b5118423d759b1231d8838c8966a373a1dc27db Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 21 Feb 2017 04:07:40 +0100 Subject: [PATCH] Create task_push_content_load_nothing_with_new_core_from_menu --- menu/cbs/menu_cbs_ok.c | 18 +++++--- tasks/task_content.c | 68 +++++++++++++++---------------- tasks/task_netplay_find_content.c | 3 +- tasks/tasks_internal.h | 9 +++- 4 files changed, 53 insertions(+), 45 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 8ee2070a7e..57d40e045b 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1076,15 +1076,21 @@ static int generic_action_ok(const char *path, } break; case ACTION_OK_LOAD_CORE: - flush_type = MENU_SETTINGS; - - if (generic_action_ok_file_load(action_path, - NULL, CORE_TYPE_PLAIN, - CONTENT_MODE_LOAD_NOTHING_WITH_NEW_CORE_FROM_MENU) == 0) { + content_ctx_info_t content_info = {0}; + + flush_type = MENU_SETTINGS; + + if (!task_push_content_load_nothing_with_new_core_from_menu( + action_path, NULL, + &content_info, + CORE_TYPE_PLAIN, + NULL, NULL)) + { #ifndef HAVE_DYNAMIC - ret = -1; + ret = -1; #endif + } } break; case ACTION_OK_LOAD_CONFIG_FILE: diff --git a/tasks/task_content.c b/tasks/task_content.c index 6c4209f661..e7f234f0b9 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1256,6 +1256,36 @@ error: return false; } +bool task_push_content_load_nothing_with_new_core_from_menu( + const char *core_path, + const char *fullpath, + content_ctx_info_t *content_info, + enum rarch_core_type type, + retro_task_callback_t cb, + void *user_data) +{ + if (!content_info) + return false; + + /* Set libretro core path */ + runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, (void*)core_path); + + /* Load core */ + command_event(CMD_EVENT_LOAD_CORE, NULL); + +#ifndef HAVE_DYNAMIC + /* Fork core? */ + if (!frontend_driver_set_fork(FRONTEND_FORK_CORE)) + return false; +#endif + + /* Preliminary stuff that has to be done before we + * load the actual content. Can differ per mode. */ + retroarch_set_current_core_type(type, true); + + return true; +} + bool task_push_content_load_default( const char *core_path, const char *fullpath, @@ -1297,7 +1327,6 @@ bool task_push_content_load_default( /* First we determine if we are loading from a menu */ switch (mode) { - case CONTENT_MODE_LOAD_NOTHING_WITH_NEW_CORE_FROM_MENU: #if defined(HAVE_VIDEO_PROCESSOR) case CONTENT_MODE_LOAD_NOTHING_WITH_VIDEO_PROCESSOR_CORE_FROM_MENU: #endif @@ -1366,7 +1395,6 @@ bool task_push_content_load_default( /* Set libretro core path */ switch (mode) { - case CONTENT_MODE_LOAD_NOTHING_WITH_NEW_CORE_FROM_MENU: case CONTENT_MODE_LOAD_CONTENT_WITH_NEW_CORE_FROM_MENU: case CONTENT_MODE_LOAD_CONTENT_WITH_NEW_CORE_FROM_COMPANION_UI: runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, (void*)core_path); @@ -1378,7 +1406,6 @@ bool task_push_content_load_default( /* Load core */ switch (mode) { - case CONTENT_MODE_LOAD_NOTHING_WITH_NEW_CORE_FROM_MENU: #ifdef HAVE_DYNAMIC case CONTENT_MODE_LOAD_CONTENT_WITH_NEW_CORE_FROM_MENU: case CONTENT_MODE_LOAD_CONTENT_WITH_NEW_CORE_FROM_COMPANION_UI: @@ -1389,26 +1416,10 @@ bool task_push_content_load_default( break; } -#ifndef HAVE_DYNAMIC - /* Fork core? */ - switch (mode) - { - case CONTENT_MODE_LOAD_NOTHING_WITH_NEW_CORE_FROM_MENU: - if (!frontend_driver_set_fork(FRONTEND_FORK_CORE)) - goto cleanup; - break; - default: - break; - } -#endif - /* Preliminary stuff that has to be done before we * load the actual content. Can differ per mode. */ switch (mode) { - case CONTENT_MODE_LOAD_NOTHING_WITH_NEW_CORE_FROM_MENU: - retroarch_set_current_core_type(type, true); - break; case CONTENT_MODE_LOAD_NOTHING_WITH_NET_RETROPAD_CORE_FROM_MENU: #if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) retroarch_set_current_core_type(CORE_TYPE_NETRETROPAD, true); @@ -1465,17 +1476,10 @@ bool task_push_content_load_default( } /* Push quick menu onto menu stack */ - switch (mode) - { - case CONTENT_MODE_LOAD_NOTHING_WITH_NEW_CORE_FROM_MENU: - break; - default: #ifdef HAVE_MENU - if (type != CORE_TYPE_DUMMY && mode != CONTENT_MODE_LOAD_FROM_CLI) - menu_driver_ctl(RARCH_MENU_CTL_SET_PENDING_QUICK_MENU, NULL); + if (type != CORE_TYPE_DUMMY && mode != CONTENT_MODE_LOAD_FROM_CLI) + menu_driver_ctl(RARCH_MENU_CTL_SET_PENDING_QUICK_MENU, NULL); #endif - break; - } if (content_ctx.directory_system) free(content_ctx.directory_system); @@ -1517,14 +1521,6 @@ skip: RARCH_LOG("Load content blocked. Reason: %s\n", msg_hash_to_str(MSG_FIRMWARE)); return true; - -#ifndef HAVE_DYNAMIC -cleanup: - if (content_ctx.directory_system) - free(content_ctx.directory_system); - - return false; -#endif } void content_get_status( diff --git a/tasks/task_netplay_find_content.c b/tasks/task_netplay_find_content.c index 2eebe83789..2e7cb004be 100644 --- a/tasks/task_netplay_find_content.c +++ b/tasks/task_netplay_find_content.c @@ -75,11 +75,10 @@ static void netplay_crc_scan_callback(void *task_data, content_ctx_info_t content_info = {0}; command_event(CMD_EVENT_NETPLAY_INIT_DIRECT_DEFERRED, state->hostname); - task_push_content_load_default( + task_push_content_load_nothing_with_new_core_from_menu( state->core_path, NULL, &content_info, CORE_TYPE_PLAIN, - CONTENT_MODE_LOAD_NOTHING_WITH_NEW_CORE_FROM_MENU, NULL, NULL); task_push_content_load_nothing_with_current_core_from_menu(&content_info); diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index d66b5c0470..0473533fb6 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -40,7 +40,6 @@ enum content_mode_load { CONTENT_MODE_LOAD_NONE = 0, CONTENT_MODE_LOAD_FROM_CLI, - CONTENT_MODE_LOAD_NOTHING_WITH_NEW_CORE_FROM_MENU, CONTENT_MODE_LOAD_NOTHING_WITH_NET_RETROPAD_CORE_FROM_MENU, CONTENT_MODE_LOAD_NOTHING_WITH_VIDEO_PROCESSOR_CORE_FROM_MENU, CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_MENU, @@ -143,6 +142,14 @@ bool task_push_decompress( retro_task_callback_t cb, void *user_data); +bool task_push_content_load_nothing_with_new_core_from_menu( + const char *core_path, + const char *fullpath, + content_ctx_info_t *content_info, + enum rarch_core_type type, + retro_task_callback_t cb, + void *user_data); + bool task_push_content_load_nothing_with_current_core_from_menu(content_ctx_info_t *content_info); bool task_push_content_load_nothing_with_dummy_core(content_ctx_info_t *content_info);