Create rarch_main_ctl

This commit is contained in:
twinaphex 2015-09-26 12:57:52 +02:00
parent 905ad40ebf
commit cc4a918296
8 changed files with 53 additions and 15 deletions

View File

@ -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");

View File

@ -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);

View File

@ -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. */

View File

@ -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))

View File

@ -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();

View File

@ -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(

View File

@ -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);

View File

@ -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());
}