From b18442dc5a039d092dfd7617ee8f3f82a11f673e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 5 Aug 2015 13:06:44 +0200 Subject: [PATCH] Refactor is_slowmotion --- audio/audio_driver.c | 2 +- gfx/drivers/gl.c | 2 +- runloop.c | 24 +++++++++++++++++------- runloop.h | 5 ++++- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 561690e6a1..338f24f139 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -653,7 +653,7 @@ bool audio_driver_flush(const int16_t *data, size_t samples) audio_driver_readjust_input_rate(); src_data.ratio = audio_data.src_ratio; - if (global->is_slowmotion) + if (rarch_main_is_slowmotion()) src_data.ratio *= settings->slowmotion_ratio; RARCH_PERFORMANCE_INIT(resampler_proc); diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index bb39a98fd4..36ae7e693a 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1714,7 +1714,7 @@ static bool gl_frame(void *data, const void *frame, /* Disable BFI during fast forward, slow-motion, * and pause to prevent flicker. */ if (settings->video.black_frame_insertion && - !driver->nonblock_state && !global->is_slowmotion + !driver->nonblock_state && (!(rarch_main_is_slowmotion())) && !rarch_main_is_paused()) { gfx_ctx_swap_buffers(gl); diff --git a/runloop.c b/runloop.c index 0774797a45..c19e939d31 100644 --- a/runloop.c +++ b/runloop.c @@ -46,6 +46,7 @@ static struct global g_extern; static bool main_is_idle; static bool main_is_paused; +static bool main_is_slowmotion; /** * check_pause: @@ -230,9 +231,9 @@ static void check_rewind(settings_t *settings, static void check_slowmotion(settings_t *settings, global_t *global, bool slowmotion_pressed) { - global->is_slowmotion = slowmotion_pressed; + main_is_slowmotion = slowmotion_pressed; - if (!global->is_slowmotion) + if (!main_is_slowmotion) return; if (settings->video.black_frame_insertion) @@ -627,8 +628,7 @@ static INLINE int time_to_exit(driver_t *driver, global_t *global, * Updates frame timing if frame timing callback is in use by the core. **/ static void rarch_update_frame_time(driver_t *driver, settings_t *settings, - rarch_system_info_t *system, - global_t *global) + rarch_system_info_t *system) { retro_time_t curr_time = rarch_get_time_usec(); retro_time_t delta = curr_time - system->frame_time_last; @@ -639,7 +639,7 @@ static void rarch_update_frame_time(driver_t *driver, settings_t *settings, if (!system->frame_time_last || is_locked_fps) delta = system->frame_time.reference; - if (!is_locked_fps && global->is_slowmotion) + if (!is_locked_fps && main_is_slowmotion) delta /= settings->slowmotion_ratio; system->frame_time_last = curr_time; @@ -870,10 +870,10 @@ void rarch_main_state_free(void) { main_is_idle = false; main_is_paused = false; + main_is_slowmotion = false; g_extern.ui_companion_is_on_foreground = false; g_extern.frames.limit.minimum_time = 0.0; g_extern.frames.limit.last_time = 0.0; - g_extern.is_slowmotion = false; g_extern.max_frames = 0; } @@ -912,6 +912,11 @@ void rarch_main_clear_state(void) rarch_main_global_free(); } +void rarch_main_set_slowmotion(unsigned enable) +{ + main_is_slowmotion = enable; +} + void rarch_main_set_pause(unsigned enable) { main_is_paused = enable; @@ -932,6 +937,11 @@ bool rarch_main_is_idle(void) return main_is_idle; } +bool rarch_main_is_slowmotion(void) +{ + return main_is_slowmotion; +} + static bool rarch_main_cmd_get_state_menu_toggle_button_combo( driver_t *driver, settings_t *settings, retro_input_t input, retro_input_t old_input, @@ -1049,7 +1059,7 @@ int rarch_main_iterate(void) return rarch_main_iterate_quit(settings, system, global); if (system->frame_time.callback) - rarch_update_frame_time(driver, settings, system, global); + rarch_update_frame_time(driver, settings, system); do_pre_state_checks(settings, global, &cmd); diff --git a/runloop.h b/runloop.h index d6026b47aa..e7bfb779b9 100644 --- a/runloop.h +++ b/runloop.h @@ -54,7 +54,6 @@ typedef struct global } limit; } frames; - bool is_slowmotion; unsigned max_frames; bool verbosity; @@ -343,8 +342,12 @@ FILE *rarch_main_log_file(void); bool rarch_main_is_idle(void); +bool rarch_main_is_slowmotion(void); + bool rarch_main_is_paused(void); +void rarch_main_set_slowmotion(unsigned enable); + void rarch_main_set_pause(unsigned enable); void rarch_main_set_idle(unsigned enable);