Create rarch_main_get_ptr

This commit is contained in:
twinaphex 2015-03-18 06:47:22 +01:00
parent 8fd08bb6fe
commit 7378299282
31 changed files with 232 additions and 153 deletions

View File

@ -231,11 +231,14 @@ enum
void switch_to_ios(void) void switch_to_ios(void)
{ {
RetroArch_iOS *ap;
runloop_t *runloop = rarch_main_get_ptr();
if (!apple_platform) if (!apple_platform)
return; return;
RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform; ap = (RetroArch_iOS *)apple_platform;
g_runloop.is_idle = true; runloop->is_idle = true;
[ap showPauseMenu:ap]; [ap showPauseMenu:ap];
} }
@ -288,6 +291,7 @@ static void rarch_main_event_pump(void)
- (void) rarch_draw:(id)sender - (void) rarch_draw:(id)sender
{ {
runloop_t *runloop = rarch_main_get_ptr();
int ret = 0; int ret = 0;
if (displayLink == nil) if (displayLink == nil)
@ -300,7 +304,7 @@ static void rarch_main_event_pump(void)
if (ret == -1) if (ret == -1)
goto exit; goto exit;
if (g_runloop.is_idle) if (runloop->is_idle)
return; return;
if (g_view) if (g_view)
@ -375,19 +379,24 @@ exit:
- (void)showGameView - (void)showGameView
{ {
runloop_t *runloop = rarch_main_get_ptr();
[self popToRootViewControllerAnimated:NO]; [self popToRootViewControllerAnimated:NO];
[self setToolbarHidden:true animated:NO]; [self setToolbarHidden:true animated:NO];
[[UIApplication sharedApplication] setStatusBarHidden:true withAnimation:UIStatusBarAnimationNone]; [[UIApplication sharedApplication] setStatusBarHidden:true withAnimation:UIStatusBarAnimationNone];
[[UIApplication sharedApplication] setIdleTimerDisabled:true]; [[UIApplication sharedApplication] setIdleTimerDisabled:true];
[self.window setRootViewController:[RAGameView get]]; [self.window setRootViewController:[RAGameView get]];
g_runloop.is_paused = false;
g_runloop.is_idle = false; runloop->is_paused = false;
runloop->is_idle = false;
} }
- (IBAction)showPauseMenu:(id)sender - (IBAction)showPauseMenu:(id)sender
{ {
g_runloop.is_paused = true; runloop_t *runloop = rarch_main_get_ptr();
g_runloop.is_idle = true;
runloop->is_paused = true;
runloop->is_idle = true;
[[UIApplication sharedApplication] setStatusBarHidden:false withAnimation:UIStatusBarAnimationNone]; [[UIApplication sharedApplication] setStatusBarHidden:false withAnimation:UIStatusBarAnimationNone];
[[UIApplication sharedApplication] setIdleTimerDisabled:false]; [[UIApplication sharedApplication] setIdleTimerDisabled:false];
[self.window setRootViewController:self]; [self.window setRootViewController:self];

View File

@ -95,20 +95,23 @@ static void compute_audio_buffer_statistics(void)
float avg_filled, deviation; float avg_filled, deviation;
uint64_t accum = 0, accum_var = 0; uint64_t accum = 0, accum_var = 0;
unsigned low_water_count = 0, high_water_count = 0; unsigned low_water_count = 0, high_water_count = 0;
unsigned samples = min(g_runloop.measure_data.buffer_free_samples_count, unsigned samples = 0;
runloop_t *runloop = rarch_main_get_ptr();
samples = min(runloop->measure_data.buffer_free_samples_count,
AUDIO_BUFFER_FREE_SAMPLES_COUNT); AUDIO_BUFFER_FREE_SAMPLES_COUNT);
if (samples < 3) if (samples < 3)
return; return;
for (i = 1; i < samples; i++) for (i = 1; i < samples; i++)
accum += g_runloop.measure_data.buffer_free_samples[i]; accum += runloop->measure_data.buffer_free_samples[i];
avg = accum / (samples - 1); avg = accum / (samples - 1);
for (i = 1; i < samples; i++) for (i = 1; i < samples; i++)
{ {
int diff = avg - g_runloop.measure_data.buffer_free_samples[i]; int diff = avg - runloop->measure_data.buffer_free_samples[i];
accum_var += diff * diff; accum_var += diff * diff;
} }
@ -121,9 +124,9 @@ static void compute_audio_buffer_statistics(void)
for (i = 1; i < samples; i++) for (i = 1; i < samples; i++)
{ {
if (g_runloop.measure_data.buffer_free_samples[i] >= low_water_size) if (runloop->measure_data.buffer_free_samples[i] >= low_water_size)
low_water_count++; low_water_count++;
else if (g_runloop.measure_data.buffer_free_samples[i] <= high_water_size) else if (runloop->measure_data.buffer_free_samples[i] <= high_water_size)
high_water_count++; high_water_count++;
} }
@ -265,6 +268,7 @@ void uninit_audio(void)
void init_audio(void) void init_audio(void)
{ {
size_t outsamples_max, max_bufsamples = AUDIO_CHUNK_SIZE_NONBLOCKING * 2; size_t outsamples_max, max_bufsamples = AUDIO_CHUNK_SIZE_NONBLOCKING * 2;
runloop_t *runloop = rarch_main_get_ptr();
audio_convert_init_simd(); audio_convert_init_simd();
@ -383,7 +387,7 @@ void init_audio(void)
rarch_main_command(RARCH_CMD_DSP_FILTER_DEINIT); rarch_main_command(RARCH_CMD_DSP_FILTER_DEINIT);
g_runloop.measure_data.buffer_free_samples_count = 0; runloop->measure_data.buffer_free_samples_count = 0;
if (driver.audio_active && !g_settings.audio.mute_enable && if (driver.audio_active && !g_settings.audio.mute_enable &&
g_extern.system.audio_callback.callback) g_extern.system.audio_callback.callback)
@ -419,24 +423,24 @@ bool audio_driver_mute_toggle(void)
void audio_driver_readjust_input_rate(void) void audio_driver_readjust_input_rate(void)
{ {
double direction, adjust; double direction, adjust;
int half_size, delta_mid, avail; int half_size, delta_mid;
unsigned write_idx; unsigned write_idx;
int avail = driver.audio->write_avail(driver.audio_data);
avail = driver.audio->write_avail(driver.audio_data); runloop_t *runloop = rarch_main_get_ptr();
#if 0 #if 0
RARCH_LOG_OUTPUT("Audio buffer is %u%% full\n", RARCH_LOG_OUTPUT("Audio buffer is %u%% full\n",
(unsigned)(100 - (avail * 100) / g_extern.audio_data.driver_buffer_size)); (unsigned)(100 - (avail * 100) / g_extern.audio_data.driver_buffer_size));
#endif #endif
write_idx = g_runloop.measure_data.buffer_free_samples_count++ & write_idx = runloop->measure_data.buffer_free_samples_count++ &
(AUDIO_BUFFER_FREE_SAMPLES_COUNT - 1); (AUDIO_BUFFER_FREE_SAMPLES_COUNT - 1);
half_size = g_extern.audio_data.driver_buffer_size / 2; half_size = g_extern.audio_data.driver_buffer_size / 2;
delta_mid = avail - half_size; delta_mid = avail - half_size;
direction = (double)delta_mid / half_size; direction = (double)delta_mid / half_size;
adjust = 1.0 + g_settings.audio.rate_control_delta * direction; adjust = 1.0 + g_settings.audio.rate_control_delta * direction;
g_runloop.measure_data.buffer_free_samples[write_idx] = avail; runloop->measure_data.buffer_free_samples[write_idx] = avail;
g_extern.audio_data.src_ratio = g_extern.audio_data.orig_src_ratio * adjust; g_extern.audio_data.src_ratio = g_extern.audio_data.orig_src_ratio * adjust;
#if 0 #if 0

View File

@ -321,7 +321,9 @@ void init_drivers(int flags)
if (flags & DRIVER_VIDEO) if (flags & DRIVER_VIDEO)
{ {
g_runloop.frames.video.count = 0; runloop_t *runloop = rarch_main_get_ptr();
runloop->frames.video.count = 0;
init_video(); init_video();

View File

@ -168,7 +168,9 @@ bool read_compressed_file(const char * path, void **buf,
//We split carchive path and relative path: //We split carchive path and relative path:
strlcpy(archive_path, path, sizeof(archive_path)); strlcpy(archive_path, path, sizeof(archive_path));
archive_found = (char*)strchr(archive_path,'#'); archive_found = (char*)strchr(archive_path,'#');
rarch_assert(archive_found != NULL); rarch_assert(archive_found != NULL);
//We assure that there is something after the '#' symbol //We assure that there is something after the '#' symbol

View File

@ -36,6 +36,7 @@ void engine_handle_cmd(void *data)
{ {
int8_t cmd; int8_t cmd;
struct android_app *android_app = (struct android_app*)g_android; struct android_app *android_app = (struct android_app*)g_android;
runloop_t *runloop = rarch_main_get_ptr();
if (read(android_app->msgread, &cmd, sizeof(cmd)) != sizeof(cmd)) if (read(android_app->msgread, &cmd, sizeof(cmd)) != sizeof(cmd))
cmd = -1; cmd = -1;
@ -69,7 +70,7 @@ void engine_handle_cmd(void *data)
scond_broadcast(android_app->cond); scond_broadcast(android_app->cond);
slock_unlock(android_app->mutex); slock_unlock(android_app->mutex);
if (g_runloop.is_paused) if (runloop->is_paused)
rarch_main_command(RARCH_CMD_REINIT); rarch_main_command(RARCH_CMD_REINIT);
break; break;
@ -96,8 +97,8 @@ void engine_handle_cmd(void *data)
if (!g_extern.system.shutdown) if (!g_extern.system.shutdown)
{ {
RARCH_LOG("Pausing RetroArch.\n"); RARCH_LOG("Pausing RetroArch.\n");
g_runloop.is_paused = true; runloop->is_paused = true;
g_runloop.is_idle = true; runloop->is_idle = true;
} }
break; break;
@ -126,8 +127,8 @@ void engine_handle_cmd(void *data)
break; break;
case APP_CMD_GAINED_FOCUS: case APP_CMD_GAINED_FOCUS:
g_runloop.is_paused = false; runloop->is_paused = false;
g_runloop.is_idle = false; runloop->is_idle = false;
if ((android_app->sensor_state_mask if ((android_app->sensor_state_mask
& (1ULL << RETRO_SENSOR_ACCELEROMETER_ENABLE)) & (1ULL << RETRO_SENSOR_ACCELEROMETER_ENABLE))

View File

@ -409,10 +409,11 @@ static bool d3d_alive(void *data)
d3d_video_t *d3d = (d3d_video_t*)data; d3d_video_t *d3d = (d3d_video_t*)data;
bool quit = false; bool quit = false;
bool resize = false; bool resize = false;
runloop_t *runloop = rarch_main_get_ptr();
if (d3d->ctx_driver && d3d->ctx_driver->check_window) if (d3d->ctx_driver && d3d->ctx_driver->check_window)
d3d->ctx_driver->check_window(d3d, &quit, &resize, d3d->ctx_driver->check_window(d3d, &quit, &resize,
&d3d->screen_width, &d3d->screen_height, g_runloop.frames.video.count); &d3d->screen_width, &d3d->screen_height, runloop->frames.video.count);
if (quit) if (quit)
d3d->quitting = quit; d3d->quitting = quit;
@ -1604,6 +1605,7 @@ static bool d3d_frame(void *data, const void *frame,
unsigned i = 0; unsigned i = 0;
d3d_video_t *d3d = (d3d_video_t*)data; d3d_video_t *d3d = (d3d_video_t*)data;
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
runloop_t *runloop = rarch_main_get_ptr();
(void)i; (void)i;
@ -1705,7 +1707,7 @@ static bool d3d_frame(void *data, const void *frame,
#endif #endif
#ifdef HAVE_MENU #ifdef HAVE_MENU
if (g_runloop.is_menu if (runloop->is_menu
&& driver.menu_ctx && driver.menu_ctx->frame) && driver.menu_ctx && driver.menu_ctx->frame)
driver.menu_ctx->frame(); driver.menu_ctx->frame();

View File

@ -114,6 +114,7 @@ static void renderchain_render_pass(void *data, const void *frame, unsigned widt
{ {
d3d_video_t *d3d = (d3d_video_t*)data; d3d_video_t *d3d = (d3d_video_t*)data;
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
runloop_t *runloop = rarch_main_get_ptr();
#if defined(_XBOX1) #if defined(_XBOX1)
d3dr->SetFlickerFilter(g_extern.console.screen.flicker_filter_index); d3dr->SetFlickerFilter(g_extern.console.screen.flicker_filter_index);
@ -138,7 +139,7 @@ static void renderchain_render_pass(void *data, const void *frame, unsigned widt
d3d_draw_primitive(d3dr, D3DPT_TRIANGLESTRIP, 0, 2); d3d_draw_primitive(d3dr, D3DPT_TRIANGLESTRIP, 0, 2);
g_runloop.frames.video.count++; runloop->frames.video.count++;
renderchain_set_mvp(d3d, d3d->screen_width, d3d->screen_height, d3d->dev_rotation); renderchain_set_mvp(d3d, d3d->screen_width, d3d->screen_height, d3d->dev_rotation);
} }
@ -146,6 +147,7 @@ static void renderchain_render_pass(void *data, const void *frame, unsigned widt
static void renderchain_set_vertices(void *data, unsigned pass, unsigned width, unsigned height) static void renderchain_set_vertices(void *data, unsigned pass, unsigned width, unsigned height)
{ {
d3d_video_t *d3d = (d3d_video_t*)data; d3d_video_t *d3d = (d3d_video_t*)data;
runloop_t *runloop = rarch_main_get_ptr();
if (d3d->last_width != width || d3d->last_height != height) if (d3d->last_width != width || d3d->last_height != height)
{ {
@ -222,7 +224,7 @@ static void renderchain_set_vertices(void *data, unsigned pass, unsigned width,
d3d->shader->use(d3d, pass); d3d->shader->use(d3d, pass);
if (d3d->shader->set_params) if (d3d->shader->set_params)
d3d->shader->set_params(d3d, width, height, d3d->tex_w, d3d->tex_h, d3d->screen_width, d3d->shader->set_params(d3d, width, height, d3d->tex_w, d3d->tex_h, d3d->screen_width,
d3d->screen_height, g_runloop.frames.video.count, d3d->screen_height, runloop->frames.video.count,
NULL, NULL, NULL, 0); NULL, NULL, NULL, 0);
} }
#endif #endif

View File

@ -959,6 +959,7 @@ static void gl_frame_fbo(gl_t *gl,
GLfloat xamt, yamt; GLfloat xamt, yamt;
unsigned fbo_tex_info_cnt = 0; unsigned fbo_tex_info_cnt = 0;
GLfloat fbo_tex_coords[8] = {0.0f}; GLfloat fbo_tex_coords[8] = {0.0f};
runloop_t *runloop = rarch_main_get_ptr();
/* Render the rest of our passes. */ /* Render the rest of our passes. */
gl->coords.tex_coord = fbo_tex_coords; gl->coords.tex_coord = fbo_tex_coords;
@ -998,7 +999,7 @@ static void gl_frame_fbo(gl_t *gl,
gl_set_viewport(gl, rect->img_width, rect->img_height, true, false); gl_set_viewport(gl, rect->img_width, rect->img_height, true, false);
gl->shader->set_params(gl, prev_rect->img_width, prev_rect->img_height, gl->shader->set_params(gl, prev_rect->img_width, prev_rect->img_height,
prev_rect->width, prev_rect->height, prev_rect->width, prev_rect->height,
gl->vp.width, gl->vp.height, g_runloop.frames.video.count, gl->vp.width, gl->vp.height, runloop->frames.video.count,
tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt); tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt);
gl->coords.vertices = 4; gl->coords.vertices = 4;
@ -1045,7 +1046,7 @@ static void gl_frame_fbo(gl_t *gl,
gl->shader->set_params(gl, gl->shader->set_params(gl,
prev_rect->img_width, prev_rect->img_height, prev_rect->img_width, prev_rect->img_height,
prev_rect->width, prev_rect->height, prev_rect->width, prev_rect->height,
gl->vp.width, gl->vp.height, g_runloop.frames.video.count, gl->vp.width, gl->vp.height, runloop->frames.video.count,
tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt); tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt);
gl->coords.vertex = gl->vertex_ptr; gl->coords.vertex = gl->vertex_ptr;
@ -1462,6 +1463,7 @@ static bool gl_frame(void *data, const void *frame,
unsigned width, unsigned height, unsigned pitch, const char *msg) unsigned width, unsigned height, unsigned pitch, const char *msg)
{ {
gl_t *gl = (gl_t*)data; gl_t *gl = (gl_t*)data;
runloop_t *runloop = rarch_main_get_ptr();
RARCH_PERFORMANCE_INIT(frame_run); RARCH_PERFORMANCE_INIT(frame_run);
RARCH_PERFORMANCE_START(frame_run); RARCH_PERFORMANCE_START(frame_run);
@ -1571,7 +1573,7 @@ static bool gl_frame(void *data, const void *frame,
gl->shader->set_params(gl, width, height, gl->shader->set_params(gl, width, height,
gl->tex_w, gl->tex_h, gl->tex_w, gl->tex_h,
gl->vp.width, gl->vp.height, gl->vp.width, gl->vp.height,
g_runloop.frames.video.count, runloop->frames.video.count,
&gl->tex_info, gl->prev_info, NULL, 0); &gl->tex_info, gl->prev_info, NULL, 0);
gl->coords.vertices = 4; gl->coords.vertices = 4;
@ -1587,7 +1589,7 @@ static bool gl_frame(void *data, const void *frame,
gl_set_prev_texture(gl, &gl->tex_info); gl_set_prev_texture(gl, &gl->tex_info);
#if defined(HAVE_MENU) #if defined(HAVE_MENU)
if (g_runloop.is_menu if (runloop->is_menu
&& driver.menu_ctx && driver.menu_ctx->frame) && driver.menu_ctx && driver.menu_ctx->frame)
driver.menu_ctx->frame(); driver.menu_ctx->frame();
@ -1643,8 +1645,8 @@ static bool gl_frame(void *data, const void *frame,
/* Disable BFI during fast forward, slow-motion, /* Disable BFI during fast forward, slow-motion,
* and pause to prevent flicker. */ * and pause to prevent flicker. */
if (g_settings.video.black_frame_insertion && if (g_settings.video.black_frame_insertion &&
!driver.nonblock_state && !g_runloop.is_slowmotion !driver.nonblock_state && !runloop->is_slowmotion
&& !g_runloop.is_paused) && !runloop->is_paused)
{ {
gl->ctx_driver->swap_buffers(gl); gl->ctx_driver->swap_buffers(gl);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
@ -2430,13 +2432,14 @@ static bool gl_alive(void *data)
{ {
bool quit = false, resize = false; bool quit = false, resize = false;
gl_t *gl = (gl_t*)data; gl_t *gl = (gl_t*)data;
runloop_t *runloop = rarch_main_get_ptr();
if (!gl) if (!gl)
return false; return false;
gl->ctx_driver->check_window(gl, &quit, gl->ctx_driver->check_window(gl, &quit,
&resize, &gl->win_width, &gl->win_height, &resize, &gl->win_width, &gl->win_height,
g_runloop.frames.video.count); runloop->frames.video.count);
if (quit) if (quit)
gl->quitting = true; gl->quitting = true;

View File

@ -484,6 +484,7 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width,
{ {
char buf[128]; char buf[128];
sdl2_video_t *vid = (sdl2_video_t*)data; sdl2_video_t *vid = (sdl2_video_t*)data;
runloop_t *runloop = rarch_main_get_ptr();
if (vid->should_resize) if (vid->should_resize)
sdl_refresh_viewport(vid); sdl_refresh_viewport(vid);
@ -503,7 +504,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); SDL_RenderCopyEx(vid->renderer, vid->frame.tex, NULL, NULL, vid->rotation, NULL, SDL_FLIP_NONE);
#ifdef HAVE_MENU #ifdef HAVE_MENU
if (g_runloop.is_menu if (runloop->is_menu
&& driver.menu_ctx && driver.menu_ctx->frame) && driver.menu_ctx && driver.menu_ctx->frame)
driver.menu_ctx->frame(); driver.menu_ctx->frame();
#endif #endif

View File

@ -406,12 +406,13 @@ static bool vg_frame(void *data, const void *frame, unsigned width, unsigned hei
static bool vg_alive(void *data) static bool vg_alive(void *data)
{ {
vg_t *vg = (vg_t*)data;
bool quit; bool quit;
vg_t *vg = (vg_t*)data;
runloop_t *runloop = rarch_main_get_ptr();
vg->driver->check_window(vg, &quit, vg->driver->check_window(vg, &quit,
&vg->should_resize, &vg->mScreenWidth, &vg->mScreenHeight, &vg->should_resize, &vg->mScreenWidth, &vg->mScreenHeight,
g_runloop.frames.video.count); runloop->frames.video.count);
return !quit; return !quit;
} }

View File

@ -391,6 +391,7 @@ void init_video(void)
const struct retro_game_geometry *geom = NULL; const struct retro_game_geometry *geom = NULL;
video_info_t video = {0}; video_info_t video = {0};
static uint16_t dummy_pixels[32] = {0}; static uint16_t dummy_pixels[32] = {0};
runloop_t *runloop = rarch_main_get_ptr();
init_video_filter(g_extern.system.pix_fmt); init_video_filter(g_extern.system.pix_fmt);
rarch_main_command(RARCH_CMD_SHADER_DIR_INIT); rarch_main_command(RARCH_CMD_SHADER_DIR_INIT);
@ -529,7 +530,7 @@ void init_video(void)
rarch_main_command(RARCH_CMD_OVERLAY_DEINIT); rarch_main_command(RARCH_CMD_OVERLAY_DEINIT);
rarch_main_command(RARCH_CMD_OVERLAY_INIT); rarch_main_command(RARCH_CMD_OVERLAY_INIT);
g_runloop.measure_data.frame_time_samples_count = 0; runloop->measure_data.frame_time_samples_count = 0;
g_extern.frame_cache.width = 4; g_extern.frame_cache.width = 4;
g_extern.frame_cache.height = 4; g_extern.frame_cache.height = 4;

View File

@ -75,6 +75,7 @@ void video_monitor_compute_fps_statistics(void)
{ {
double avg_fps = 0.0, stddev = 0.0; double avg_fps = 0.0, stddev = 0.0;
unsigned samples = 0; unsigned samples = 0;
runloop_t *runloop = rarch_main_get_ptr();
if (g_settings.video.threaded) if (g_settings.video.threaded)
{ {
@ -82,7 +83,7 @@ void video_monitor_compute_fps_statistics(void)
return; return;
} }
if (g_runloop.measure_data.frame_time_samples_count < if (runloop->measure_data.frame_time_samples_count <
2 * MEASURE_FRAME_TIME_SAMPLES_COUNT) 2 * MEASURE_FRAME_TIME_SAMPLES_COUNT)
{ {
RARCH_LOG( RARCH_LOG(
@ -118,20 +119,23 @@ bool video_monitor_fps_statistics(double *refresh_rate,
{ {
unsigned i; unsigned i;
retro_time_t accum = 0, avg, accum_var = 0; retro_time_t accum = 0, avg, accum_var = 0;
unsigned samples = min(MEASURE_FRAME_TIME_SAMPLES_COUNT, unsigned samples = 0;
g_runloop.measure_data.frame_time_samples_count); runloop_t *runloop = rarch_main_get_ptr();
samples = min(MEASURE_FRAME_TIME_SAMPLES_COUNT,
runloop->measure_data.frame_time_samples_count);
if (g_settings.video.threaded || (samples < 2)) if (g_settings.video.threaded || (samples < 2))
return false; return false;
/* Measure statistics on frame time (microsecs), *not* FPS. */ /* Measure statistics on frame time (microsecs), *not* FPS. */
for (i = 0; i < samples; i++) for (i = 0; i < samples; i++)
accum += g_runloop.measure_data.frame_time_samples[i]; accum += runloop->measure_data.frame_time_samples[i];
#if 0 #if 0
for (i = 0; i < samples; i++) for (i = 0; i < samples; i++)
RARCH_LOG("Interval #%u: %d usec / frame.\n", RARCH_LOG("Interval #%u: %d usec / frame.\n",
i, (int)g_runloop.measure_data.frame_time_samples[i]); i, (int)runloop->measure_data.frame_time_samples[i]);
#endif #endif
avg = accum / samples; avg = accum / samples;
@ -139,7 +143,7 @@ bool video_monitor_fps_statistics(double *refresh_rate,
/* Drop first measurement. It is likely to be bad. */ /* Drop first measurement. It is likely to be bad. */
for (i = 0; i < samples; i++) for (i = 0; i < samples; i++)
{ {
retro_time_t diff = g_runloop.measure_data.frame_time_samples[i] - avg; retro_time_t diff = runloop->measure_data.frame_time_samples[i] - avg;
accum_var += diff * diff; accum_var += diff * diff;
} }
@ -172,37 +176,39 @@ bool video_monitor_fps_statistics(double *refresh_rate,
bool video_monitor_get_fps(char *buf, size_t size, bool video_monitor_get_fps(char *buf, size_t size,
char *buf_fps, size_t size_fps) char *buf_fps, size_t size_fps)
{ {
static float last_fps;
retro_time_t new_time; retro_time_t new_time;
static retro_time_t curr_time; static retro_time_t curr_time;
static retro_time_t fps_time; static retro_time_t fps_time;
static float last_fps; runloop_t *runloop = rarch_main_get_ptr();
*buf = '\0'; *buf = '\0';
new_time = rarch_get_time_usec(); new_time = rarch_get_time_usec();
if (g_runloop.frames.video.count) if (runloop->frames.video.count)
{ {
bool ret = false; bool ret = false;
unsigned write_index = unsigned write_index =
g_runloop.measure_data.frame_time_samples_count++ & runloop->measure_data.frame_time_samples_count++ &
(MEASURE_FRAME_TIME_SAMPLES_COUNT - 1); (MEASURE_FRAME_TIME_SAMPLES_COUNT - 1);
g_runloop.measure_data.frame_time_samples[write_index] = runloop->measure_data.frame_time_samples[write_index] =
new_time - fps_time; new_time - fps_time;
fps_time = new_time; fps_time = new_time;
if ((g_runloop.frames.video.count % FPS_UPDATE_INTERVAL) == 0) if ((runloop->frames.video.count % FPS_UPDATE_INTERVAL) == 0)
{ {
last_fps = TIME_TO_FPS(curr_time, new_time, FPS_UPDATE_INTERVAL); last_fps = TIME_TO_FPS(curr_time, new_time, FPS_UPDATE_INTERVAL);
curr_time = new_time; curr_time = new_time;
snprintf(buf, size, "%s || FPS: %6.1f || Frames: %u", snprintf(buf, size, "%s || FPS: %6.1f || Frames: %u",
g_extern.title_buf, last_fps, g_runloop.frames.video.count); g_extern.title_buf, last_fps, runloop->frames.video.count);
ret = true; ret = true;
} }
if (buf_fps) if (buf_fps)
snprintf(buf_fps, size_fps, "FPS: %6.1f || Frames: %u", snprintf(buf_fps, size_fps, "FPS: %6.1f || Frames: %u",
last_fps, g_runloop.frames.video.count); last_fps, runloop->frames.video.count);
return ret; return ret;
} }

View File

@ -393,8 +393,9 @@ static bool thread_alive(void *data)
{ {
bool ret; bool ret;
thread_video_t *thr = (thread_video_t*)data; thread_video_t *thr = (thread_video_t*)data;
runloop_t *runloop = rarch_main_get_ptr();
if (g_runloop.is_paused) if (runloop->is_paused)
{ {
thread_send_cmd(thr, CMD_ALIVE); thread_send_cmd(thr, CMD_ALIVE);
thread_wait_reply(thr, CMD_ALIVE); thread_wait_reply(thr, CMD_ALIVE);

View File

@ -119,6 +119,7 @@ static void ps3_joypad_poll(void)
unsigned port; unsigned port;
CellPadInfo2 pad_info; CellPadInfo2 pad_info;
uint64_t *lifecycle_state = (uint64_t*)&g_extern.lifecycle_state; uint64_t *lifecycle_state = (uint64_t*)&g_extern.lifecycle_state;
runloop_t *runloop = rarch_main_get_ptr();
for (port = 0; port < MAX_PADS; port++) for (port = 0; port < MAX_PADS; port++)
{ {
@ -158,7 +159,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_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; *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_SQUARE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
if (g_runloop.is_menu) if (runloop->is_menu)
{ {
int value = 0; int value = 0;
if (cellSysutilGetSystemParamInt(CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN, &value) == 0) if (cellSysutilGetSystemParamInt(CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN, &value) == 0)

View File

@ -113,6 +113,7 @@ static void video_frame(const void *data, unsigned width,
{ {
unsigned output_width = 0, output_height = 0, output_pitch = 0; unsigned output_width = 0, output_height = 0, output_pitch = 0;
const char *msg = NULL; const char *msg = NULL;
runloop_t *runloop = rarch_main_get_ptr();
if (!driver.video_active) if (!driver.video_active)
return; return;
@ -152,7 +153,7 @@ static void video_frame(const void *data, unsigned width,
if (driver.video->frame(driver.video_data, data, width, height, pitch, msg)) if (driver.video->frame(driver.video_data, data, width, height, pitch, msg))
{ {
g_runloop.frames.video.count++; runloop->frames.video.count++;
return; return;
} }
@ -177,6 +178,7 @@ bool retro_flush_audio(const int16_t *data, size_t samples)
size_t output_size = sizeof(float); size_t output_size = sizeof(float);
struct resampler_data src_data = {0}; struct resampler_data src_data = {0};
struct rarch_dsp_data dsp_data = {0}; struct rarch_dsp_data dsp_data = {0};
runloop_t *runloop = rarch_main_get_ptr();
if (driver.recording_data) if (driver.recording_data)
{ {
@ -188,7 +190,7 @@ bool retro_flush_audio(const int16_t *data, size_t samples)
driver.recording->push_audio(driver.recording_data, &ffemu_data); driver.recording->push_audio(driver.recording_data, &ffemu_data);
} }
if (g_runloop.is_paused || g_settings.audio.mute_enable) if (runloop->is_paused || g_settings.audio.mute_enable)
return true; return true;
if (!driver.audio_active || !g_extern.audio_data.data) if (!driver.audio_active || !g_extern.audio_data.data)
return false; return false;
@ -225,7 +227,7 @@ bool retro_flush_audio(const int16_t *data, size_t samples)
audio_driver_readjust_input_rate(); audio_driver_readjust_input_rate();
src_data.ratio = g_extern.audio_data.src_ratio; src_data.ratio = g_extern.audio_data.src_ratio;
if (g_runloop.is_slowmotion) if (runloop->is_slowmotion)
src_data.ratio *= g_settings.slowmotion_ratio; src_data.ratio *= g_settings.slowmotion_ratio;
RARCH_PERFORMANCE_INIT(resampler_proc); RARCH_PERFORMANCE_INIT(resampler_proc);

View File

@ -268,6 +268,7 @@ static void glui_render(void)
glui_handle_t *glui = NULL; glui_handle_t *glui = NULL;
gl_t *gl = NULL; gl_t *gl = NULL;
menu_handle_t *menu = menu_driver_resolve(); menu_handle_t *menu = menu_driver_resolve();
runloop_t *runloop = rarch_main_get_ptr();
if (!menu) if (!menu)
return; return;
@ -291,9 +292,9 @@ static void glui_render(void)
menu->frame_buf.width = gl->win_width; menu->frame_buf.width = gl->win_width;
menu->frame_buf.height = gl->win_height; menu->frame_buf.height = gl->win_height;
g_runloop.frames.video.current.menu.animation.is_active = false; runloop->frames.video.current.menu.animation.is_active = false;
g_runloop.frames.video.current.menu.label.is_updated = false; runloop->frames.video.current.menu.label.is_updated = false;
g_runloop.frames.video.current.menu.framebuf.dirty = false; runloop->frames.video.current.menu.framebuf.dirty = false;
menu->mouse.ptr = (menu->mouse.y - glui->margin) / menu->mouse.ptr = (menu->mouse.y - glui->margin) /
glui->line_height - 2 + menu->begin; glui->line_height - 2 + menu->begin;
@ -328,6 +329,7 @@ static void glui_frame(void)
menu_handle_t *menu = menu_driver_resolve(); menu_handle_t *menu = menu_driver_resolve();
const uint32_t normal_color = FONT_COLOR_ARGB_TO_RGBA(g_settings.menu.entry_normal_color); const uint32_t normal_color = FONT_COLOR_ARGB_TO_RGBA(g_settings.menu.entry_normal_color);
const uint32_t hover_color = FONT_COLOR_ARGB_TO_RGBA(g_settings.menu.entry_hover_color); const uint32_t hover_color = FONT_COLOR_ARGB_TO_RGBA(g_settings.menu.entry_hover_color);
runloop_t *runloop = rarch_main_get_ptr();
if (!menu) if (!menu)
return; return;
@ -343,7 +345,7 @@ static void glui_frame(void)
return; return;
if (menu->need_refresh if (menu->need_refresh
&& g_runloop.is_menu && runloop->is_menu
&& !menu->msg_force) && !menu->msg_force)
return; return;
@ -361,7 +363,7 @@ static void glui_frame(void)
get_title(label, dir, menu_type, title, sizeof(title)); get_title(label, dir, menu_type, title, sizeof(title));
menu_animation_ticker_line(title_buf, glui->term_width - 3, menu_animation_ticker_line(title_buf, glui->term_width - 3,
g_runloop.frames.video.count / glui->margin, title, true); runloop->frames.video.count / glui->margin, title, true);
glui_blit_line(gl, glui->margin * 2, glui->margin + glui->line_height, glui_blit_line(gl, glui->margin * 2, glui->margin + glui->line_height,
title_buf, FONT_COLOR_ARGB_TO_RGBA(g_settings.menu.title_color)); title_buf, FONT_COLOR_ARGB_TO_RGBA(g_settings.menu.title_color));
@ -428,9 +430,9 @@ static void glui_frame(void)
selected = (i == menu->navigation.selection_ptr); selected = (i == menu->navigation.selection_ptr);
menu_animation_ticker_line(entry_title_buf, glui->term_width - (w + 1 + 2), menu_animation_ticker_line(entry_title_buf, glui->term_width - (w + 1 + 2),
g_runloop.frames.video.count / glui->margin, path_buf, selected); runloop->frames.video.count / glui->margin, path_buf, selected);
menu_animation_ticker_line(type_str_buf, w, menu_animation_ticker_line(type_str_buf, w,
g_runloop.frames.video.count / glui->margin, type_str, selected); runloop->frames.video.count / glui->margin, type_str, selected);
strlcpy(message, entry_title_buf, sizeof(message)); strlcpy(message, entry_title_buf, sizeof(message));

View File

@ -58,6 +58,7 @@ static int rgui_entry_iterate(unsigned action)
const char *label = NULL; const char *label = NULL;
menu_file_list_cbs_t *cbs = NULL; menu_file_list_cbs_t *cbs = NULL;
menu_handle_t *menu = menu_driver_resolve(); menu_handle_t *menu = menu_driver_resolve();
runloop_t *runloop = rarch_main_get_ptr();
if (!menu) if (!menu)
return -1; return -1;
@ -65,10 +66,10 @@ static int rgui_entry_iterate(unsigned action)
return -1; return -1;
if (action != MENU_ACTION_NOOP || menu->need_refresh || if (action != MENU_ACTION_NOOP || menu->need_refresh ||
g_runloop.frames.video.current.menu.label.is_updated || runloop->frames.video.current.menu.label.is_updated ||
g_runloop.frames.video.current.menu.animation.is_active) runloop->frames.video.current.menu.animation.is_active)
{ {
g_runloop.frames.video.current.menu.framebuf.dirty = true; runloop->frames.video.current.menu.framebuf.dirty = true;
} }
@ -353,24 +354,25 @@ static void rgui_render(void)
const char *core_name = NULL; const char *core_name = NULL;
const char *core_version = NULL; const char *core_version = NULL;
menu_handle_t *menu = menu_driver_resolve(); menu_handle_t *menu = menu_driver_resolve();
runloop_t *runloop = rarch_main_get_ptr();
if (!menu) if (!menu)
return; return;
if (menu->need_refresh && g_runloop.is_menu if (menu->need_refresh && runloop->is_menu
&& !menu->msg_force) && !menu->msg_force)
return; return;
if (g_runloop.is_idle) if (runloop->is_idle)
return; return;
if (!menu_display_update_pending()) if (!menu_display_update_pending())
return; return;
/* ensures the framebuffer will be rendered on the screen */ /* ensures the framebuffer will be rendered on the screen */
g_runloop.frames.video.current.menu.framebuf.dirty = true; runloop->frames.video.current.menu.framebuf.dirty = true;
g_runloop.frames.video.current.menu.animation.is_active = false; runloop->frames.video.current.menu.animation.is_active = false;
g_runloop.frames.video.current.menu.label.is_updated = false; runloop->frames.video.current.menu.label.is_updated = false;
menu->mouse.ptr = menu->mouse.y / 11 - 2 + menu->begin; menu->mouse.ptr = menu->mouse.y / 11 - 2 + menu->begin;
@ -402,7 +404,7 @@ static void rgui_render(void)
get_title(label, dir, menu_type, title, sizeof(title)); get_title(label, dir, menu_type, title, sizeof(title));
menu_animation_ticker_line(title_buf, RGUI_TERM_WIDTH - 3, menu_animation_ticker_line(title_buf, RGUI_TERM_WIDTH - 3,
g_runloop.frames.video.count / RGUI_TERM_START_X, title, true); runloop->frames.video.count / RGUI_TERM_START_X, title, true);
hover_color = HOVER_COLOR; hover_color = HOVER_COLOR;
normal_color = NORMAL_COLOR; normal_color = NORMAL_COLOR;
@ -476,8 +478,8 @@ static void rgui_render(void)
continue; continue;
menu_animation_ticker_line(entry_title_buf, RGUI_TERM_WIDTH - (w + 1 + 2), menu_animation_ticker_line(entry_title_buf, RGUI_TERM_WIDTH - (w + 1 + 2),
g_runloop.frames.video.count / RGUI_TERM_START_X, path_buf, selected); runloop->frames.video.count / RGUI_TERM_START_X, path_buf, selected);
menu_animation_ticker_line(type_str_buf, w, g_runloop.frames.video.count / RGUI_TERM_START_X, menu_animation_ticker_line(type_str_buf, w, runloop->frames.video.count / RGUI_TERM_START_X,
type_str, selected); type_str, selected);
snprintf(message, sizeof(message), "%c %-*.*s %-*s", snprintf(message, sizeof(message), "%c %-*.*s %-*s",
@ -580,6 +582,8 @@ static void rgui_free(void *data)
static void rgui_set_texture(void) static void rgui_set_texture(void)
{ {
menu_handle_t *menu = menu_driver_resolve(); menu_handle_t *menu = menu_driver_resolve();
runloop_t *runloop = rarch_main_get_ptr();
if (!menu) if (!menu)
return; return;
@ -589,10 +593,10 @@ static void rgui_set_texture(void)
return; return;
if (!driver.video_poke->set_texture_frame) if (!driver.video_poke->set_texture_frame)
return; return;
if (!g_runloop.frames.video.current.menu.framebuf.dirty) if (!runloop->frames.video.current.menu.framebuf.dirty)
return; return;
g_runloop.frames.video.current.menu.framebuf.dirty = false; runloop->frames.video.current.menu.framebuf.dirty = false;
driver.video_poke->set_texture_frame(driver.video_data, driver.video_poke->set_texture_frame(driver.video_data,
menu->frame_buf.data, false, menu->frame_buf.width, menu->frame_buf.height, 1.0f); menu->frame_buf.data, false, menu->frame_buf.width, menu->frame_buf.height, 1.0f);

View File

@ -154,6 +154,7 @@ static void rmenu_render(void)
const char *core_version = NULL; const char *core_version = NULL;
unsigned menu_type = 0; unsigned menu_type = 0;
menu_handle_t *menu = menu_driver_resolve(); menu_handle_t *menu = menu_driver_resolve();
runloop_t *runloop = rarch_main_get_ptr();
if (!menu) if (!menu)
return; return;
@ -164,13 +165,13 @@ static void rmenu_render(void)
return; return;
} }
if (menu->need_refresh && g_runloop.is_menu if (menu->need_refresh && runloop->is_menu
&& !menu->msg_force) && !menu->msg_force)
return; return;
g_runloop.frames.video.current.menu.animation.is_active = false; runloop->frames.video.current.menu.animation.is_active = false;
g_runloop.frames.video.current.menu.label.is_updated = false; runloop->frames.video.current.menu.label.is_updated = false;
g_runloop.frames.video.current.menu.framebuf.dirty = false; runloop->frames.video.current.menu.framebuf.dirty = false;
if (!menu->menu_list->selection_buf) if (!menu->menu_list->selection_buf)
return; return;
@ -195,7 +196,7 @@ static void rmenu_render(void)
get_title(label, dir, menu_type, title, sizeof(title)); get_title(label, dir, menu_type, title, sizeof(title));
menu_animation_ticker_line(title_buf, RMENU_TERM_WIDTH, menu_animation_ticker_line(title_buf, RMENU_TERM_WIDTH,
g_runloop.frames.video.count / 15, title, true); runloop->frames.video.count / 15, title, true);
font_parms.x = POSITION_EDGE_MIN + POSITION_OFFSET; font_parms.x = POSITION_EDGE_MIN + POSITION_OFFSET;
font_parms.y = POSITION_EDGE_MIN + POSITION_RENDER_OFFSET font_parms.y = POSITION_EDGE_MIN + POSITION_RENDER_OFFSET
@ -262,8 +263,8 @@ static void rmenu_render(void)
selected = (i == menu->navigation.selection_ptr); selected = (i == menu->navigation.selection_ptr);
menu_animation_ticker_line(entry_title_buf, RMENU_TERM_WIDTH - (w + 1 + 2), menu_animation_ticker_line(entry_title_buf, RMENU_TERM_WIDTH - (w + 1 + 2),
g_runloop.frames.video.count / 15, path, selected); runloop->frames.video.count / 15, path, selected);
menu_animation_ticker_line(type_str_buf, w, g_runloop.frames.video.count / 15, menu_animation_ticker_line(type_str_buf, w, runloop->frames.video.count / 15,
type_str, selected); type_str, selected);
snprintf(message, sizeof(message), "%c %s", snprintf(message, sizeof(message), "%c %s",

View File

@ -553,16 +553,17 @@ static void rmenu_xui_render(void)
const char *dir = NULL, *label = NULL; const char *dir = NULL, *label = NULL;
unsigned menu_type = 0; unsigned menu_type = 0;
menu_handle_t *menu = menu_driver_resolve(); menu_handle_t *menu = menu_driver_resolve();
runloop_t *runloop = rarch_main_get_ptr();
if (!menu) if (!menu)
return; return;
if (menu->need_refresh && if (menu->need_refresh &&
g_runloop.is_menu && !menu->msg_force) runloop->is_menu && !menu->msg_force)
return; return;
g_runloop.frames.video.current.menu.animation.is_active = false; runloop->frames.video.current.menu.animation.is_active = false;
g_runloop.frames.video.current.menu.label.is_updated = false; runloop->frames.video.current.menu.label.is_updated = false;
g_runloop.frames.video.current.menu.framebuf.dirty = false; runloop->frames.video.current.menu.framebuf.dirty = false;
rmenu_xui_render_background(); rmenu_xui_render_background();
@ -573,7 +574,7 @@ static void rmenu_xui_render(void)
get_title(label, dir, menu_type, title, sizeof(title)); get_title(label, dir, menu_type, title, sizeof(title));
mbstowcs(strw_buffer, title, sizeof(strw_buffer) / sizeof(wchar_t)); mbstowcs(strw_buffer, title, sizeof(strw_buffer) / sizeof(wchar_t));
XuiTextElementSetText(m_menutitle, strw_buffer); XuiTextElementSetText(m_menutitle, strw_buffer);
menu_animation_ticker_line(title, RXUI_TERM_WIDTH - 3, g_runloop.frames.video.count / 15, title, true); menu_animation_ticker_line(title, RXUI_TERM_WIDTH - 3, runloop->frames.video.count / 15, title, true);
} }
if (XuiHandleIsValid(m_menutitle)) if (XuiHandleIsValid(m_menutitle))

View File

@ -1049,6 +1049,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
menu_file_list_cbs_t *cbs = NULL; menu_file_list_cbs_t *cbs = NULL;
GLuint icon = 0; GLuint icon = 0;
xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i);
runloop_t *runloop = rarch_main_get_ptr();
if (!node) if (!node)
continue; continue;
@ -1101,7 +1102,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
icon = xmb->textures.list[XMB_TEXTURE_RESUME].id; icon = xmb->textures.list[XMB_TEXTURE_RESUME].id;
menu_animation_ticker_line(name, 35, g_runloop.frames.video.count / 20, path_buf, menu_animation_ticker_line(name, 35, runloop->frames.video.count / 20, path_buf,
(i == current)); (i == current));
xmb_draw_text(gl, xmb, name, xmb_draw_text(gl, xmb, name,
@ -1109,7 +1110,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
xmb->margins.screen.top + node->y + xmb->margins.label.top, xmb->margins.screen.top + node->y + xmb->margins.label.top,
1, node->label_alpha, 0); 1, node->label_alpha, 0);
menu_animation_ticker_line(value, 35, g_runloop.frames.video.count / 20, type_str, menu_animation_ticker_line(value, 35, runloop->frames.video.count / 20, type_str,
(i == current)); (i == current));
if(( strcmp(type_str, "...") if(( strcmp(type_str, "...")
@ -1203,6 +1204,7 @@ static void xmb_draw_cursor(gl_t *gl, xmb_handle_t *xmb, float x, float y)
static void xmb_render(void) static void xmb_render(void)
{ {
unsigned i, current, end; unsigned i, current, end;
runloop_t *runloop = rarch_main_get_ptr();
menu_handle_t *menu = menu_driver_resolve(); menu_handle_t *menu = menu_driver_resolve();
if (!menu) if (!menu)
@ -1226,9 +1228,9 @@ static void xmb_render(void)
menu->mouse.ptr = i; menu->mouse.ptr = i;
} }
g_runloop.frames.video.current.menu.animation.is_active = false; runloop->frames.video.current.menu.animation.is_active = false;
g_runloop.frames.video.current.menu.label.is_updated = false; runloop->frames.video.current.menu.label.is_updated = false;
g_runloop.frames.video.current.menu.framebuf.dirty = false; runloop->frames.video.current.menu.framebuf.dirty = false;
} }
static void xmb_frame(void) static void xmb_frame(void)

View File

@ -27,9 +27,10 @@
bool menu_display_update_pending(void) bool menu_display_update_pending(void)
{ {
if (g_runloop.frames.video.current.menu.animation.is_active || runloop_t *runloop = rarch_main_get_ptr();
g_runloop.frames.video.current.menu.label.is_updated || if (runloop->frames.video.current.menu.animation.is_active ||
g_runloop.frames.video.current.menu.framebuf.dirty) runloop->frames.video.current.menu.label.is_updated ||
runloop->frames.video.current.menu.framebuf.dirty)
return true; return true;
return false; return false;
} }
@ -181,6 +182,7 @@ void *menu_init(const void *data)
{ {
menu_handle_t *menu = NULL; menu_handle_t *menu = NULL;
menu_ctx_driver_t *menu_ctx = (menu_ctx_driver_t*)data; menu_ctx_driver_t *menu_ctx = (menu_ctx_driver_t*)data;
runloop_t *runloop = rarch_main_get_ptr();
if (!menu_ctx) if (!menu_ctx)
return NULL; return NULL;
@ -217,7 +219,7 @@ void *menu_init(const void *data)
rarch_assert(menu->msg_queue = msg_queue_new(8)); rarch_assert(menu->msg_queue = msg_queue_new(8));
g_runloop.frames.video.current.menu.framebuf.dirty = true; runloop->frames.video.current.menu.framebuf.dirty = true;
return menu; return menu;
error: error:
@ -387,6 +389,7 @@ int menu_iterate(retro_input_t input,
static retro_time_t last_clock_update = 0; static retro_time_t last_clock_update = 0;
int32_t ret = 0; int32_t ret = 0;
unsigned action = menu_input_frame(input, trigger_input); unsigned action = menu_input_frame(input, trigger_input);
runloop_t *runloop = rarch_main_get_ptr();
menu_handle_t *menu = menu_driver_resolve(); menu_handle_t *menu = menu_driver_resolve();
@ -400,14 +403,14 @@ int menu_iterate(retro_input_t input,
if (menu->cur_time - last_clock_update > 1000000 && g_settings.menu.timedate_enable) if (menu->cur_time - last_clock_update > 1000000 && g_settings.menu.timedate_enable)
{ {
g_runloop.frames.video.current.menu.label.is_updated = true; runloop->frames.video.current.menu.label.is_updated = true;
last_clock_update = menu->cur_time; last_clock_update = menu->cur_time;
} }
if (driver.menu_ctx && driver.menu_ctx->entry_iterate) if (driver.menu_ctx && driver.menu_ctx->entry_iterate)
ret = driver.menu_ctx->entry_iterate(action); ret = driver.menu_ctx->entry_iterate(action);
if (g_runloop.is_menu && !g_runloop.is_idle) if (runloop->is_menu && !runloop->is_idle)
draw_frame(); draw_frame();
if (driver.menu_ctx && driver.menu_ctx->set_texture) if (driver.menu_ctx && driver.menu_ctx->set_texture)

View File

@ -439,6 +439,7 @@ bool menu_animation_update(animation_t *animation, float dt)
{ {
unsigned i; unsigned i;
unsigned active_tweens = 0; unsigned active_tweens = 0;
runloop_t *runloop = rarch_main_get_ptr();
for(i = 0; i < animation->size; i++) for(i = 0; i < animation->size; i++)
menu_animation_iterate(&animation->list[i], dt, &active_tweens); menu_animation_iterate(&animation->list[i], dt, &active_tweens);
@ -449,7 +450,7 @@ bool menu_animation_update(animation_t *animation, float dt)
return false; return false;
} }
g_runloop.frames.video.current.menu.animation.is_active = true; runloop->frames.video.current.menu.animation.is_active = true;
return true; return true;
} }
@ -472,6 +473,7 @@ void menu_animation_ticker_line(char *buf, size_t len, unsigned idx,
unsigned phase_left_moving, phase_right_stop; unsigned phase_left_moving, phase_right_stop;
unsigned left_offset, right_offset; unsigned left_offset, right_offset;
size_t str_len = strlen(str); size_t str_len = strlen(str);
runloop_t *runloop = rarch_main_get_ptr();
if (str_len <= len) if (str_len <= len)
{ {
@ -512,5 +514,5 @@ void menu_animation_ticker_line(char *buf, size_t len, unsigned idx,
else else
strlcpy(buf, str + right_offset, len + 1); strlcpy(buf, str + right_offset, len + 1);
g_runloop.frames.video.current.menu.animation.is_active = true; runloop->frames.video.current.menu.animation.is_active = true;
} }

View File

@ -581,6 +581,7 @@ static int mouse_iterate(unsigned *action)
{ {
const struct retro_keybind *binds[MAX_USERS]; const struct retro_keybind *binds[MAX_USERS];
menu_handle_t *menu = menu_driver_resolve(); menu_handle_t *menu = menu_driver_resolve();
runloop_t *runloop = rarch_main_get_ptr();
if (!menu) if (!menu)
return -1; return -1;
@ -651,7 +652,7 @@ static int mouse_iterate(unsigned *action)
|| menu->mouse.wheelup || menu->mouse.wheeldown || menu->mouse.wheelup || menu->mouse.wheeldown
|| menu->mouse.hwheelup || menu->mouse.hwheeldown || menu->mouse.hwheelup || menu->mouse.hwheeldown
|| menu->mouse.scrollup || menu->mouse.scrolldown) || menu->mouse.scrollup || menu->mouse.scrolldown)
g_runloop.frames.video.current.menu.animation.is_active = true; runloop->frames.video.current.menu.animation.is_active = true;
return 0; return 0;
} }

View File

@ -379,6 +379,7 @@ static void menu_action_setting_disp_set_label_perf_counters(
const struct retro_perf_counter **counters = const struct retro_perf_counter **counters =
(const struct retro_perf_counter **)perf_counters_rarch; (const struct retro_perf_counter **)perf_counters_rarch;
unsigned offset = type - MENU_SETTINGS_PERF_COUNTERS_BEGIN; unsigned offset = type - MENU_SETTINGS_PERF_COUNTERS_BEGIN;
runloop_t *runloop = rarch_main_get_ptr();
*type_str = '\0'; *type_str = '\0';
*w = 19; *w = 19;
@ -399,7 +400,7 @@ static void menu_action_setting_disp_set_label_perf_counters(
(unsigned long long)counters[offset]->call_cnt), (unsigned long long)counters[offset]->call_cnt),
(unsigned long long)counters[offset]->call_cnt); (unsigned long long)counters[offset]->call_cnt);
g_runloop.frames.video.current.menu.label.is_updated = true; runloop->frames.video.current.menu.label.is_updated = true;
} }
static void menu_action_setting_disp_set_label_libretro_perf_counters( static void menu_action_setting_disp_set_label_libretro_perf_counters(
@ -414,6 +415,7 @@ static void menu_action_setting_disp_set_label_libretro_perf_counters(
const struct retro_perf_counter **counters = const struct retro_perf_counter **counters =
(const struct retro_perf_counter **)perf_counters_libretro; (const struct retro_perf_counter **)perf_counters_libretro;
unsigned offset = type - MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN; unsigned offset = type - MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN;
runloop_t *runloop = rarch_main_get_ptr();
*type_str = '\0'; *type_str = '\0';
*w = 19; *w = 19;
@ -434,7 +436,7 @@ static void menu_action_setting_disp_set_label_libretro_perf_counters(
(unsigned long long)counters[offset]->call_cnt), (unsigned long long)counters[offset]->call_cnt),
(unsigned long long)counters[offset]->call_cnt); (unsigned long long)counters[offset]->call_cnt);
g_runloop.frames.video.current.menu.label.is_updated = true; runloop->frames.video.current.menu.label.is_updated = true;
} }
static void menu_action_setting_disp_set_label_menu_more( static void menu_action_setting_disp_set_label_menu_more(

View File

@ -78,8 +78,9 @@
void rarch_render_cached_frame(void) void rarch_render_cached_frame(void)
{ {
void *recording = driver.recording_data; void *recording = driver.recording_data;
runloop_t *runloop = rarch_main_get_ptr();
if (g_runloop.is_idle) if (runloop->is_idle)
return; return;
/* Cannot allow recording when pushing duped frames. */ /* Cannot allow recording when pushing duped frames. */
@ -378,6 +379,8 @@ static void set_paths(const char *path)
**/ **/
static void parse_input(int argc, char *argv[]) static void parse_input(int argc, char *argv[])
{ {
runloop_t *runloop = rarch_main_get_ptr();
g_extern.libretro_no_content = false; g_extern.libretro_no_content = false;
g_extern.libretro_dummy = false; g_extern.libretro_dummy = false;
g_extern.has_set_save_path = false; g_extern.has_set_save_path = false;
@ -656,7 +659,7 @@ static void parse_input(int argc, char *argv[])
break; break;
case 'm': case 'm':
g_runloop.frames.video.max = strtoul(optarg, NULL, 10); runloop->frames.video.max = strtoul(optarg, NULL, 10);
break; break;
case 0: case 0:
@ -1617,8 +1620,8 @@ static void main_clear_state_extern(void)
rarch_main_command(RARCH_CMD_HISTORY_DEINIT); rarch_main_command(RARCH_CMD_HISTORY_DEINIT);
memset(&g_extern, 0, sizeof(g_extern)); memset(&g_extern, 0, sizeof(g_extern));
memset(&g_runloop, 0, sizeof(g_runloop));
rarch_main_clear_state();
rarch_main_data_clear_state(); rarch_main_data_clear_state();
} }
@ -1757,8 +1760,10 @@ static void validate_cpu_features(void)
**/ **/
static void init_system_av_info(void) static void init_system_av_info(void)
{ {
runloop_t *runloop = rarch_main_get_ptr();
pretro_get_system_av_info(&g_extern.system.av_info); pretro_get_system_av_info(&g_extern.system.av_info);
g_runloop.frames.limit.last_time = rarch_get_time_usec(); runloop->frames.limit.last_time = rarch_get_time_usec();
} }
static void deinit_core(void) static void deinit_core(void)
@ -1956,6 +1961,8 @@ void rarch_main_init_wrap(const struct rarch_main_wrap *args,
void rarch_main_set_state(unsigned cmd) void rarch_main_set_state(unsigned cmd)
{ {
runloop_t *runloop = rarch_main_get_ptr();
switch (cmd) switch (cmd)
{ {
case RARCH_ACTION_STATE_MENU_RUNNING: case RARCH_ACTION_STATE_MENU_RUNNING:
@ -1984,7 +1991,7 @@ void rarch_main_set_state(unsigned cmd)
menu->need_refresh = true; menu->need_refresh = true;
g_extern.system.frame_time_last = 0; g_extern.system.frame_time_last = 0;
g_runloop.is_menu = true; runloop->is_menu = true;
} }
#endif #endif
break; break;
@ -2004,7 +2011,7 @@ void rarch_main_set_state(unsigned cmd)
if (driver.menu_ctx && driver.menu_ctx->toggle) if (driver.menu_ctx && driver.menu_ctx->toggle)
driver.menu_ctx->toggle(false); driver.menu_ctx->toggle(false);
g_runloop.is_menu = false; runloop->is_menu = false;
driver_set_nonblock_state(driver.nonblock_state); driver_set_nonblock_state(driver.nonblock_state);
@ -2161,6 +2168,7 @@ bool rarch_main_command(unsigned cmd)
{ {
unsigned i = 0; unsigned i = 0;
bool boolean = false; bool boolean = false;
runloop_t *runloop = rarch_main_get_ptr();
(void)i; (void)i;
@ -2229,7 +2237,7 @@ bool rarch_main_command(unsigned cmd)
g_extern.pending.windowed_scale = 0; g_extern.pending.windowed_scale = 0;
break; break;
case RARCH_CMD_MENU_TOGGLE: case RARCH_CMD_MENU_TOGGLE:
if (g_runloop.is_menu) if (runloop->is_menu)
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED); rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED);
else else
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING); rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING);
@ -2286,8 +2294,8 @@ bool rarch_main_command(unsigned cmd)
driver.input->poll(driver.input_data); driver.input->poll(driver.input_data);
#ifdef HAVE_MENU #ifdef HAVE_MENU
g_runloop.frames.video.current.menu.framebuf.dirty = true; runloop->frames.video.current.menu.framebuf.dirty = true;
if (g_runloop.is_menu) if (runloop->is_menu)
rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE); rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE);
#endif #endif
break; break;
@ -2543,7 +2551,7 @@ bool rarch_main_command(unsigned cmd)
#endif #endif
break; break;
case RARCH_CMD_PAUSE_CHECKS: case RARCH_CMD_PAUSE_CHECKS:
if (g_runloop.is_paused) if (runloop->is_paused)
{ {
RARCH_LOG("Paused.\n"); RARCH_LOG("Paused.\n");
rarch_main_command(RARCH_CMD_AUDIO_STOP); rarch_main_command(RARCH_CMD_AUDIO_STOP);
@ -2558,19 +2566,19 @@ bool rarch_main_command(unsigned cmd)
} }
break; break;
case RARCH_CMD_PAUSE_TOGGLE: case RARCH_CMD_PAUSE_TOGGLE:
g_runloop.is_paused = !g_runloop.is_paused; runloop->is_paused = !runloop->is_paused;
rarch_main_command(RARCH_CMD_PAUSE_CHECKS); rarch_main_command(RARCH_CMD_PAUSE_CHECKS);
break; break;
case RARCH_CMD_UNPAUSE: case RARCH_CMD_UNPAUSE:
g_runloop.is_paused = false; runloop->is_paused = false;
rarch_main_command(RARCH_CMD_PAUSE_CHECKS); rarch_main_command(RARCH_CMD_PAUSE_CHECKS);
break; break;
case RARCH_CMD_PAUSE: case RARCH_CMD_PAUSE:
g_runloop.is_paused = true; runloop->is_paused = true;
rarch_main_command(RARCH_CMD_PAUSE_CHECKS); rarch_main_command(RARCH_CMD_PAUSE_CHECKS);
break; break;
case RARCH_CMD_MENU_PAUSE_LIBRETRO: case RARCH_CMD_MENU_PAUSE_LIBRETRO:
if (g_runloop.is_menu) if (runloop->is_menu)
{ {
if (g_settings.menu.pause_libretro) if (g_settings.menu.pause_libretro)
rarch_main_command(RARCH_CMD_AUDIO_STOP); rarch_main_command(RARCH_CMD_AUDIO_STOP);

View File

@ -924,6 +924,16 @@ void rarch_main_msg_queue_init(void)
rarch_assert(g_runloop.msg_queue = msg_queue_new(8)); rarch_assert(g_runloop.msg_queue = msg_queue_new(8));
} }
runloop_t *rarch_main_get_ptr(void)
{
return &g_runloop;
}
void rarch_main_clear_state(void)
{
memset(&g_runloop, 0, sizeof(g_runloop));
}
/** /**
* rarch_main_iterate: * rarch_main_iterate:
* *

View File

@ -108,8 +108,7 @@ typedef struct runloop
msg_queue_t *msg_queue; msg_queue_t *msg_queue;
} runloop_t; } runloop_t;
/* Public data structures. */ runloop_t *rarch_main_get_ptr(void);
extern struct runloop g_runloop;
/** /**
* rarch_main_iterate: * rarch_main_iterate:
@ -134,6 +133,8 @@ void rarch_main_data_msg_queue_push(unsigned type,
const char *msg, const char *msg2, const char *msg, const char *msg2,
unsigned prio, unsigned duration, bool flush); unsigned prio, unsigned duration, bool flush);
void rarch_main_clear_state(void);
void rarch_main_data_clear_state(void); void rarch_main_data_clear_state(void);
void rarch_main_data_iterate(void); void rarch_main_data_iterate(void);

View File

@ -684,7 +684,8 @@ static void rarch_main_data_db_iterate(void)
#ifdef HAVE_OVERLAY #ifdef HAVE_OVERLAY
static void rarch_main_data_overlay_iterate(void) static void rarch_main_data_overlay_iterate(void)
{ {
if (g_runloop.is_idle) runloop_t *runloop = rarch_main_get_ptr();
if (runloop->is_idle)
return; return;
if (!driver.overlay) if (!driver.overlay)
return; return;

View File

@ -248,6 +248,7 @@ bool take_screenshot(void)
bool viewport_read = false; bool viewport_read = false;
bool ret = true; bool ret = true;
const char *msg = NULL; const char *msg = NULL;
runloop_t *runloop = rarch_main_get_ptr();
/* No way to infer screenshot directory. */ /* No way to infer screenshot directory. */
if ((!*g_settings.screenshot_directory) && (!*g_extern.basename)) if ((!*g_settings.screenshot_directory) && (!*g_extern.basename))
@ -319,9 +320,9 @@ bool take_screenshot(void)
msg = RETRO_MSG_TAKE_SCREENSHOT_FAILED; msg = RETRO_MSG_TAKE_SCREENSHOT_FAILED;
} }
rarch_main_msg_queue_push(msg, 1, g_runloop.is_paused ? 1 : 180, true); rarch_main_msg_queue_push(msg, 1, runloop->is_paused ? 1 : 180, true);
if (g_runloop.is_paused) if (runloop->is_paused)
rarch_render_cached_frame(); rarch_render_cached_frame();
return ret; return ret;

View File

@ -381,11 +381,12 @@ static int setting_data_action_start_video_refresh_rate_auto(
void *data) void *data)
{ {
rarch_setting_t *setting = (rarch_setting_t*)data; rarch_setting_t *setting = (rarch_setting_t*)data;
runloop_t *runloop = rarch_main_get_ptr();
if (!setting) if (!setting)
return -1; return -1;
g_runloop.measure_data.frame_time_samples_count = 0; runloop->measure_data.frame_time_samples_count = 0;
return 0; return 0;
} }
@ -1182,9 +1183,11 @@ static void setting_data_get_string_representation_st_float_video_refresh_rate_a
if (video_monitor_fps_statistics(&video_refresh_rate, &deviation, &sample_points)) if (video_monitor_fps_statistics(&video_refresh_rate, &deviation, &sample_points))
{ {
runloop_t *runloop = rarch_main_get_ptr();
snprintf(type_str, type_str_size, "%.3f Hz (%.1f%% dev, %u samples)", snprintf(type_str, type_str_size, "%.3f Hz (%.1f%% dev, %u samples)",
video_refresh_rate, 100.0 * deviation, sample_points); video_refresh_rate, 100.0 * deviation, sample_points);
g_runloop.frames.video.current.menu.label.is_updated = true; runloop->frames.video.current.menu.label.is_updated = true;
} }
else else
strlcpy(type_str, "N/A", type_str_size); strlcpy(type_str, "N/A", type_str_size);

View File

@ -34,7 +34,6 @@
* with special #ifdefs. * with special #ifdefs.
*/ */
struct settings g_settings; struct settings g_settings;
struct runloop g_runloop;
struct global g_extern; struct global g_extern;
driver_t driver; driver_t driver;