mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
Create g_runloop and start moving variables there
This commit is contained in:
parent
3d7c1ab304
commit
a74cb0574b
@ -312,12 +312,12 @@ void notify_content_loaded(void) {
|
||||
[[UIApplication sharedApplication] setStatusBarHidden:true withAnimation:UIStatusBarAnimationNone];
|
||||
[[UIApplication sharedApplication] setIdleTimerDisabled:true];
|
||||
[self.window setRootViewController:[RAGameView get]];
|
||||
g_extern.is_paused = false;
|
||||
g_runloop.is_paused = false;
|
||||
}
|
||||
|
||||
- (IBAction)showPauseMenu:(id)sender
|
||||
{
|
||||
g_extern.is_paused = true;
|
||||
g_runloop.is_paused = true;
|
||||
[[UIApplication sharedApplication] setStatusBarHidden:false withAnimation:UIStatusBarAnimationNone];
|
||||
[[UIApplication sharedApplication] setIdleTimerDisabled:false];
|
||||
[self.window setRootViewController:self];
|
||||
|
@ -68,7 +68,7 @@ void engine_handle_cmd(void *data)
|
||||
scond_broadcast(android_app->cond);
|
||||
slock_unlock(android_app->mutex);
|
||||
|
||||
if (g_extern.is_paused)
|
||||
if (g_runloop.is_paused)
|
||||
rarch_main_command(RARCH_CMD_REINIT);
|
||||
break;
|
||||
|
||||
@ -95,7 +95,7 @@ void engine_handle_cmd(void *data)
|
||||
if (!g_extern.system.shutdown)
|
||||
{
|
||||
RARCH_LOG("Pausing RetroArch.\n");
|
||||
g_extern.is_paused = true;
|
||||
g_runloop.is_paused = true;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -124,7 +124,7 @@ void engine_handle_cmd(void *data)
|
||||
break;
|
||||
|
||||
case APP_CMD_GAINED_FOCUS:
|
||||
g_extern.is_paused = false;
|
||||
g_runloop.is_paused = false;
|
||||
|
||||
if ((android_app->sensor_state_mask
|
||||
& (1ULL << RETRO_SENSOR_ACCELEROMETER_ENABLE))
|
||||
|
@ -87,7 +87,7 @@ static void do_iteration(void)
|
||||
main_exit, WAIT doesn't wake up the loop, and AGAIN does. It
|
||||
would then return AGAIN when a core was active. An ugly way to
|
||||
get the same effect is to look have this code just look at
|
||||
g_extern.is_menu and use the WAIT behavior in that case.
|
||||
g_runloop.is_menu and use the WAIT behavior in that case.
|
||||
|
||||
Approach 2: Instead of signalling outside of RA whether a core
|
||||
is running, instead externalize the frame time that is inside
|
||||
|
15
general.h
15
general.h
@ -424,6 +424,16 @@ typedef struct nbio_handle
|
||||
msg_queue_t *msg_queue;
|
||||
} nbio_handle_t;
|
||||
|
||||
/* All runloop-related globals go here. */
|
||||
|
||||
struct runloop
|
||||
{
|
||||
/* Lifecycle state checks. */
|
||||
bool is_paused;
|
||||
bool is_menu;
|
||||
bool is_slowmotion;
|
||||
};
|
||||
|
||||
/* All run-time- / command line flag-related globals go here. */
|
||||
|
||||
struct global
|
||||
@ -655,10 +665,6 @@ struct global
|
||||
bool sram_save_disable;
|
||||
bool use_sram;
|
||||
|
||||
/* Lifecycle state checks. */
|
||||
bool is_paused;
|
||||
bool is_menu;
|
||||
bool is_slowmotion;
|
||||
|
||||
/* Turbo support. */
|
||||
bool turbo_frame_enable[MAX_USERS];
|
||||
@ -780,6 +786,7 @@ struct global
|
||||
|
||||
/* Public data structures. */
|
||||
extern struct settings g_settings;
|
||||
extern struct runloop g_runloop;
|
||||
extern struct global g_extern;
|
||||
extern struct defaults g_defaults;
|
||||
|
||||
|
@ -1668,7 +1668,7 @@ static bool d3d_frame(void *data, const void *frame,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (g_extern.is_menu
|
||||
if (g_runloop.is_menu
|
||||
&& driver.menu_ctx && driver.menu_ctx->frame)
|
||||
driver.menu_ctx->frame();
|
||||
|
||||
|
@ -1585,7 +1585,7 @@ static bool gl_frame(void *data, const void *frame,
|
||||
gl_set_prev_texture(gl, &gl->tex_info);
|
||||
|
||||
#if defined(HAVE_MENU)
|
||||
if (g_extern.is_menu
|
||||
if (g_runloop.is_menu
|
||||
&& driver.menu_ctx && driver.menu_ctx->frame)
|
||||
driver.menu_ctx->frame();
|
||||
|
||||
@ -1641,8 +1641,8 @@ static bool gl_frame(void *data, const void *frame,
|
||||
/* Disable BFI during fast forward, slow-motion,
|
||||
* and pause to prevent flicker. */
|
||||
if (g_settings.video.black_frame_insertion &&
|
||||
!driver.nonblock_state && !g_extern.is_slowmotion
|
||||
&& !g_extern.is_paused)
|
||||
!driver.nonblock_state && !g_runloop.is_slowmotion
|
||||
&& !g_runloop.is_paused)
|
||||
{
|
||||
gl->ctx_driver->swap_buffers(gl);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
@ -501,7 +501,7 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width,
|
||||
SDL_RenderCopyEx(vid->renderer, vid->frame.tex, NULL, NULL, vid->rotation, NULL, SDL_FLIP_NONE);
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (g_extern.is_menu
|
||||
if (g_runloop.is_menu
|
||||
&& driver.menu_ctx && driver.menu_ctx->frame)
|
||||
driver.menu_ctx->frame();
|
||||
#endif
|
||||
|
@ -1381,7 +1381,7 @@ static bool sunxi_gfx_frame(void *data, const void *frame, unsigned width,
|
||||
sunxi_layer_show(disp);
|
||||
}
|
||||
|
||||
page = sunxi_get_free_page((void*)_dispvars);
|
||||
page = sunxi_get_free_page(_dispvars);
|
||||
sunxi_blit_flip(page, frame, _dispvars);
|
||||
|
||||
return true;
|
||||
|
@ -394,7 +394,7 @@ static bool thread_alive(void *data)
|
||||
bool ret;
|
||||
thread_video_t *thr = (thread_video_t*)data;
|
||||
|
||||
if (g_extern.is_paused)
|
||||
if (g_runloop.is_paused)
|
||||
{
|
||||
thread_send_cmd(thr, CMD_ALIVE);
|
||||
thread_wait_reply(thr, CMD_ALIVE);
|
||||
|
@ -156,7 +156,7 @@ static void ps3_joypad_poll(void)
|
||||
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_X) : 0;
|
||||
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_SQUARE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
|
||||
|
||||
if (g_extern.is_menu)
|
||||
if (g_runloop.is_menu)
|
||||
{
|
||||
int value = 0;
|
||||
if (cellSysutilGetSystemParamInt(CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN, &value) == 0)
|
||||
|
@ -181,7 +181,7 @@ bool retro_flush_audio(const int16_t *data, size_t samples)
|
||||
driver.recording->push_audio(driver.recording_data, &ffemu_data);
|
||||
}
|
||||
|
||||
if (g_extern.is_paused || g_settings.audio.mute_enable)
|
||||
if (g_runloop.is_paused || g_settings.audio.mute_enable)
|
||||
return true;
|
||||
if (!driver.audio_active || !g_extern.audio_data.data)
|
||||
return false;
|
||||
@ -218,7 +218,7 @@ bool retro_flush_audio(const int16_t *data, size_t samples)
|
||||
audio_driver_readjust_input_rate();
|
||||
|
||||
src_data.ratio = g_extern.audio_data.src_ratio;
|
||||
if (g_extern.is_slowmotion)
|
||||
if (g_runloop.is_slowmotion)
|
||||
src_data.ratio *= g_settings.slowmotion_ratio;
|
||||
|
||||
RARCH_PERFORMANCE_INIT(resampler_proc);
|
||||
|
@ -294,7 +294,7 @@ static void glui_frame(void)
|
||||
return;
|
||||
|
||||
if (menu->need_refresh
|
||||
&& g_extern.is_menu
|
||||
&& g_runloop.is_menu
|
||||
&& !menu->msg_force)
|
||||
return;
|
||||
|
||||
|
@ -320,7 +320,7 @@ static void rgui_render(void)
|
||||
|
||||
if (!menu)
|
||||
return;
|
||||
if (menu->need_refresh && g_extern.is_menu
|
||||
if (menu->need_refresh && g_runloop.is_menu
|
||||
&& !menu->msg_force)
|
||||
return;
|
||||
|
||||
|
@ -164,7 +164,7 @@ static void rmenu_render(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (menu->need_refresh && g_extern.is_menu
|
||||
if (menu->need_refresh && g_runloop.is_menu
|
||||
&& !menu->msg_force)
|
||||
return;
|
||||
|
||||
|
@ -557,7 +557,7 @@ static void rmenu_xui_render(void)
|
||||
if (!menu)
|
||||
return;
|
||||
if (menu->need_refresh &&
|
||||
g_extern.is_menu && !menu->msg_force)
|
||||
g_runloop.is_menu && !menu->msg_force)
|
||||
return;
|
||||
|
||||
rmenu_xui_render_background();
|
||||
|
@ -396,7 +396,7 @@ int menu_iterate(retro_input_t input,
|
||||
ret = driver.menu_ctx->entry_iterate(action);
|
||||
}
|
||||
|
||||
if (g_extern.is_menu)
|
||||
if (g_runloop.is_menu)
|
||||
draw_frame();
|
||||
if (g_settings.menu.throttle && (g_settings.menu.pause_libretro || !g_extern.content_is_init))
|
||||
draw_frame();
|
||||
|
19
retroarch.c
19
retroarch.c
@ -1622,6 +1622,7 @@ static void main_clear_state_extern(void)
|
||||
rarch_main_command(RARCH_CMD_HISTORY_DEINIT);
|
||||
|
||||
memset(&g_extern, 0, sizeof(g_extern));
|
||||
memset(&g_runloop, 0, sizeof(g_runloop));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1979,7 +1980,7 @@ void rarch_main_set_state(unsigned cmd)
|
||||
|
||||
menu->need_refresh = true;
|
||||
g_extern.system.frame_time_last = 0;
|
||||
g_extern.is_menu = true;
|
||||
g_runloop.is_menu = true;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@ -1999,7 +2000,7 @@ void rarch_main_set_state(unsigned cmd)
|
||||
if (driver.menu_ctx && driver.menu_ctx->toggle)
|
||||
driver.menu_ctx->toggle(false);
|
||||
|
||||
g_extern.is_menu = false;
|
||||
g_runloop.is_menu = false;
|
||||
|
||||
driver_set_nonblock_state(driver.nonblock_state);
|
||||
|
||||
@ -2197,7 +2198,7 @@ bool rarch_main_command(unsigned cmd)
|
||||
g_extern.pending.windowed_scale = 0;
|
||||
break;
|
||||
case RARCH_CMD_MENU_TOGGLE:
|
||||
if (g_extern.is_menu)
|
||||
if (g_runloop.is_menu)
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED);
|
||||
else
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING);
|
||||
@ -2255,7 +2256,7 @@ bool rarch_main_command(unsigned cmd)
|
||||
driver.input->poll(driver.input_data);
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (g_extern.is_menu)
|
||||
if (g_runloop.is_menu)
|
||||
rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE);
|
||||
#endif
|
||||
break;
|
||||
@ -2512,7 +2513,7 @@ bool rarch_main_command(unsigned cmd)
|
||||
#endif
|
||||
break;
|
||||
case RARCH_CMD_PAUSE_CHECKS:
|
||||
if (g_extern.is_paused)
|
||||
if (g_runloop.is_paused)
|
||||
{
|
||||
RARCH_LOG("Paused.\n");
|
||||
rarch_main_command(RARCH_CMD_AUDIO_STOP);
|
||||
@ -2527,19 +2528,19 @@ bool rarch_main_command(unsigned cmd)
|
||||
}
|
||||
break;
|
||||
case RARCH_CMD_PAUSE_TOGGLE:
|
||||
g_extern.is_paused = !g_extern.is_paused;
|
||||
g_runloop.is_paused = !g_runloop.is_paused;
|
||||
rarch_main_command(RARCH_CMD_PAUSE_CHECKS);
|
||||
break;
|
||||
case RARCH_CMD_UNPAUSE:
|
||||
g_extern.is_paused = false;
|
||||
g_runloop.is_paused = false;
|
||||
rarch_main_command(RARCH_CMD_PAUSE_CHECKS);
|
||||
break;
|
||||
case RARCH_CMD_PAUSE:
|
||||
g_extern.is_paused = true;
|
||||
g_runloop.is_paused = true;
|
||||
rarch_main_command(RARCH_CMD_PAUSE_CHECKS);
|
||||
break;
|
||||
case RARCH_CMD_MENU_PAUSE_LIBRETRO:
|
||||
if (g_extern.is_menu)
|
||||
if (g_runloop.is_menu)
|
||||
{
|
||||
if (g_settings.menu.pause_libretro)
|
||||
rarch_main_command(RARCH_CMD_AUDIO_STOP);
|
||||
|
26
runloop.c
26
runloop.c
@ -80,11 +80,11 @@ static bool check_pause(bool pressed, bool frameadvance_pressed)
|
||||
{
|
||||
static bool old_focus = true;
|
||||
bool focus = true;
|
||||
bool old_is_paused = g_extern.is_paused;
|
||||
bool old_is_paused = g_runloop.is_paused;
|
||||
unsigned cmd = RARCH_CMD_NONE;
|
||||
|
||||
/* FRAMEADVANCE will set us into pause mode. */
|
||||
pressed |= !g_extern.is_paused && frameadvance_pressed;
|
||||
pressed |= !g_runloop.is_paused && frameadvance_pressed;
|
||||
|
||||
if (g_settings.pause_nonactive)
|
||||
focus = video_driver_has_focus();
|
||||
@ -101,7 +101,7 @@ static bool check_pause(bool pressed, bool frameadvance_pressed)
|
||||
if (cmd != RARCH_CMD_NONE)
|
||||
rarch_main_command(cmd);
|
||||
|
||||
if (g_extern.is_paused == old_is_paused)
|
||||
if (g_runloop.is_paused == old_is_paused)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -246,7 +246,7 @@ static void check_rewind(bool pressed)
|
||||
setup_rewind_audio();
|
||||
|
||||
msg_queue_push(g_extern.msg_queue, RETRO_MSG_REWINDING, 0,
|
||||
g_extern.is_paused ? 1 : 30);
|
||||
g_runloop.is_paused ? 1 : 30);
|
||||
pretro_unserialize(buf, g_extern.rewind.size);
|
||||
|
||||
if (g_extern.bsv.movie)
|
||||
@ -288,9 +288,9 @@ static void check_rewind(bool pressed)
|
||||
**/
|
||||
static void check_slowmotion(bool pressed)
|
||||
{
|
||||
g_extern.is_slowmotion = pressed;
|
||||
g_runloop.is_slowmotion = pressed;
|
||||
|
||||
if (!g_extern.is_slowmotion)
|
||||
if (!g_runloop.is_slowmotion)
|
||||
return;
|
||||
|
||||
if (g_settings.video.black_frame_insertion)
|
||||
@ -474,7 +474,7 @@ static void check_cheats(retro_input_t trigger_input)
|
||||
#ifdef HAVE_MENU
|
||||
static void do_state_check_menu_toggle(void)
|
||||
{
|
||||
if (g_extern.is_menu)
|
||||
if (g_runloop.is_menu)
|
||||
{
|
||||
if (g_extern.main_is_init && !g_extern.libretro_dummy)
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED);
|
||||
@ -506,7 +506,7 @@ static int do_pre_state_checks(
|
||||
if (BIT64_GET(trigger_input, RARCH_OVERLAY_NEXT))
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_NEXT);
|
||||
|
||||
if (!g_extern.is_paused || g_extern.is_menu)
|
||||
if (!g_runloop.is_paused || g_runloop.is_menu)
|
||||
{
|
||||
if (BIT64_GET(trigger_input, RARCH_FULLSCREEN_TOGGLE_KEY))
|
||||
rarch_main_command(RARCH_CMD_FULLSCREEN_TOGGLE);
|
||||
@ -543,7 +543,7 @@ static int do_pause_state_checks(
|
||||
{
|
||||
check_pause_func(trigger_input);
|
||||
|
||||
if (!g_extern.is_paused)
|
||||
if (!g_runloop.is_paused)
|
||||
return 0;
|
||||
|
||||
if (BIT64_GET(trigger_input, RARCH_FULLSCREEN_TOGGLE_KEY))
|
||||
@ -667,13 +667,13 @@ static void update_frame_time(void)
|
||||
{
|
||||
retro_time_t curr_time = rarch_get_time_usec();
|
||||
retro_time_t delta = curr_time - g_extern.system.frame_time_last;
|
||||
bool is_locked_fps = g_extern.is_paused || driver.nonblock_state;
|
||||
bool is_locked_fps = g_runloop.is_paused || driver.nonblock_state;
|
||||
is_locked_fps |= !!driver.recording_data;
|
||||
|
||||
if (!g_extern.system.frame_time_last || is_locked_fps)
|
||||
delta = g_extern.system.frame_time.reference;
|
||||
|
||||
if (!is_locked_fps && g_extern.is_slowmotion)
|
||||
if (!is_locked_fps && g_runloop.is_slowmotion)
|
||||
delta /= g_settings.slowmotion_ratio;
|
||||
|
||||
g_extern.system.frame_time_last = curr_time;
|
||||
@ -841,7 +841,7 @@ static bool input_flush(retro_input_t *input)
|
||||
|
||||
/* If core was paused before entering menu, evoke
|
||||
* pause toggle to wake it up. */
|
||||
if (g_extern.is_paused)
|
||||
if (g_runloop.is_paused)
|
||||
BIT64_SET(*input, RARCH_PAUSE_TOGGLE);
|
||||
|
||||
return true;
|
||||
@ -969,7 +969,7 @@ int rarch_main_iterate(void)
|
||||
do_data_state_checks();
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (g_extern.is_menu)
|
||||
if (g_runloop.is_menu)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_resolve();
|
||||
if (menu)
|
||||
|
@ -292,9 +292,9 @@ bool take_screenshot(void)
|
||||
msg = RETRO_MSG_TAKE_SCREENSHOT_FAILED;
|
||||
}
|
||||
|
||||
msg_queue_push(g_extern.msg_queue, msg, 1, g_extern.is_paused ? 1 : 180);
|
||||
msg_queue_push(g_extern.msg_queue, msg, 1, g_runloop.is_paused ? 1 : 180);
|
||||
|
||||
if (g_extern.is_paused)
|
||||
if (g_runloop.is_paused)
|
||||
rarch_render_cached_frame();
|
||||
|
||||
return ret;
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
struct settings g_settings;
|
||||
struct global g_extern;
|
||||
struct runloop g_runloop;
|
||||
struct defaults g_defaults;
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user