mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 00:32:49 +00:00
Add RUNLOOP_CTL_FORCED_NONBLOCK_{} actions
This commit is contained in:
parent
fe9ad4825d
commit
05ce32efe4
11
driver.c
11
driver.c
@ -200,16 +200,13 @@ bool driver_find_next(const char *label, char *s, size_t len)
|
||||
|
||||
static void driver_adjust_system_rates(void)
|
||||
{
|
||||
rarch_system_info_t *system = NULL;
|
||||
|
||||
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
|
||||
audio_driver_ctl(RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES, NULL);
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_MONITOR_ADJUST_SYSTEM_RATES, NULL);
|
||||
|
||||
if (!video_driver_get_ptr(false))
|
||||
return;
|
||||
|
||||
if (system->force_nonblock)
|
||||
if (runloop_ctl(RUNLOOP_CTL_IS_NONBLOCK_FORCED, NULL))
|
||||
event_cmd_ctl(EVENT_CMD_VIDEO_SET_NONBLOCKING_STATE, NULL);
|
||||
else
|
||||
driver_ctl(RARCH_DRIVER_CTL_SET_NONBLOCK_STATE, NULL);
|
||||
@ -225,20 +222,18 @@ static void driver_adjust_system_rates(void)
|
||||
**/
|
||||
static void driver_set_nonblock_state(void)
|
||||
{
|
||||
rarch_system_info_t *system = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool enable = input_driver_ctl(
|
||||
RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL);
|
||||
|
||||
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
|
||||
|
||||
/* Only apply non-block-state for video if we're using vsync. */
|
||||
if (video_driver_ctl(RARCH_DISPLAY_CTL_IS_ACTIVE, NULL)
|
||||
&& video_driver_get_ptr(false))
|
||||
{
|
||||
bool video_nonblock = enable;
|
||||
|
||||
if (!settings->video.vsync || system->force_nonblock)
|
||||
if ( !settings->video.vsync
|
||||
|| runloop_ctl(RUNLOOP_CTL_IS_NONBLOCK_FORCED, NULL))
|
||||
video_nonblock = true;
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_NONBLOCK_STATE, &video_nonblock);
|
||||
}
|
||||
|
@ -665,7 +665,7 @@ static bool init_video(void)
|
||||
video.width = width;
|
||||
video.height = height;
|
||||
video.fullscreen = settings->video.fullscreen;
|
||||
video.vsync = settings->video.vsync && !system->force_nonblock;
|
||||
video.vsync = settings->video.vsync && !runloop_ctl(RUNLOOP_CTL_IS_NONBLOCK_FORCED, NULL);
|
||||
video.force_aspect = settings->video.force_aspect;
|
||||
#ifdef GEKKO
|
||||
video.viwidth = settings->video.viwidth;
|
||||
@ -1119,14 +1119,8 @@ static void video_monitor_adjust_system_rates(void)
|
||||
struct retro_system_av_info *av_info =
|
||||
video_viewport_get_system_av_info();
|
||||
settings_t *settings = config_get_ptr();
|
||||
rarch_system_info_t *system = NULL;
|
||||
|
||||
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
|
||||
|
||||
if (!system)
|
||||
return;
|
||||
|
||||
system->force_nonblock = false;
|
||||
runloop_ctl(RUNLOOP_CTL_UNSET_NONBLOCK_FORCED, NULL);
|
||||
|
||||
if (av_info)
|
||||
info = (const struct retro_system_timing*)&av_info->timing;
|
||||
@ -1149,7 +1143,7 @@ static void video_monitor_adjust_system_rates(void)
|
||||
return;
|
||||
|
||||
/* We won't be able to do VSync reliably when game FPS > monitor FPS. */
|
||||
system->force_nonblock = true;
|
||||
runloop_ctl(RUNLOOP_CTL_SET_NONBLOCK_FORCED, NULL);
|
||||
RARCH_LOG("Game FPS > Monitor FPS. Cannot rely on VSync.\n");
|
||||
}
|
||||
|
||||
|
@ -416,6 +416,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
||||
static retro_keyboard_event_t runloop_key_event = NULL;
|
||||
static retro_keyboard_event_t runloop_frontend_key_event = NULL;
|
||||
static unsigned runloop_max_frames = false;
|
||||
static bool runloop_force_nonblock = false;
|
||||
static bool runloop_frame_time_last = false;
|
||||
static bool runloop_set_frame_limit = false;
|
||||
static bool runloop_paused = false;
|
||||
@ -564,6 +565,14 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
||||
break;
|
||||
case RUNLOOP_CTL_IS_PERFCNT_ENABLE:
|
||||
return runloop_perfcnt_enable;
|
||||
case RUNLOOP_CTL_SET_NONBLOCK_FORCED:
|
||||
runloop_force_nonblock = true;
|
||||
break;
|
||||
case RUNLOOP_CTL_UNSET_NONBLOCK_FORCED:
|
||||
runloop_force_nonblock = false;
|
||||
break;
|
||||
case RUNLOOP_CTL_IS_NONBLOCK_FORCED:
|
||||
return runloop_force_nonblock;
|
||||
case RUNLOOP_CTL_SET_FRAME_TIME:
|
||||
{
|
||||
const struct retro_frame_time_callback *info =
|
||||
|
@ -48,6 +48,9 @@ enum runloop_ctl_state
|
||||
RUNLOOP_CTL_IS_GAME_OPTIONS_ACTIVE,
|
||||
RUNLOOP_CTL_SET_GAME_OPTIONS_ACTIVE,
|
||||
RUNLOOP_CTL_UNSET_GAME_OPTIONS_ACTIVE,
|
||||
RUNLOOP_CTL_IS_NONBLOCK_FORCED,
|
||||
RUNLOOP_CTL_SET_NONBLOCK_FORCED,
|
||||
RUNLOOP_CTL_UNSET_NONBLOCK_FORCED,
|
||||
RUNLOOP_CTL_CHECK_IDLE_STATE,
|
||||
RUNLOOP_CTL_GET_CONTENT_PATH,
|
||||
RUNLOOP_CTL_SET_CONTENT_PATH,
|
||||
|
Loading…
x
Reference in New Issue
Block a user