Move global->record to record_driver.c

This commit is contained in:
twinaphex 2016-10-01 00:47:05 +02:00
parent 6d47b57af7
commit 5ff13df40f
6 changed files with 57 additions and 32 deletions

View File

@ -4422,7 +4422,7 @@ static bool setting_append_list(
CONFIG_BOOL(
list, list_info,
&global->record.use_output_dir,
recording_driver_get_use_output_dir_ptr(),
msg_hash_to_str(MENU_ENUM_LABEL_RECORD_USE_OUTPUT_DIRECTORY),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RECORD_USE_OUTPUT_DIRECTORY),
false,

View File

@ -37,7 +37,6 @@
#include "../paths.h"
#include "../list_special.h"
static bool recording_enable;
static const record_driver_t *record_drivers[] = {
#ifdef HAVE_FFMPEG
@ -47,8 +46,15 @@ static const record_driver_t *record_drivers[] = {
NULL,
};
static const record_driver_t *recording_driver;
static void *recording_data;
unsigned recording_width = 0;
unsigned recording_height = 0;
size_t recording_gpu_width = 0;
size_t recording_gpu_height = 0;
static bool recording_enable = false;
static bool recording_use_output_dir = false;
static const record_driver_t *recording_driver = NULL;
static void *recording_data = NULL;
/**
* record_driver_find_ident:
@ -182,7 +188,6 @@ void recording_dump_frame(const void *data, unsigned width,
unsigned height, size_t pitch)
{
struct ffemu_video_data ffemu_data = {0};
global_t *global = global_get_ptr();
if (!recording_data)
return;
@ -210,8 +215,8 @@ void recording_dump_frame(const void *data, unsigned width,
}
/* User has resized. We kinda have a problem now. */
if (vp.width != global->record.gpu_width ||
vp.height != global->record.gpu_height)
if ( vp.width != recording_gpu_width ||
vp.height != recording_gpu_height)
{
RARCH_WARN("%s\n", msg_hash_to_str(MSG_RECORDING_TERMINATED_DUE_TO_RESIZE));
@ -232,9 +237,9 @@ void recording_dump_frame(const void *data, unsigned width,
if (!video_driver_read_viewport(gpu_buf))
return;
ffemu_data.pitch = global->record.gpu_width * 3;
ffemu_data.width = global->record.gpu_width;
ffemu_data.height = global->record.gpu_height;
ffemu_data.pitch = recording_gpu_width * 3;
ffemu_data.width = recording_gpu_width;
ffemu_data.height = recording_gpu_height;
ffemu_data.data = gpu_buf + (ffemu_data.height - 1) * ffemu_data.pitch;
ffemu_data.pitch = -ffemu_data.pitch;
@ -301,7 +306,6 @@ bool recording_init(void)
{
char recording_file[PATH_MAX_LENGTH] = {0};
struct ffemu_params params = {0};
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
bool *recording_enabled = recording_is_enabled();
@ -331,7 +335,7 @@ bool recording_init(void)
strlcpy(recording_file, path_get(RARCH_PATH_RECORD), sizeof(recording_file));
if (global->record.use_output_dir)
if (recording_use_output_dir)
fill_pathname_join(recording_file,
dir_get(RARCH_DIR_RECORD_OUTPUT),
path_get(RARCH_PATH_RECORD),
@ -378,8 +382,8 @@ bool recording_init(void)
params.aspect_ratio = (float)vp.width / vp.height;
params.pix_fmt = FFEMU_PIX_BGR24;
global->record.gpu_width = vp.width;
global->record.gpu_height = vp.height;
recording_gpu_width = vp.width;
recording_gpu_height = vp.height;
RARCH_LOG("%s %u x %u\n", msg_hash_to_str(MSG_DETECTED_VIEWPORT_OF),
vp.width, vp.height);
@ -390,10 +394,10 @@ bool recording_init(void)
}
else
{
if (global->record.width || global->record.height)
if (recording_width || recording_height)
{
params.out_width = global->record.width;
params.out_height = global->record.height;
params.out_width = recording_width;
params.out_height = recording_height;
}
if (settings->video.force_aspect &&
@ -453,3 +457,27 @@ void recording_driver_set_data_ptr(void *data)
{
recording_data = data;
}
bool *recording_driver_get_use_output_dir_ptr(void)
{
return &recording_use_output_dir;
}
unsigned *recording_driver_get_width(void)
{
return &recording_width;
}
unsigned *recording_driver_get_height(void)
{
return &recording_height;
}
void recording_driver_free_state(void)
{
recording_use_output_dir = false;
recording_gpu_width = 0;
recording_gpu_height = 0;
recording_width = 0;
recording_height = 0;
}

View File

@ -172,6 +172,14 @@ void recording_driver_clear_data_ptr(void);
void recording_driver_set_data_ptr(void *data);
bool *recording_driver_get_use_output_dir_ptr(void);
unsigned *recording_driver_get_width(void);
unsigned *recording_driver_get_height(void);
void recording_driver_free_state(void);
RETRO_END_DECLS
#endif

View File

@ -757,16 +757,15 @@ static void retroarch_parse_input(int argc, char *argv[])
break;
case RA_OPT_SIZE:
{
if (sscanf(optarg, "%ux%u", &global->record.width,
&global->record.height) != 2)
if (sscanf(optarg, "%ux%u",
recording_driver_get_width(),
recording_driver_get_height()) != 2)
{
RARCH_ERR("Wrong format for --size.\n");
retroarch_print_help(argv[0]);
retroarch_fail(1, "retroarch_parse_input()");
}
break;
}
case RA_OPT_RECORDCONFIG:
path_set(RARCH_PATH_RECORD_CONFIG, optarg);

View File

@ -761,6 +761,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
dir_clear(RARCH_DIR_RECORD_CONFIG);
dir_clear(RARCH_DIR_RECORD_OUTPUT);
dir_clear_all();
recording_driver_free_state();
{
global_t *global = global_get_ptr();

View File

@ -154,17 +154,6 @@ typedef struct global
} netplay;
#endif
/* Recording. */
struct
{
unsigned width;
unsigned height;
size_t gpu_width;
size_t gpu_height;
bool use_output_dir;
} record;
/* Settings and/or global state that is specific to
* a console-style implementation. */
struct