Turn more boolean variables into flags for runloop

- Get rid of RARCH_CTL_IS_INITED, use runloop_get_flags instead
This commit is contained in:
LibretroAdmin 2022-10-24 18:15:19 +02:00
parent 9b7be5f2af
commit 18ea6fa81e
7 changed files with 23 additions and 25 deletions

View File

@ -338,7 +338,7 @@ static void driver_adjust_system_rates(
audio_st->input);
}
runloop_st->force_nonblock = false;
runloop_st->flags &= ~RUNLOOP_FLAG_FORCE_NONBLOCK;
if (input_fps > 0.0)
{
@ -358,7 +358,7 @@ static void driver_adjust_system_rates(
{
/* We won't be able to do VSync reliably
when game FPS > monitor FPS. */
runloop_st->force_nonblock = true;
runloop_st->flags |= RUNLOOP_FLAG_FORCE_NONBLOCK;
RARCH_LOG("[Video]: Game FPS > Monitor FPS. Cannot rely on VSync.\n");
if (VIDEO_DRIVER_GET_PTR_INTERNAL(video_st))
@ -403,9 +403,9 @@ void driver_set_nonblock_state(void)
bool adaptive_vsync = settings->bools.video_adaptive_vsync;
unsigned swap_interval = runloop_get_video_swap_interval(
settings->uints.video_swap_interval);
bool video_driver_active = video_st->flags & VIDEO_FLAG_ACTIVE;
bool audio_driver_active = audio_st->flags & AUDIO_FLAG_ACTIVE;
bool runloop_force_nonblock = runloop_st->force_nonblock;
bool video_driver_active = video_st->flags & VIDEO_FLAG_ACTIVE;
bool audio_driver_active = audio_st->flags & AUDIO_FLAG_ACTIVE;
bool runloop_force_nonblock = runloop_st->flags & RUNLOOP_FLAG_FORCE_NONBLOCK;
/* Only apply non-block-state for video if we're using vsync. */
if (video_driver_active && VIDEO_DRIVER_GET_PTR_INTERNAL(video_st))

View File

@ -3458,7 +3458,7 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
video.fullscreen = settings->bools.video_fullscreen ||
(video_st->flags & VIDEO_FLAG_FORCE_FULLSCREEN);
video.vsync = settings->bools.video_vsync &&
!runloop_st->force_nonblock;
(!(runloop_st->flags & RUNLOOP_FLAG_FORCE_NONBLOCK));
video.force_aspect = settings->bools.video_force_aspect;
video.font_enable = settings->bools.video_font_enable;
video.swap_interval = runloop_get_video_swap_interval(

View File

@ -3711,11 +3711,11 @@ void main_exit(void *args)
path_get_realsize(RARCH_PATH_CORE),
p_rarch->launch_arguments);
p_rarch->flags &= ~RARCH_FLAGS_HAS_SET_USERNAME;
runloop_st->is_inited = false;
p_rarch->flags &= ~RARCH_FLAGS_HAS_SET_USERNAME;
runloop_st->flags &= ~RUNLOOP_FLAG_IS_INITED;
global_get_ptr()->error_on_init = false;
#ifdef HAVE_CONFIGFILE
p_rarch->flags &= ~RARCH_FLAGS_BLOCK_CONFIG_READ;
p_rarch->flags &= ~RARCH_FLAGS_BLOCK_CONFIG_READ;
#endif
runloop_msg_queue_deinit();
@ -3812,7 +3812,7 @@ int rarch_main(int argc, char *argv[], void *data)
frontend_driver_init_first(data);
if (runloop_st->is_inited)
if (runloop_st->flags & RUNLOOP_FLAG_IS_INITED)
driver_uninit(DRIVERS_CMD_ALL);
#ifdef HAVE_THREAD_STORAGE
@ -5513,7 +5513,7 @@ bool retroarch_main_init(int argc, char *argv[])
command_event(CMD_EVENT_SET_PER_GAME_RESOLUTION, NULL);
global->error_on_init = false;
runloop_st->is_inited = true;
runloop_st->flags |= RUNLOOP_FLAG_IS_INITED;
#ifdef HAVE_DISCORD
{
@ -5540,7 +5540,7 @@ bool retroarch_main_init(int argc, char *argv[])
error:
command_event(CMD_EVENT_CORE_DEINIT, NULL);
runloop_st->is_inited = false;
runloop_st->flags &= ~RUNLOOP_FLAG_IS_INITED;
return false;
}
@ -5622,12 +5622,10 @@ bool retroarch_ctl(enum rarch_ctl_state state, void *data)
(runloop_st->flags & RUNLOOP_FLAG_CORE_RUNNING)
&& (runloop_st->secondary_lib_handle != NULL);
#endif
case RARCH_CTL_IS_INITED:
return runloop_st->is_inited;
case RARCH_CTL_MAIN_DEINIT:
{
input_driver_state_t *input_st = input_state_get_ptr();
if (!runloop_st->is_inited)
if (!(runloop_st->flags & RUNLOOP_FLAG_IS_INITED))
return false;
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
#ifdef HAVE_COMMAND
@ -5667,7 +5665,7 @@ bool retroarch_ctl(enum rarch_ctl_state state, void *data)
path_deinit_subsystem(runloop_st);
path_deinit_savefile();
runloop_st->is_inited = false;
runloop_st->flags &= ~RUNLOOP_FLAG_IS_INITED;
#ifdef HAVE_THREAD_STORAGE
sthread_tls_delete(&p_rarch->rarch_tls);

View File

@ -51,8 +51,6 @@ enum rarch_ctl_state
/* Deinitializes RetroArch. */
RARCH_CTL_MAIN_DEINIT,
RARCH_CTL_IS_INITED,
RARCH_CTL_IS_DUMMY_CORE,
RARCH_CTL_IS_CORE_LOADED,

View File

@ -3179,7 +3179,8 @@ bool runloop_environment_cb(unsigned cmd, void *data)
/* VSync overrides the mode if the rate is limited by the display. */
if (menu_opened || /* Menu currently always runs with vsync on. */
(settings->bools.video_vsync && !runloop_st->force_nonblock
( settings->bools.video_vsync
&& (!(runloop_st->flags & RUNLOOP_FLAG_FORCE_NONBLOCK))
&& !(input_state_get_ptr()->flags & INP_FLAG_NONBLOCKING)))
{
float refresh_rate = video_driver_get_refresh_rate();
@ -6468,7 +6469,7 @@ static enum runloop_state_enum runloop_check_state(
bool is_alive = false;
uint64_t frame_count = 0;
bool focused = true;
bool rarch_is_initialized = runloop_st->is_inited;
bool rarch_is_initialized = runloop_st->flags & RUNLOOP_FLAG_IS_INITED;
bool runloop_paused = runloop_st->flags & RUNLOOP_FLAG_PAUSED;
bool pause_nonactive = settings->bools.pause_nonactive;
unsigned quit_gamepad_combo = settings->uints.input_quit_gamepad_combo;
@ -6963,7 +6964,7 @@ MENU_ST_FLAG_IS_BINDING;
if (focused || !(runloop_st->flags & RUNLOOP_FLAG_IDLE))
{
bool runloop_is_inited = runloop_st->is_inited;
bool runloop_is_inited = runloop_st->flags & RUNLOOP_FLAG_IS_INITED;
#ifdef HAVE_NETWORKING
bool menu_pause_libretro = settings->bools.menu_pause_libretro &&
netplay_driver_ctl(RARCH_NETPLAY_CTL_ALLOW_PAUSE, NULL);

View File

@ -162,7 +162,9 @@ enum runloop_flags
RUNLOOP_FLAG_FASTMOTION = (1 << 26),
RUNLOOP_FLAG_PAUSED = (1 << 27),
RUNLOOP_FLAG_IDLE = (1 << 28),
RUNLOOP_FLAG_FOCUSED = (1 << 29)
RUNLOOP_FLAG_FOCUSED = (1 << 29),
RUNLOOP_FLAG_FORCE_NONBLOCK = (1 << 30),
RUNLOOP_FLAG_IS_INITED = (1 << 31)
};
struct runloop
@ -297,9 +299,7 @@ struct runloop
char label[8192];
} name;
bool is_inited;
bool missing_bios;
bool force_nonblock;
bool perfcnt_enable;
};

View File

@ -701,8 +701,9 @@ static ui_application_t ui_application_cocoa = {
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
NSApplicationTerminateReply reply = NSTerminateNow;
uint32_t runloop_flags = runloop_get_flags();
if (retroarch_ctl(RARCH_CTL_IS_INITED, NULL))
if (runloop_flags & RUNLOOP_FLAG_IS_INITED)
reply = NSTerminateCancel;
command_event(CMD_EVENT_QUIT, NULL);