From 05ce32efe48a89140b14ce16357c61f0c50bd1e9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 4 Mar 2016 19:20:00 +0100 Subject: [PATCH] Add RUNLOOP_CTL_FORCED_NONBLOCK_{} actions --- driver.c | 11 +++-------- gfx/video_driver.c | 12 +++--------- runloop.c | 9 +++++++++ runloop.h | 3 +++ system.h | 2 -- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/driver.c b/driver.c index cf01cc3fc4..848d5a7cee 100644 --- a/driver.c +++ b/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); } diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 16c2aad699..166e5e3fe4 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -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"); } diff --git a/runloop.c b/runloop.c index 5d73835270..7602c96dcf 100644 --- a/runloop.c +++ b/runloop.c @@ -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 = diff --git a/runloop.h b/runloop.h index 651e8aa321..57e74c06a2 100644 --- a/runloop.h +++ b/runloop.h @@ -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, diff --git a/system.h b/system.h index d150893033..72742b4247 100644 --- a/system.h +++ b/system.h @@ -39,8 +39,6 @@ typedef struct rarch_system_info unsigned rotation; unsigned performance_level; - bool force_nonblock; - const char *input_desc_btn[MAX_USERS][RARCH_FIRST_META_KEY]; char valid_extensions[PATH_MAX_LENGTH];