mirror of
https://github.com/libretro/RetroArch
synced 2025-04-07 13:23:32 +00:00
Create rarch_main_iterate_time_to_exit
This commit is contained in:
parent
d4a8d97ed3
commit
c9a0a48448
92
runloop.c
92
runloop.c
@ -825,6 +825,55 @@ static void rarch_main_cmd_get_state(driver_t *driver,
|
|||||||
RARCH_CHEAT_TOGGLE);
|
RARCH_CHEAT_TOGGLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Time to exit out of the main loop?
|
||||||
|
* Reasons for exiting:
|
||||||
|
* a) Shutdown environment callback was invoked.
|
||||||
|
* b) Quit key was pressed.
|
||||||
|
* c) Frame count exceeds or equals maximum amount of frames to run.
|
||||||
|
* d) Video driver no longer alive.
|
||||||
|
* e) End of BSV movie and BSV EOF exit is true. (TODO/FIXME - explain better)
|
||||||
|
*/
|
||||||
|
static INLINE int rarch_main_iterate_time_to_exit(event_cmd_state_t *cmd)
|
||||||
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
global_t *global = global_get_ptr();
|
||||||
|
driver_t *driver = driver_get_ptr();
|
||||||
|
rarch_system_info_t *system = rarch_system_info_get_ptr();
|
||||||
|
video_driver_t *video = driver ? (video_driver_t*)driver->video : NULL;
|
||||||
|
bool shutdown_pressed = (system && system->shutdown) || cmd->quit_key_pressed;
|
||||||
|
bool video_alive = video && video->alive(driver->video_data);
|
||||||
|
bool movie_end = (global->bsv.movie_end && global->bsv.eof_exit);
|
||||||
|
uint64_t *frame_count = video_driver_get_frame_count();
|
||||||
|
bool frame_count_end = main_max_frames && (*frame_count >= main_max_frames);
|
||||||
|
|
||||||
|
if (shutdown_pressed || frame_count_end || movie_end || !video_alive || global->exec)
|
||||||
|
{
|
||||||
|
if (global->exec)
|
||||||
|
global->exec = false;
|
||||||
|
|
||||||
|
/* Quits out of RetroArch main loop.
|
||||||
|
* On special case, loads dummy core
|
||||||
|
* instead of exiting RetroArch completely.
|
||||||
|
* Aborts core shutdown if invoked.
|
||||||
|
*/
|
||||||
|
if (global->core_shutdown_initiated
|
||||||
|
&& settings->load_dummy_on_core_shutdown)
|
||||||
|
{
|
||||||
|
if (!event_command(EVENT_CMD_PREPARE_DUMMY))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
system->shutdown = false;
|
||||||
|
global->core_shutdown_initiated = false;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rarch_main_iterate:
|
* rarch_main_iterate:
|
||||||
*
|
*
|
||||||
@ -835,6 +884,7 @@ static void rarch_main_cmd_get_state(driver_t *driver,
|
|||||||
**/
|
**/
|
||||||
int rarch_main_iterate(unsigned *sleep_ms)
|
int rarch_main_iterate(unsigned *sleep_ms)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
retro_input_t trigger_input;
|
retro_input_t trigger_input;
|
||||||
event_cmd_state_t cmd;
|
event_cmd_state_t cmd;
|
||||||
@ -920,47 +970,11 @@ int rarch_main_iterate(unsigned *sleep_ms)
|
|||||||
rarch_main_iterate_linefeed_overlay(driver, settings);
|
rarch_main_iterate_linefeed_overlay(driver, settings);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
ret = rarch_main_iterate_time_to_exit(&cmd);
|
||||||
/* Time to exit out of the main loop?
|
|
||||||
* Reasons for exiting:
|
|
||||||
* a) Shutdown environment callback was invoked.
|
|
||||||
* b) Quit key was pressed.
|
|
||||||
* c) Frame count exceeds or equals maximum amount of frames to run.
|
|
||||||
* d) Video driver no longer alive.
|
|
||||||
* e) End of BSV movie and BSV EOF exit is true. (TODO/FIXME - explain better)
|
|
||||||
*/
|
|
||||||
video_driver_t *video = driver ? (video_driver_t*)driver->video : NULL;
|
|
||||||
bool shutdown_pressed = (system && system->shutdown) || cmd.quit_key_pressed;
|
|
||||||
bool video_alive = video && video->alive(driver->video_data);
|
|
||||||
bool movie_end = (global->bsv.movie_end && global->bsv.eof_exit);
|
|
||||||
uint64_t *frame_count = video_driver_get_frame_count();
|
|
||||||
bool frame_count_end = main_max_frames && (*frame_count >= main_max_frames);
|
|
||||||
|
|
||||||
if (shutdown_pressed || frame_count_end || movie_end || !video_alive || global->exec)
|
if (ret == -1)
|
||||||
{
|
return -1;
|
||||||
if (global->exec)
|
|
||||||
global->exec = false;
|
|
||||||
|
|
||||||
/* Quits out of RetroArch main loop.
|
|
||||||
* On special case, loads dummy core
|
|
||||||
* instead of exiting RetroArch completely.
|
|
||||||
* Aborts core shutdown if invoked.
|
|
||||||
*/
|
|
||||||
if (global->core_shutdown_initiated
|
|
||||||
&& settings->load_dummy_on_core_shutdown)
|
|
||||||
{
|
|
||||||
if (!event_command(EVENT_CMD_PREPARE_DUMMY))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
system->shutdown = false;
|
|
||||||
global->core_shutdown_initiated = false;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
if (menu_driver_alive())
|
if (menu_driver_alive())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user