Skip to content

Commit

Permalink
Merge pull request libretro#13216 from libretro/splitup-record
Browse files Browse the repository at this point in the history
Split up recording code
  • Loading branch information
inactive123 authored Nov 11, 2021
2 parents 771585f + 0b768d0 commit 1280151
Show file tree
Hide file tree
Showing 18 changed files with 755 additions and 710 deletions.
15 changes: 8 additions & 7 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ endif

OBJ += frontend/frontend_driver.o \
retroarch.o \
record/record_driver.o \
command.o \
msg_hash.o \
midi_driver.o \
Expand Down Expand Up @@ -1093,13 +1094,13 @@ endif
ifeq ($(HAVE_VIDEO_LAYOUT), 1)
DEFINES += -DHAVE_VIDEO_LAYOUT
OBJ += \
gfx/video_layout.o \
gfx/video_layout/view.o \
gfx/video_layout/element.o \
gfx/video_layout/component.o \
gfx/video_layout/internal.o \
gfx/video_layout/scope.o \
gfx/video_layout/load.o
gfx/video_layout.o \
gfx/video_layout/view.o \
gfx/video_layout/element.o \
gfx/video_layout/component.o \
gfx/video_layout/internal.o \
gfx/video_layout/scope.o \
gfx/video_layout/load.o
endif

ifeq ($(HAVE_STB_FONT), 1)
Expand Down
1 change: 1 addition & 0 deletions audio/audio_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "../retroarch.h"
#include "../list_special.h"
#include "../file_path_special.h"
#include "../record/record_driver.h"
#include "../tasks/task_content.h"
#include "../verbosity.h"

Expand Down
46 changes: 20 additions & 26 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "verbosity.h"

#include "audio/audio_driver.h"
#include "record/record_driver.h"
#include "gfx/gfx_animation.h"

#include "tasks/task_content.h"
Expand Down Expand Up @@ -1433,6 +1434,7 @@ static struct config_path_setting *populate_settings_path(
settings_t *settings, int *size)
{
unsigned count = 0;
recording_state_t *recording_st = recording_state_get_ptr();
struct config_path_setting *tmp = (struct config_path_setting*)calloc(1, (*size + 1) * sizeof(struct config_path_setting));

if (!tmp)
Expand Down Expand Up @@ -1562,16 +1564,10 @@ static struct config_path_setting *populate_settings_path(
"screenshot_directory",
settings->paths.directory_screenshot, true, NULL, false);

{
global_t *global = global_get_ptr();
if (global)
{
SETTING_PATH("recording_output_directory",
global->record.output_dir, false, NULL, true);
SETTING_PATH("recording_config_directory",
global->record.config_dir, false, NULL, true);
}
}
SETTING_PATH("recording_output_directory",
recording_st->output_dir, false, NULL, true);
SETTING_PATH("recording_config_directory",
recording_st->config_dir, false, NULL, true);

SETTING_ARRAY("log_dir", settings->paths.log_dir, true, NULL, true);

Expand Down Expand Up @@ -2383,6 +2379,7 @@ void config_set_defaults(void *data)
#endif
global_t *global = (global_t*)data;
settings_t *settings = config_st;
recording_state_t *recording_st = recording_state_get_ptr();
int bool_settings_size = sizeof(settings->bools) / sizeof(settings->bools.placeholder);
int float_settings_size = sizeof(settings->floats) / sizeof(settings->floats.placeholder);
int int_settings_size = sizeof(settings->ints) / sizeof(settings->ints.placeholder);
Expand Down Expand Up @@ -2668,23 +2665,20 @@ void config_set_defaults(void *data)
retroarch_ctl(RARCH_CTL_UNSET_BPS_PREF, NULL);
retroarch_ctl(RARCH_CTL_UNSET_IPS_PREF, NULL);

if (global)
{
*global->record.output_dir = '\0';
*global->record.config_dir = '\0';
}
*recording_st->output_dir = '\0';
*recording_st->config_dir = '\0';

*settings->paths.path_core_options = '\0';
*settings->paths.path_content_favorites = '\0';
*settings->paths.path_content_history = '\0';
*settings->paths.path_core_options = '\0';
*settings->paths.path_content_favorites = '\0';
*settings->paths.path_content_history = '\0';
*settings->paths.path_content_image_history = '\0';
*settings->paths.path_content_music_history = '\0';
*settings->paths.path_content_video_history = '\0';
*settings->paths.path_cheat_settings = '\0';
*settings->paths.path_cheat_settings = '\0';
#if !defined(__APPLE__)
*settings->arrays.bundle_assets_src = '\0';
*settings->arrays.bundle_assets_dst = '\0';
*settings->arrays.bundle_assets_dst_subdir = '\0';
*settings->arrays.bundle_assets_src = '\0';
*settings->arrays.bundle_assets_dst = '\0';
*settings->arrays.bundle_assets_dst_subdir = '\0';
#endif
*settings->paths.path_cheat_database = '\0';
*settings->paths.path_menu_wallpaper = '\0';
Expand Down Expand Up @@ -2872,13 +2866,13 @@ void config_set_defaults(void *data)
g_defaults.dirs[DEFAULT_DIR_LOGS]);

if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_RECORD_OUTPUT]))
fill_pathname_expand_special(global->record.output_dir,
fill_pathname_expand_special(recording_st->output_dir,
g_defaults.dirs[DEFAULT_DIR_RECORD_OUTPUT],
sizeof(global->record.output_dir));
sizeof(recording_st->output_dir));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_RECORD_CONFIG]))
fill_pathname_expand_special(global->record.config_dir,
fill_pathname_expand_special(recording_st->config_dir,
g_defaults.dirs[DEFAULT_DIR_RECORD_CONFIG],
sizeof(global->record.config_dir));
sizeof(recording_st->config_dir));

if (!string_is_empty(g_defaults.path_config))
{
Expand Down
8 changes: 5 additions & 3 deletions gfx/drivers/gl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "../../dynamic.h"

#include "../../retroarch.h"
#include "../../record/record_driver.h"
#include "../../verbosity.h"
#include "../common/gl2_common.h"

Expand Down Expand Up @@ -3617,7 +3618,8 @@ static void *gl2_init(const video_info_t *video,
const char *version = NULL;
struct retro_hw_render_callback *hwr = NULL;
char *error_string = NULL;
gl2_t *gl = (gl2_t*)calloc(1, sizeof(gl2_t));
recording_state_t *recording_st = recording_state_get_ptr();
gl2_t *gl = (gl2_t*)calloc(1, sizeof(gl2_t));
const gfx_ctx_driver_t *ctx_driver = gl2_get_context(gl);

if (!gl || !ctx_driver)
Expand Down Expand Up @@ -3953,12 +3955,12 @@ static void *gl2_init(const video_info_t *video,
FONT_DRIVER_RENDER_OPENGL_API);

/* Only bother with PBO readback if we're doing GPU recording.
* Check recording_is_enabled() and not
* Check recording_st->enable and not
* driver.recording_data, because recording is
* not initialized yet.
*/
gl->pbo_readback_enable = video_gpu_record
&& recording_is_enabled();
&& recording_st->enable;

if (gl->pbo_readback_enable && gl2_init_pbo_readback(gl))
{
Expand Down
4 changes: 3 additions & 1 deletion gfx/drivers/gl3.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#endif

#include "../font_driver.h"
#include "../../record/record_driver.h"

#ifdef HAVE_MENU
#include "../../menu/menu_driver.h"
Expand Down Expand Up @@ -1331,7 +1332,8 @@ static void *gl_core_init(const video_info_t *video,
FONT_DRIVER_RENDER_OPENGL_CORE_API);
}

gl->pbo_readback_enable = video_gpu_record && recording_is_enabled();
gl->pbo_readback_enable = video_gpu_record
&& recording_state_get_ptr()->enable;

if (gl->pbo_readback_enable && gl_core_init_pbo_readback(gl))
{
Expand Down
7 changes: 5 additions & 2 deletions gfx/drivers/vulkan.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

#include "../../retroarch.h"
#include "../../verbosity.h"
#include "../../record/record_driver.h"

#include "../video_coord_array.h"

Expand Down Expand Up @@ -1131,12 +1132,14 @@ static void vulkan_init_hw_render(vk_t *vk)
static void vulkan_init_readback(vk_t *vk)
{
/* Only bother with this if we're doing GPU recording.
* Check recording_is_enabled() and not
* Check recording_st->enable and not
* driver.recording_data, because recording is
* not initialized yet.
*/
settings_t *settings = config_get_ptr();
bool recording_enabled = recording_is_enabled();
recording_state_t
*recording_st = recording_state_get_ptr();
bool recording_enabled = recording_st->enable;
bool video_gpu_record = settings->bools.video_gpu_record;
vk->readback.streamed = video_gpu_record && recording_enabled;

Expand Down
1 change: 1 addition & 0 deletions gfx/video_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

#include "../audio/audio_driver.h"
#include "../frontend/frontend_driver.h"
#include "../record/record_driver.h"
#include "../ui/ui_companion_driver.h"
#include "../driver.h"
#include "../file_path_special.h"
Expand Down
1 change: 1 addition & 0 deletions griffin/griffin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,7 @@ WIFI
/*============================================================
RECORDING
============================================================ */
#include "../record/record_driver.c"
#ifdef HAVE_FFMPEG
#include "../record/drivers/record_ffmpeg.c"
#endif
Expand Down
6 changes: 4 additions & 2 deletions menu/cbs/menu_cbs_ok.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include "../../configuration.h"
#include "../../core_info.h"
#include "../../audio/audio_driver.h"
#include "../../record/record_driver.h"
#include "../../frontend/frontend_driver.h"
#include "../../defaults.h"
#include "../../core_option_manager.h"
Expand Down Expand Up @@ -552,6 +553,7 @@ int generic_action_ok_displaylist_push(const char *path,
#endif
const char *dir_menu_content = settings->paths.directory_menu_content;
const char *dir_libretro = settings->paths.directory_libretro;
recording_state_t *recording_st = recording_state_get_ptr();

if (!menu || string_is_equal(menu_ident, "null"))
{
Expand Down Expand Up @@ -1070,7 +1072,7 @@ int generic_action_ok_displaylist_push(const char *path,
global_t *global = global_get_ptr();
info.type = type;
info.directory_ptr = idx;
info_path = global->record.config_dir;
info_path = recording_st->config_dir;
info_label = label;
dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_FILE;
}
Expand All @@ -1081,7 +1083,7 @@ int generic_action_ok_displaylist_push(const char *path,
global_t *global = global_get_ptr();
info.type = type;
info.directory_ptr = idx;
info_path = global->record.config_dir;
info_path = recording_st->config_dir;
info_label = label;
dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_FILE;
}
Expand Down
7 changes: 5 additions & 2 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
#endif

#include "../audio/audio_driver.h"
#include "../record/record_driver.h"
#include "menu_cbs.h"
#include "menu_driver.h"
#include "menu_entries.h"
Expand Down Expand Up @@ -3000,7 +3001,8 @@ static int menu_displaylist_parse_load_content_settings(

if (string_is_not_equal(settings->arrays.record_driver, "null"))
{
if (!recording_is_enabled())
recording_state_t *recording_st = recording_state_get_ptr();
if (!recording_st->enable)
{
if (settings->bools.quick_menu_show_start_recording && !settings->bools.kiosk_mode_enable)
{
Expand All @@ -3022,7 +3024,8 @@ static int menu_displaylist_parse_load_content_settings(
}
else
{
if (streaming_is_enabled())
recording_state_t *recording_st = recording_state_get_ptr();
if (recording_st->streaming_enable)
{
if (menu_entries_append_enum(list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QUICK_MENU_STOP_STREAMING),
Expand Down
14 changes: 8 additions & 6 deletions menu/menu_setting.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
#include "../wifi/wifi_driver.h"
#include "../midi_driver.h"
#include "../location_driver.h"
#include "../record/record_driver.h"
#include "../tasks/tasks_internal.h"
#include "../config.def.h"
#include "../ui/ui_companion_driver.h"
Expand Down Expand Up @@ -8885,6 +8886,7 @@ static bool setting_append_list(
unsigned user;
rarch_setting_group_info_t group_info;
rarch_setting_group_info_t subgroup_info;
recording_state_t *recording_st = recording_state_get_ptr();

group_info.name = NULL;
subgroup_info.name = NULL;
Expand Down Expand Up @@ -13731,8 +13733,8 @@ static bool setting_append_list(

CONFIG_DIR(
list, list_info,
global->record.output_dir,
sizeof(global->record.output_dir),
recording_st->output_dir,
sizeof(recording_st->output_dir),
MENU_ENUM_LABEL_RECORDING_OUTPUT_DIRECTORY,
MENU_ENUM_LABEL_VALUE_RECORDING_OUTPUT_DIRECTORY,
g_defaults.dirs[DEFAULT_DIR_RECORD_OUTPUT],
Expand Down Expand Up @@ -20038,8 +20040,8 @@ static bool setting_append_list(
{
CONFIG_DIR(
list, list_info,
global->record.output_dir,
sizeof(global->record.output_dir),
recording_st->output_dir,
sizeof(recording_st->output_dir),
MENU_ENUM_LABEL_RECORDING_OUTPUT_DIRECTORY,
MENU_ENUM_LABEL_VALUE_RECORDING_OUTPUT_DIRECTORY,
g_defaults.dirs[DEFAULT_DIR_RECORD_OUTPUT],
Expand All @@ -20053,8 +20055,8 @@ static bool setting_append_list(

CONFIG_DIR(
list, list_info,
global->record.config_dir,
sizeof(global->record.config_dir),
recording_st->config_dir,
sizeof(recording_st->config_dir),
MENU_ENUM_LABEL_RECORDING_CONFIG_DIRECTORY,
MENU_ENUM_LABEL_VALUE_RECORDING_CONFIG_DIRECTORY,
g_defaults.dirs[DEFAULT_DIR_RECORD_CONFIG],
Expand Down
2 changes: 2 additions & 0 deletions record/drivers/record_ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#include <time.h>
#endif

#include "../record_driver.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand Down
Loading

0 comments on commit 1280151

Please sign in to comment.