diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 56be7bea87..173a530c38 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -594,6 +594,7 @@ void audio_driver_set_nonblocking_state(bool enable) **/ bool audio_driver_flush(const int16_t *data, size_t samples) { + bool is_slowmotion; static struct retro_perf_counter audio_convert_s16 = {0}; static struct retro_perf_counter audio_convert_float = {0}; static struct retro_perf_counter audio_dsp = {0}; @@ -655,7 +656,10 @@ bool audio_driver_flush(const int16_t *data, size_t samples) audio_driver_readjust_input_rate(); src_data.ratio = audio_data.src_ratio; - if (rarch_main_is_slowmotion()) + + rarch_main_ctl(RARCH_MAIN_CTL_IS_SLOWMOTION, &is_slowmotion); + + if (is_slowmotion) src_data.ratio *= settings->slowmotion_ratio; rarch_perf_init(&resampler_proc, "resampler_proc"); diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index f98afb1800..c83507d74f 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1632,6 +1632,7 @@ static bool gl_frame(void *data, const void *frame, uint64_t frame_count, unsigned pitch, const char *msg) { + bool is_slowmotion; unsigned width, height; struct gfx_tex_info feedback_info; static struct retro_perf_counter frame_run = {0}; @@ -1838,10 +1839,12 @@ static bool gl_frame(void *data, const void *frame, #endif #endif #endif + rarch_main_ctl(RARCH_MAIN_CTL_IS_SLOWMOTION, &is_slowmotion); + /* Disable BFI during fast forward, slow-motion, * and pause to prevent flicker. */ if (settings->video.black_frame_insertion && - !driver->nonblock_state && (!(rarch_main_is_slowmotion())) + !driver->nonblock_state && !is_slowmotion && !rarch_main_is_paused()) { gfx_ctx_swap_buffers(gl); diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 5c435a2f5f..f9e732f75a 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -829,10 +829,13 @@ void video_driver_get_video_output_prev(void) **/ void video_driver_cached_frame(void) { + bool is_idle; driver_t *driver = driver_get_ptr(); void *recording = driver ? driver->recording_data : NULL; - if (rarch_main_is_idle()) + rarch_main_ctl(RARCH_MAIN_CTL_IS_IDLE, &is_idle); + + if (is_idle) return; /* Cannot allow recording when pushing duped frames. */ diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 01472d98c1..4c58e66a08 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -432,10 +432,13 @@ static void rgui_render(void) if (!rgui->force_redraw) { + bool is_idle; if (menu_entries_needs_refresh() && menu_driver_alive() && !disp->msg_force) return; - if (rarch_main_is_idle()) + rarch_main_ctl(RARCH_MAIN_CTL_IS_IDLE, &is_idle); + + if (is_idle) return; if (!menu_display_ctl(MENU_DISPLAY_CTL_UPDATE_PENDING, NULL)) diff --git a/menu/menu_iterate.c b/menu/menu_iterate.c index 0ca4c8a902..44168a5c3a 100644 --- a/menu/menu_iterate.c +++ b/menu/menu_iterate.c @@ -542,6 +542,7 @@ end: int menu_iterate_render(void) { + bool is_idle; const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr(); @@ -573,7 +574,9 @@ int menu_iterate_render(void) driver->render(); } - if (menu_driver_alive() && !rarch_main_is_idle()) + rarch_main_ctl(RARCH_MAIN_CTL_IS_IDLE, &is_idle); + + if (menu_driver_alive() && !is_idle) menu_display_ctl(MENU_DISPLAY_CTL_LIBRETRO, NULL); menu_driver_set_texture(); diff --git a/runloop.c b/runloop.c index 5b26f401d2..f8b7c8f0ab 100644 --- a/runloop.c +++ b/runloop.c @@ -901,14 +901,29 @@ bool rarch_main_is_paused(void) return main_is_paused; } -bool rarch_main_is_idle(void) +bool rarch_main_ctl(enum rarch_main_ctl_state state, void *data) { - return main_is_idle; -} + switch (state) + { + case RARCH_MAIN_CTL_IS_IDLE: + { + bool *ptr = (bool*)data; + if (!ptr) + return false; + *ptr = main_is_idle; + } + return true; + case RARCH_MAIN_CTL_IS_SLOWMOTION: + { + bool *ptr = (bool*)data; + if (!ptr) + return false; + *ptr = main_is_slowmotion; + } + return true; + } -bool rarch_main_is_slowmotion(void) -{ - return main_is_slowmotion; + return false; } static bool rarch_main_cmd_get_state_menu_toggle_button_combo( diff --git a/runloop.h b/runloop.h index 1934aeface..0827589287 100644 --- a/runloop.h +++ b/runloop.h @@ -33,6 +33,12 @@ extern "C" { #endif +enum rarch_main_ctl_state +{ + RARCH_MAIN_CTL_IS_IDLE = 0, + RARCH_MAIN_CTL_IS_SLOWMOTION +}; + typedef struct rarch_resolution { unsigned idx; @@ -327,9 +333,7 @@ bool rarch_main_verbosity(void); FILE *rarch_main_log_file(void); -bool rarch_main_is_idle(void); - -bool rarch_main_is_slowmotion(void); +bool rarch_main_ctl(enum rarch_main_ctl_state state, void *data); bool rarch_main_is_paused(void); diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 1e8c1b7250..693d7c56af 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -60,6 +60,7 @@ static void rarch_disable_ui(void) static void rarch_draw_observer(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info) { + bool is_idle; unsigned sleep_ms = 0; int ret = rarch_main_iterate(&sleep_ms); @@ -74,7 +75,9 @@ static void rarch_draw_observer(CFRunLoopObserverRef observer, return; } - if (rarch_main_is_idle()) + rarch_main_ctl(RARCH_MAIN_CTL_IS_IDLE, &is_idle); + + if (is_idle) return; CFRunLoopWakeUp(CFRunLoopGetMain()); }