Create rarch_main_set_idle - make 'idle' variable self-contained

This commit is contained in:
twinaphex 2015-08-05 12:40:47 +02:00
parent 3f46a74f08
commit 74ee9b05f3
7 changed files with 25 additions and 21 deletions

View File

@ -829,10 +829,9 @@ void video_driver_get_video_output_prev(void)
void video_driver_cached_frame(void)
{
driver_t *driver = driver_get_ptr();
global_t *global = global_get_ptr();
void *recording = driver ? driver->recording_data : NULL;
if (global->is_idle)
if (rarch_main_is_idle())
return;
/* Cannot allow recording when pushing duped frames. */

View File

@ -359,7 +359,7 @@ static void engine_handle_cmd(void)
{
RARCH_LOG("Pausing RetroArch.\n");
global->is_paused = true;
global->is_idle = true;
rarch_main_set_idle(true);
}
break;
@ -389,7 +389,7 @@ static void engine_handle_cmd(void)
case APP_CMD_GAINED_FOCUS:
global->is_paused = false;
global->is_idle = false;
rarch_main_set_idle(false);
if ((android_app->sensor_state_mask
& (UINT64_C(1) << RETRO_SENSOR_ACCELEROMETER_ENABLE))

View File

@ -397,7 +397,7 @@ static void rgui_render(void)
if (menu_entries_needs_refresh() && menu_driver_alive() && !disp->msg_force)
return;
if (global->is_idle)
if (rarch_main_is_idle())
return;
if (!menu_display_update_pending())

View File

@ -364,7 +364,7 @@ int menu_iterate(retro_input_t input,
ret = menu_entry_iterate(action);
if (menu_driver_alive() && !global->is_idle)
if (menu_driver_alive() && !rarch_main_is_idle())
menu_display_fb();
menu_driver_set_texture();

View File

@ -44,6 +44,8 @@
static struct global g_extern;
static bool main_is_idle;
/**
* check_pause:
* @pressed : was libretro pause key pressed?
@ -512,7 +514,7 @@ static int do_pause_state_checks(
static int do_state_checks(driver_t *driver, settings_t *settings,
global_t *global, event_cmd_state_t *cmd)
{
if (global->is_idle)
if (main_is_idle)
return 1;
if (cmd->screenshot_pressed)
@ -868,7 +870,7 @@ global_t *global_get_ptr(void)
void rarch_main_state_free(void)
{
g_extern.is_idle = false;
main_is_idle = 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;
@ -912,12 +914,14 @@ void rarch_main_clear_state(void)
rarch_main_global_free();
}
void rarch_main_set_idle(unsigned enable)
{
main_is_idle = enable;
}
bool rarch_main_is_idle(void)
{
global_t *global = global_get_ptr();
if (!global)
return false;
return global->is_idle;
return main_is_idle;
}
static bool rarch_main_cmd_get_state_menu_toggle_button_combo(

View File

@ -43,7 +43,6 @@ typedef struct rarch_resolution
typedef struct global
{
/* Lifecycle state checks. */
bool is_idle;
bool ui_companion_is_on_foreground;
struct
@ -345,6 +344,8 @@ FILE *rarch_main_log_file(void);
bool rarch_main_is_idle(void);
void rarch_main_set_idle(unsigned enable);
void rarch_main_state_free(void);
void rarch_main_global_free(void);

View File

@ -45,19 +45,19 @@ void apple_rarch_exited(void);
static void rarch_enable_ui(void)
{
global_t *global = global_get_ptr();
global->is_paused = true;
global->is_idle = true;
global->ui_companion_is_on_foreground = true;
rarch_main_set_idle(true);
}
static void rarch_disable_ui(void)
{
global_t *global = global_get_ptr();
global->is_paused = false;
global->is_idle = false;
global->ui_companion_is_on_foreground = false;
global_t *global = global_get_ptr();
global->is_paused = false;
global->ui_companion_is_on_foreground = false;
rarch_main_set_idle(false);
}
static void rarch_draw(void)
@ -88,7 +88,7 @@ static void rarch_draw(void)
return;
}
if (global->is_idle)
if (rarch_main_is_idle())
return;
CFRunLoopWakeUp(CFRunLoopGetMain());
}