retroarch: Refactor retroarch_main_init core initialization failure handling

This commit is contained in:
Sebastien Ronsse 2016-07-19 14:27:46 +10:00
parent 88c767fee9
commit 21a82e3622

View File

@ -1272,7 +1272,8 @@ static void retroarch_validate_cpu_features(void)
**/ **/
bool retroarch_main_init(int argc, char *argv[]) bool retroarch_main_init(int argc, char *argv[])
{ {
bool menu_alive = false; bool menu_alive;
bool init_failed;
retroarch_init_state(); retroarch_init_state();
@ -1350,26 +1351,37 @@ bool retroarch_main_init(int argc, char *argv[])
driver_ctl(RARCH_DRIVER_CTL_INIT_PRE, NULL); driver_ctl(RARCH_DRIVER_CTL_INIT_PRE, NULL);
#ifdef HAVE_MENU #ifdef HAVE_MENU
/* Check if menu is active */
menu_alive = menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL); menu_alive = menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL);
#endif #endif
/* Attempt to initialize core */
init_failed = false;
if (current_core_explicitly_set) if (current_core_explicitly_set)
{ {
current_core_explicitly_set = false; current_core_explicitly_set = false;
if (!command_event(CMD_EVENT_CORE_INIT, &explicit_current_core_type)) if (!command_event(CMD_EVENT_CORE_INIT, &explicit_current_core_type))
{ init_failed = true;
if (!menu_alive)
goto error;
current_core_type = CORE_TYPE_DUMMY;
command_event(CMD_EVENT_CORE_INIT, &current_core_type);
}
} }
else if (!command_event(CMD_EVENT_CORE_INIT, &current_core_type)) else if (!command_event(CMD_EVENT_CORE_INIT, &current_core_type))
{ init_failed = true;
if (!menu_alive)
goto error; /* Handle core initialization failure */
current_core_type = CORE_TYPE_DUMMY; if (init_failed) {
command_event(CMD_EVENT_CORE_INIT, &current_core_type); #ifdef HAVE_MENU
/* Check if menu was active prior to core initialization */
if (menu_alive) {
/* Attemot initializing dummy core */
current_core_type = CORE_TYPE_DUMMY;
if (!command_event(CMD_EVENT_CORE_INIT, &current_core_type))
goto error;
} else {
/* Fall back to regular error handling */
goto error;
}
#else
goto error;
#endif
} }
driver_ctl(RARCH_DRIVER_CTL_INIT_ALL, NULL); driver_ctl(RARCH_DRIVER_CTL_INIT_ALL, NULL);