Refactor fastforward ratio

This commit is contained in:
twinaphex 2015-08-27 14:39:42 +02:00
parent 805e2ffde3
commit 1ec90df165
6 changed files with 13 additions and 36 deletions

View File

@ -677,10 +677,7 @@ static const bool savestate_auto_load = false;
static const float slowmotion_ratio = 3.0; static const float slowmotion_ratio = 3.0;
/* Maximum fast forward ratio. */ /* Maximum fast forward ratio. */
static const float fastforward_ratio = 1.0; static const float fastforward_ratio = 0.0;
/* Throttle fast forward. */
static const bool fastforward_ratio_throttle_enable = false;
/* Enable stdin/network command interface. */ /* Enable stdin/network command interface. */
static const bool network_cmd_enable = false; static const bool network_cmd_enable = false;

View File

@ -538,7 +538,6 @@ static void config_set_defaults(void)
settings->rewind_granularity = rewind_granularity; settings->rewind_granularity = rewind_granularity;
settings->slowmotion_ratio = slowmotion_ratio; settings->slowmotion_ratio = slowmotion_ratio;
settings->fastforward_ratio = fastforward_ratio; settings->fastforward_ratio = fastforward_ratio;
settings->fastforward_ratio_throttle_enable = fastforward_ratio_throttle_enable;
settings->pause_nonactive = pause_nonactive; settings->pause_nonactive = pause_nonactive;
settings->autosave_interval = autosave_interval; settings->autosave_interval = autosave_interval;
@ -1599,11 +1598,8 @@ static bool config_load_file(const char *path, bool set_defaults)
/* Sanitize fastforward_ratio value - previously range was -1 /* Sanitize fastforward_ratio value - previously range was -1
* and up (with 0 being skipped) */ * and up (with 0 being skipped) */
if (settings->fastforward_ratio <= 0.0f) if (settings->fastforward_ratio < 0.0f)
settings->fastforward_ratio = 1.0f; settings->fastforward_ratio = 0.0f;
CONFIG_GET_BOOL_BASE(conf, settings, fastforward_ratio_throttle_enable,
"fastforward_ratio_throttle_enable");
CONFIG_GET_BOOL_BASE(conf, settings, pause_nonactive, "pause_nonactive"); CONFIG_GET_BOOL_BASE(conf, settings, pause_nonactive, "pause_nonactive");
CONFIG_GET_INT_BASE(conf, settings, autosave_interval, "autosave_interval"); CONFIG_GET_INT_BASE(conf, settings, autosave_interval, "autosave_interval");
@ -2709,8 +2705,6 @@ bool config_save_file(const char *path)
settings->history_list_enable); settings->history_list_enable);
config_set_float(conf, "fastforward_ratio", settings->fastforward_ratio); config_set_float(conf, "fastforward_ratio", settings->fastforward_ratio);
config_set_bool(conf, "fastforward_ratio_throttle_enable",
settings->fastforward_ratio_throttle_enable);
config_set_float(conf, "slowmotion_ratio", settings->slowmotion_ratio); config_set_float(conf, "slowmotion_ratio", settings->slowmotion_ratio);
config_set_bool(conf, "config_save_on_exit", config_set_bool(conf, "config_save_on_exit",

View File

@ -314,7 +314,6 @@ typedef struct settings
float slowmotion_ratio; float slowmotion_ratio;
float fastforward_ratio; float fastforward_ratio;
bool fastforward_ratio_throttle_enable;
bool pause_nonactive; bool pause_nonactive;
unsigned autosave_interval; unsigned autosave_interval;

View File

@ -2932,20 +2932,6 @@ static bool setting_append_list_frame_throttling_options(
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info, parent_group); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info, parent_group);
CONFIG_BOOL(
settings->fastforward_ratio_throttle_enable,
menu_hash_to_str(MENU_LABEL_FRAME_THROTTLE_ENABLE),
menu_hash_to_str(MENU_LABEL_VALUE_FRAME_THROTTLE_ENABLE),
fastforward_ratio_throttle_enable,
menu_hash_to_str(MENU_VALUE_OFF),
menu_hash_to_str(MENU_VALUE_ON),
group_info.name,
subgroup_info.name,
parent_group,
general_write_handler,
general_read_handler);
menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_SET_FRAME_LIMIT);
CONFIG_FLOAT( CONFIG_FLOAT(
settings->fastforward_ratio, settings->fastforward_ratio,
menu_hash_to_str(MENU_LABEL_FASTFORWARD_RATIO), menu_hash_to_str(MENU_LABEL_FASTFORWARD_RATIO),
@ -2958,7 +2944,7 @@ static bool setting_append_list_frame_throttling_options(
general_write_handler, general_write_handler,
general_read_handler); general_read_handler);
menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_SET_FRAME_LIMIT); menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_SET_FRAME_LIMIT);
menu_settings_list_current_add_range(list, list_info, 1, 10, 1.0, true, true); menu_settings_list_current_add_range(list, list_info, 0, 10, 1.0, true, true);
CONFIG_FLOAT( CONFIG_FLOAT(
settings->slowmotion_ratio, settings->slowmotion_ratio,

View File

@ -760,10 +760,8 @@
# The maximum rate at which content will be run when using fast forward. (E.g. 5.0 for 60 fps content => 300 fps cap). # The maximum rate at which content will be run when using fast forward. (E.g. 5.0 for 60 fps content => 300 fps cap).
# RetroArch will go to sleep to ensure that the maximum rate will not be exceeded. # RetroArch will go to sleep to ensure that the maximum rate will not be exceeded.
# Do not rely on this cap to be perfectly accurate. # Do not rely on this cap to be perfectly accurate.
# fastforward_ratio = 1.0 # If this is set at 0, then fastforward ratio is unlimited (no FPS cap)
# fastforward_ratio = 0.0
# Setting this to false equals no FPS cap and will override the fastforward_ratio value.
# fastforward_ratio_throttle_enable = false
# Enable stdin/network command interface. # Enable stdin/network command interface.
# network_cmd_enable = false # network_cmd_enable = false

View File

@ -653,11 +653,11 @@ static void rarch_update_frame_time(driver_t *driver, float slowmotion_ratio,
system->frame_time.callback(delta); system->frame_time.callback(delta);
} }
static int rarch_limit_frame_time(settings_t *settings) static int rarch_limit_frame_time(float fastforward_ratio)
{ {
retro_time_t current, target, to_sleep_ms; retro_time_t current, target, to_sleep_ms;
if (!settings->fastforward_ratio_throttle_enable) if (!fastforward_ratio)
return 0; return 0;
current = rarch_get_time_usec(); current = rarch_get_time_usec();
@ -834,6 +834,9 @@ void rarch_main_set_frame_limit_last_time(void)
struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
float fastforward_ratio = settings->fastforward_ratio; float fastforward_ratio = settings->fastforward_ratio;
if (fastforward_ratio == 0.0f)
fastforward_ratio = 1.0f;
frame_limit_last_time = rarch_get_time_usec(); frame_limit_last_time = rarch_get_time_usec();
frame_limit_minimum_time = (retro_time_t)roundf(1000000.0f / (av_info->timing.fps * fastforward_ratio)); frame_limit_minimum_time = (retro_time_t)roundf(1000000.0f / (av_info->timing.fps * fastforward_ratio));
} }
@ -1083,7 +1086,7 @@ int rarch_main_iterate(void)
if (!input && settings->menu.pause_libretro) if (!input && settings->menu.pause_libretro)
return 1; return 1;
return rarch_limit_frame_time(settings); return rarch_limit_frame_time(settings->fastforward_ratio);
} }
#endif #endif
@ -1149,5 +1152,5 @@ int rarch_main_iterate(void)
unlock_autosave(); unlock_autosave();
#endif #endif
return rarch_limit_frame_time(settings); return rarch_limit_frame_time(settings->fastforward_ratio);
} }