Move rewind state code out of g_extern
This commit is contained in:
parent
0db7cda264
commit
e8471ead48
|
@ -28,6 +28,7 @@
|
||||||
#include "screenshot.h"
|
#include "screenshot.h"
|
||||||
#include "msg_hash.h"
|
#include "msg_hash.h"
|
||||||
#include "retroarch.h"
|
#include "retroarch.h"
|
||||||
|
#include "rewind.h"
|
||||||
#include "dir_list_special.h"
|
#include "dir_list_special.h"
|
||||||
|
|
||||||
#ifdef HAVE_CHEEVOS
|
#ifdef HAVE_CHEEVOS
|
||||||
|
|
|
@ -18,12 +18,14 @@
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
|
#include <gfx/math/matrix_4x4.h>
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "video_context_driver.h"
|
#include "video_context_driver.h"
|
||||||
#include <gfx/math/matrix_4x4.h>
|
#include "../rewind.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
48
rewind.c
48
rewind.c
|
@ -98,6 +98,14 @@ repeat {
|
||||||
size thisstart;
|
size thisstart;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct state_manager_rewind_state
|
||||||
|
{
|
||||||
|
/* Rewind support. */
|
||||||
|
state_manager_t *state;
|
||||||
|
size_t size;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct state_manager_rewind_state rewind_state;
|
||||||
static bool frame_is_reversed;
|
static bool frame_is_reversed;
|
||||||
|
|
||||||
size_t state_manager_raw_maxsize(size_t uncomp)
|
size_t state_manager_raw_maxsize(size_t uncomp)
|
||||||
|
@ -584,9 +592,8 @@ void init_rewind(void)
|
||||||
{
|
{
|
||||||
void *state = NULL;
|
void *state = NULL;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
global_t *global = global_get_ptr();
|
|
||||||
|
|
||||||
if (!settings->rewind_enable || global->rewind.state)
|
if (!settings->rewind_enable || rewind_state.state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (audio_driver_ctl(RARCH_AUDIO_CTL_HAS_CALLBACK, NULL))
|
if (audio_driver_ctl(RARCH_AUDIO_CTL_HAS_CALLBACK, NULL))
|
||||||
|
@ -595,9 +602,9 @@ void init_rewind(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
global->rewind.size = core.retro_serialize_size();
|
rewind_state.size = core.retro_serialize_size();
|
||||||
|
|
||||||
if (!global->rewind.size)
|
if (!rewind_state.size)
|
||||||
{
|
{
|
||||||
RARCH_ERR("%s.\n",
|
RARCH_ERR("%s.\n",
|
||||||
msg_hash_to_str(MSG_REWIND_INIT_FAILED_THREADED_AUDIO));
|
msg_hash_to_str(MSG_REWIND_INIT_FAILED_THREADED_AUDIO));
|
||||||
|
@ -608,15 +615,15 @@ void init_rewind(void)
|
||||||
msg_hash_to_str(MSG_REWIND_INIT),
|
msg_hash_to_str(MSG_REWIND_INIT),
|
||||||
(unsigned)(settings->rewind_buffer_size / 1000000));
|
(unsigned)(settings->rewind_buffer_size / 1000000));
|
||||||
|
|
||||||
global->rewind.state = state_manager_new(global->rewind.size,
|
rewind_state.state = state_manager_new(rewind_state.size,
|
||||||
settings->rewind_buffer_size);
|
settings->rewind_buffer_size);
|
||||||
|
|
||||||
if (!global->rewind.state)
|
if (!rewind_state.state)
|
||||||
RARCH_WARN("%s.\n", msg_hash_to_str(MSG_REWIND_INIT_FAILED));
|
RARCH_WARN("%s.\n", msg_hash_to_str(MSG_REWIND_INIT_FAILED));
|
||||||
|
|
||||||
state_manager_push_where(global->rewind.state, &state);
|
state_manager_push_where(rewind_state.state, &state);
|
||||||
core.retro_serialize(state, global->rewind.size);
|
core.retro_serialize(state, rewind_state.size);
|
||||||
state_manager_push_do(global->rewind.state);
|
state_manager_push_do(rewind_state.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -632,13 +639,10 @@ void state_manager_set_frame_is_reversed(bool value)
|
||||||
|
|
||||||
void state_manager_event_deinit(void)
|
void state_manager_event_deinit(void)
|
||||||
{
|
{
|
||||||
global_t *global = global_get_ptr();
|
if (rewind_state.state)
|
||||||
if (!global)
|
state_manager_free(rewind_state.state);
|
||||||
return;
|
rewind_state.state = NULL;
|
||||||
|
rewind_state.size = 0;
|
||||||
if (global->rewind.state)
|
|
||||||
state_manager_free(global->rewind.state);
|
|
||||||
global->rewind.state = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -665,21 +669,21 @@ void state_manager_check_rewind(bool pressed)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!global->rewind.state)
|
if (!rewind_state.state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (pressed)
|
if (pressed)
|
||||||
{
|
{
|
||||||
const void *buf = NULL;
|
const void *buf = NULL;
|
||||||
|
|
||||||
if (state_manager_pop(global->rewind.state, &buf))
|
if (state_manager_pop(rewind_state.state, &buf))
|
||||||
{
|
{
|
||||||
state_manager_set_frame_is_reversed(true);
|
state_manager_set_frame_is_reversed(true);
|
||||||
audio_driver_ctl(RARCH_AUDIO_CTL_SETUP_REWIND, NULL);
|
audio_driver_ctl(RARCH_AUDIO_CTL_SETUP_REWIND, NULL);
|
||||||
|
|
||||||
rarch_main_msg_queue_push_new(MSG_REWINDING, 0,
|
rarch_main_msg_queue_push_new(MSG_REWINDING, 0,
|
||||||
runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) ? 1 : 30, true);
|
runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) ? 1 : 30, true);
|
||||||
core.retro_unserialize(buf, global->rewind.size);
|
core.retro_unserialize(buf, rewind_state.size);
|
||||||
|
|
||||||
if (global->bsv.movie)
|
if (global->bsv.movie)
|
||||||
bsv_movie_frame_rewind(global->bsv.movie);
|
bsv_movie_frame_rewind(global->bsv.movie);
|
||||||
|
@ -700,14 +704,14 @@ void state_manager_check_rewind(bool pressed)
|
||||||
static struct retro_perf_counter rewind_serialize = {0};
|
static struct retro_perf_counter rewind_serialize = {0};
|
||||||
void *state = NULL;
|
void *state = NULL;
|
||||||
|
|
||||||
state_manager_push_where(global->rewind.state, &state);
|
state_manager_push_where(rewind_state.state, &state);
|
||||||
|
|
||||||
rarch_perf_init(&rewind_serialize, "rewind_serialize");
|
rarch_perf_init(&rewind_serialize, "rewind_serialize");
|
||||||
retro_perf_start(&rewind_serialize);
|
retro_perf_start(&rewind_serialize);
|
||||||
core.retro_serialize(state, global->rewind.size);
|
core.retro_serialize(state, rewind_state.size);
|
||||||
retro_perf_stop(&rewind_serialize);
|
retro_perf_stop(&rewind_serialize);
|
||||||
|
|
||||||
state_manager_push_do(global->rewind.state);
|
state_manager_push_do(rewind_state.state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include "core_info.h"
|
#include "core_info.h"
|
||||||
#include "core_options.h"
|
#include "core_options.h"
|
||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
#include "rewind.h"
|
|
||||||
#include "movie.h"
|
#include "movie.h"
|
||||||
#include "cheats.h"
|
#include "cheats.h"
|
||||||
#include "dynamic.h"
|
#include "dynamic.h"
|
||||||
|
@ -198,13 +197,6 @@ typedef struct global
|
||||||
} menu;
|
} menu;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
/* Rewind support. */
|
|
||||||
state_manager_t *state;
|
|
||||||
size_t size;
|
|
||||||
} rewind;
|
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/* Movie playback/recording support. */
|
/* Movie playback/recording support. */
|
||||||
|
|
Loading…
Reference in New Issue