Move rewind state variables in struct

This commit is contained in:
twinaphex 2015-02-16 18:09:00 +01:00
parent 37a541e8a0
commit 2f63b75697
7 changed files with 36 additions and 33 deletions

View File

@ -596,14 +596,17 @@ struct global
bool exec; bool exec;
/* Rewind support. */
state_manager_t *state_manager;
size_t state_size;
bool frame_is_reverse;
/* Movie playback/recording support. */
struct struct
{ {
/* Rewind support. */
state_manager_t *state;
size_t size;
bool frame_is_reverse;
} rewind;
struct
{
/* Movie playback/recording support. */
bsv_movie_t *movie; bsv_movie_t *movie;
char movie_path[PATH_MAX_LENGTH]; char movie_path[PATH_MAX_LENGTH];
bool movie_playback; bool movie_playback;

View File

@ -247,13 +247,13 @@ static void gl_cg_set_params(void *data, unsigned width, unsigned height,
set_param_2f(cg->prg[cg->active_idx].tex_size_f, tex_width, tex_height); set_param_2f(cg->prg[cg->active_idx].tex_size_f, tex_width, tex_height);
set_param_2f(cg->prg[cg->active_idx].out_size_f, out_width, out_height); set_param_2f(cg->prg[cg->active_idx].out_size_f, out_width, out_height);
set_param_1f(cg->prg[cg->active_idx].frame_dir_f, set_param_1f(cg->prg[cg->active_idx].frame_dir_f,
g_extern.frame_is_reverse ? -1.0 : 1.0); g_extern.rewind.frame_is_reverse ? -1.0 : 1.0);
set_param_2f(cg->prg[cg->active_idx].vid_size_v, width, height); set_param_2f(cg->prg[cg->active_idx].vid_size_v, width, height);
set_param_2f(cg->prg[cg->active_idx].tex_size_v, tex_width, tex_height); set_param_2f(cg->prg[cg->active_idx].tex_size_v, tex_width, tex_height);
set_param_2f(cg->prg[cg->active_idx].out_size_v, out_width, out_height); set_param_2f(cg->prg[cg->active_idx].out_size_v, out_width, out_height);
set_param_1f(cg->prg[cg->active_idx].frame_dir_v, set_param_1f(cg->prg[cg->active_idx].frame_dir_v,
g_extern.frame_is_reverse ? -1.0 : 1.0); g_extern.rewind.frame_is_reverse ? -1.0 : 1.0);
if (cg->prg[cg->active_idx].frame_cnt_f || cg->prg[cg->active_idx].frame_cnt_v) if (cg->prg[cg->active_idx].frame_cnt_f || cg->prg[cg->active_idx].frame_cnt_v)
{ {

View File

@ -982,7 +982,7 @@ static void gl_glsl_set_params(void *data, unsigned width, unsigned height,
} }
if (uni->frame_direction >= 0) if (uni->frame_direction >= 0)
glUniform1i(uni->frame_direction, g_extern.frame_is_reverse ? -1 : 1); glUniform1i(uni->frame_direction, g_extern.rewind.frame_is_reverse ? -1 : 1);
for (i = 0; i < glsl->glsl_shader->luts; i++) for (i = 0; i < glsl->glsl_shader->luts; i++)

View File

@ -130,13 +130,13 @@ static void hlsl_set_params(void *data, unsigned width, unsigned height,
set_param_2f(hlsl->prg[hlsl->active_idx].tex_size_f, tex_size, hlsl->prg[hlsl->active_idx].f_ctable); set_param_2f(hlsl->prg[hlsl->active_idx].tex_size_f, tex_size, hlsl->prg[hlsl->active_idx].f_ctable);
set_param_2f(hlsl->prg[hlsl->active_idx].out_size_f, out_size, hlsl->prg[hlsl->active_idx].f_ctable); set_param_2f(hlsl->prg[hlsl->active_idx].out_size_f, out_size, hlsl->prg[hlsl->active_idx].f_ctable);
set_param_1f(hlsl->prg[hlsl->active_idx].frame_cnt_f, frame_cnt, hlsl->prg[hlsl->active_idx].f_ctable); set_param_1f(hlsl->prg[hlsl->active_idx].frame_cnt_f, frame_cnt, hlsl->prg[hlsl->active_idx].f_ctable);
set_param_1f(hlsl->prg[hlsl->active_idx].frame_dir_f, g_extern.frame_is_reverse ? -1.0 : 1.0, hlsl->prg[hlsl->active_idx].f_ctable); set_param_1f(hlsl->prg[hlsl->active_idx].frame_dir_f, g_extern.rewind.frame_is_reverse ? -1.0 : 1.0, hlsl->prg[hlsl->active_idx].f_ctable);
set_param_2f(hlsl->prg[hlsl->active_idx].vid_size_v, ori_size, hlsl->prg[hlsl->active_idx].v_ctable); set_param_2f(hlsl->prg[hlsl->active_idx].vid_size_v, ori_size, hlsl->prg[hlsl->active_idx].v_ctable);
set_param_2f(hlsl->prg[hlsl->active_idx].tex_size_v, tex_size, hlsl->prg[hlsl->active_idx].v_ctable); set_param_2f(hlsl->prg[hlsl->active_idx].tex_size_v, tex_size, hlsl->prg[hlsl->active_idx].v_ctable);
set_param_2f(hlsl->prg[hlsl->active_idx].out_size_v, out_size, hlsl->prg[hlsl->active_idx].v_ctable); set_param_2f(hlsl->prg[hlsl->active_idx].out_size_v, out_size, hlsl->prg[hlsl->active_idx].v_ctable);
set_param_1f(hlsl->prg[hlsl->active_idx].frame_cnt_v, frame_cnt, hlsl->prg[hlsl->active_idx].v_ctable); set_param_1f(hlsl->prg[hlsl->active_idx].frame_cnt_v, frame_cnt, hlsl->prg[hlsl->active_idx].v_ctable);
set_param_1f(hlsl->prg[hlsl->active_idx].frame_dir_v, g_extern.frame_is_reverse ? -1.0 : 1.0, hlsl->prg[hlsl->active_idx].v_ctable); set_param_1f(hlsl->prg[hlsl->active_idx].frame_dir_v, g_extern.rewind.frame_is_reverse ? -1.0 : 1.0, hlsl->prg[hlsl->active_idx].v_ctable);
/* TODO - set lookup textures/FBO textures/state parameters/etc */ /* TODO - set lookup textures/FBO textures/state parameters/etc */
} }

View File

@ -687,7 +687,7 @@ void retro_init_libretro_cbs(void *data)
**/ **/
void retro_set_rewind_callbacks(void) void retro_set_rewind_callbacks(void)
{ {
if (g_extern.frame_is_reverse) if (g_extern.rewind.frame_is_reverse)
{ {
pretro_set_audio_sample(audio_sample_rewind); pretro_set_audio_sample(audio_sample_rewind);
pretro_set_audio_sample_batch(audio_sample_batch_rewind); pretro_set_audio_sample_batch(audio_sample_batch_rewind);

View File

@ -895,7 +895,7 @@ static void init_rewind(void)
return; return;
#endif #endif
if (!g_settings.rewind_enable || g_extern.state_manager) if (!g_settings.rewind_enable || g_extern.rewind.state)
return; return;
if (g_extern.system.audio_callback.callback) if (g_extern.system.audio_callback.callback)
@ -904,9 +904,9 @@ static void init_rewind(void)
return; return;
} }
g_extern.state_size = pretro_serialize_size(); g_extern.rewind.size = pretro_serialize_size();
if (!g_extern.state_size) if (!g_extern.rewind.size)
{ {
RARCH_ERR(RETRO_LOG_REWIND_INIT_FAILED_NO_SAVESTATES); RARCH_ERR(RETRO_LOG_REWIND_INIT_FAILED_NO_SAVESTATES);
return; return;
@ -915,15 +915,15 @@ static void init_rewind(void)
RARCH_LOG(RETRO_MSG_REWIND_INIT "%u MB\n", RARCH_LOG(RETRO_MSG_REWIND_INIT "%u MB\n",
(unsigned)(g_settings.rewind_buffer_size / 1000000)); (unsigned)(g_settings.rewind_buffer_size / 1000000));
g_extern.state_manager = state_manager_new(g_extern.state_size, g_extern.rewind.state = state_manager_new(g_extern.rewind.size,
g_settings.rewind_buffer_size); g_settings.rewind_buffer_size);
if (!g_extern.state_manager) if (!g_extern.rewind.state)
RARCH_WARN(RETRO_LOG_REWIND_INIT_FAILED); RARCH_WARN(RETRO_LOG_REWIND_INIT_FAILED);
state_manager_push_where(g_extern.state_manager, &state); state_manager_push_where(g_extern.rewind.state, &state);
pretro_serialize(state, g_extern.state_size); pretro_serialize(state, g_extern.rewind.size);
state_manager_push_do(g_extern.state_manager); state_manager_push_do(g_extern.rewind.state);
} }
static void init_movie(void) static void init_movie(void)
@ -2279,9 +2279,9 @@ bool rarch_main_command(unsigned cmd)
if (driver.netplay_data) if (driver.netplay_data)
return false; return false;
#endif #endif
if (g_extern.state_manager) if (g_extern.rewind.state)
state_manager_free(g_extern.state_manager); state_manager_free(g_extern.rewind.state);
g_extern.state_manager = NULL; g_extern.rewind.state = NULL;
break; break;
case RARCH_CMD_REWIND_INIT: case RARCH_CMD_REWIND_INIT:
init_rewind(); init_rewind();

View File

@ -220,14 +220,14 @@ static void check_rewind(bool pressed)
{ {
static bool first = true; static bool first = true;
if (g_extern.frame_is_reverse) if (g_extern.rewind.frame_is_reverse)
{ {
/* We just rewound. Flush rewind audio buffer. */ /* We just rewound. Flush rewind audio buffer. */
retro_flush_audio(g_extern.audio_data.rewind_buf retro_flush_audio(g_extern.audio_data.rewind_buf
+ g_extern.audio_data.rewind_ptr, + g_extern.audio_data.rewind_ptr,
g_extern.audio_data.rewind_size - g_extern.audio_data.rewind_ptr); g_extern.audio_data.rewind_size - g_extern.audio_data.rewind_ptr);
g_extern.frame_is_reverse = false; g_extern.rewind.frame_is_reverse = false;
} }
if (first) if (first)
@ -236,7 +236,7 @@ static void check_rewind(bool pressed)
return; return;
} }
if (!g_extern.state_manager) if (!g_extern.rewind.state)
return; return;
if (pressed) if (pressed)
@ -244,14 +244,14 @@ static void check_rewind(bool pressed)
const void *buf = NULL; const void *buf = NULL;
msg_queue_clear(g_extern.msg_queue); msg_queue_clear(g_extern.msg_queue);
if (state_manager_pop(g_extern.state_manager, &buf)) if (state_manager_pop(g_extern.rewind.state, &buf))
{ {
g_extern.frame_is_reverse = true; g_extern.rewind.frame_is_reverse = true;
setup_rewind_audio(); setup_rewind_audio();
msg_queue_push(g_extern.msg_queue, RETRO_MSG_REWINDING, 0, msg_queue_push(g_extern.msg_queue, RETRO_MSG_REWINDING, 0,
g_extern.is_paused ? 1 : 30); g_extern.is_paused ? 1 : 30);
pretro_unserialize(buf, g_extern.state_size); pretro_unserialize(buf, g_extern.rewind.size);
if (g_extern.bsv.movie) if (g_extern.bsv.movie)
bsv_movie_frame_rewind(g_extern.bsv.movie); bsv_movie_frame_rewind(g_extern.bsv.movie);
@ -270,14 +270,14 @@ static void check_rewind(bool pressed)
if ((cnt == 0) || g_extern.bsv.movie) if ((cnt == 0) || g_extern.bsv.movie)
{ {
void *state = NULL; void *state = NULL;
state_manager_push_where(g_extern.state_manager, &state); state_manager_push_where(g_extern.rewind.state, &state);
RARCH_PERFORMANCE_INIT(rewind_serialize); RARCH_PERFORMANCE_INIT(rewind_serialize);
RARCH_PERFORMANCE_START(rewind_serialize); RARCH_PERFORMANCE_START(rewind_serialize);
pretro_serialize(state, g_extern.state_size); pretro_serialize(state, g_extern.rewind.size);
RARCH_PERFORMANCE_STOP(rewind_serialize); RARCH_PERFORMANCE_STOP(rewind_serialize);
state_manager_push_do(g_extern.state_manager); state_manager_push_do(g_extern.rewind.state);
} }
} }
@ -301,7 +301,7 @@ static void check_slowmotion(bool pressed)
rarch_render_cached_frame(); rarch_render_cached_frame();
msg_queue_clear(g_extern.msg_queue); msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, g_extern.frame_is_reverse ? msg_queue_push(g_extern.msg_queue, g_extern.rewind.frame_is_reverse ?
"Slow motion rewind." : "Slow motion.", 0, 30); "Slow motion rewind." : "Slow motion.", 0, 30);
} }