move frame_time_last out of system_t struct and make it

a static local variable inside rarch_main_iterate
This commit is contained in:
twinaphex 2015-12-04 12:26:39 +01:00
parent 35da6073df
commit 3b176eed6f
5 changed files with 26 additions and 8 deletions

View File

@ -356,7 +356,6 @@ static void menu_update_libretro_info(void)
void init_drivers(int flags)
{
driver_t *driver = driver_get_ptr();
rarch_system_info_t *system = rarch_system_info_get_ptr();
if (flags & DRIVER_VIDEO)
video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_OWN_DRIVER, NULL);
@ -390,7 +389,7 @@ void init_drivers(int flags)
hw_render->context_reset();
video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT_ACK, NULL);
system->frame_time_last = 0;
runloop_ctl(RUNLOOP_CTL_SET_FRAME_TIME_LAST, NULL);
}
if (flags & DRIVER_AUDIO)

View File

@ -316,7 +316,8 @@ void menu_driver_toggle(bool latch)
{
global->frontend_key_event = system->key_event;
system->key_event = menu_input_key_event;
system->frame_time_last = 0;
runloop_ctl(RUNLOOP_CTL_SET_FRAME_TIME_LAST, NULL);
}
}
else

View File

@ -351,6 +351,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
{
static char runloop_fullpath[PATH_MAX_LENGTH];
static unsigned runloop_max_frames = false;
static bool runloop_frame_time_last = false;
static bool runloop_set_frame_limit = false;
static bool runloop_paused = false;
static bool runloop_idle = false;
@ -371,6 +372,14 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
return runloop_max_frames && (*frame_count >= runloop_max_frames);
}
break;
case RUNLOOP_CTL_SET_FRAME_TIME_LAST:
runloop_frame_time_last = true;
break;
case RUNLOOP_CTL_UNSET_FRAME_TIME_LAST:
runloop_frame_time_last = false;
break;
case RUNLOOP_CTL_IS_FRAME_TIME_LAST:
return runloop_frame_time_last;
case RUNLOOP_CTL_SET_FRAME_LIMIT:
runloop_set_frame_limit = true;
break;
@ -968,6 +977,7 @@ int rarch_main_iterate(unsigned *sleep_ms)
retro_input_t trigger_input;
event_cmd_state_t cmd;
retro_time_t current, target, to_sleep_ms;
static retro_usec_t frame_time_last;
static retro_time_t frame_limit_minimum_time = 0.0;
static retro_time_t frame_limit_last_time = 0.0;
static retro_input_t last_input = 0;
@ -979,6 +989,12 @@ int rarch_main_iterate(unsigned *sleep_ms)
retro_input_t old_input = last_input;
last_input = input;
if (runloop_ctl(RUNLOOP_CTL_IS_FRAME_TIME_LAST, NULL))
{
frame_time_last = 0;
runloop_ctl(RUNLOOP_CTL_UNSET_FRAME_TIME_LAST, NULL);
}
if (runloop_ctl(RUNLOOP_CTL_SHOULD_SET_FRAME_LIMIT, NULL))
{
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
@ -1015,23 +1031,23 @@ int rarch_main_iterate(unsigned *sleep_ms)
bool is_slowmotion;
retro_time_t current = retro_get_time_usec();
retro_time_t delta = current - system->frame_time_last;
retro_time_t delta = current - frame_time_last;
bool is_locked_fps = (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) ||
input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL)) |
!!driver->recording_data;
runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, &is_slowmotion);
if (!system->frame_time_last || is_locked_fps)
if (!frame_time_last || is_locked_fps)
delta = system->frame_time.reference;
if (!is_locked_fps && is_slowmotion)
delta /= settings->slowmotion_ratio;
system->frame_time_last = current;
frame_time_last = current;
if (is_locked_fps)
system->frame_time_last = 0;
frame_time_last = 0;
system->frame_time.callback(delta);
}

View File

@ -37,6 +37,9 @@ enum runloop_ctl_state
RUNLOOP_CTL_SET_FRAME_LIMIT = 0,
RUNLOOP_CTL_UNSET_FRAME_LIMIT,
RUNLOOP_CTL_SHOULD_SET_FRAME_LIMIT,
RUNLOOP_CTL_SET_FRAME_TIME_LAST,
RUNLOOP_CTL_UNSET_FRAME_TIME_LAST,
RUNLOOP_CTL_IS_FRAME_TIME_LAST,
RUNLOOP_CTL_IS_FRAME_COUNT_END,
RUNLOOP_CTL_IS_IDLE,
RUNLOOP_CTL_GET_WINDOWED_SCALE,

View File

@ -48,7 +48,6 @@ typedef struct rarch_system_info
struct retro_location_callback location_callback;
struct retro_frame_time_callback frame_time;
retro_usec_t frame_time_last;
core_option_manager_t *core_options;