[recording] refactor recording_is_enabled no need to use a pointer for all of this

This commit is contained in:
radius 2018-09-15 21:09:41 -05:00
parent 9d490ace3b
commit 16bd85b118
6 changed files with 34 additions and 35 deletions

View File

@ -2172,15 +2172,17 @@ TODO: Add a setting for these tweaks */
video_driver_gpu_record_deinit();
break;
case CMD_EVENT_RECORD_DEINIT:
if (!recording_deinit())
return false;
{
recording_set_state(false);
if (!recording_deinit())
return false;
}
break;
case CMD_EVENT_RECORD_INIT:
{
command_event(CMD_EVENT_RECORD_DEINIT, NULL);
bool *recording_enabled = recording_is_enabled();
*recording_enabled = true;
if (!recording_init(false))
recording_set_state(true);
if (!recording_init())
return false;
}
break;

View File

@ -1094,8 +1094,8 @@ static void vulkan_init_readback(vk_t *vk)
* not initialized yet.
*/
settings_t *settings = config_get_ptr();
bool *recording_enabled = recording_is_enabled();
vk->readback.streamed = settings->bools.video_gpu_record && *recording_enabled;
bool recording_enabled = recording_is_enabled();
vk->readback.streamed = settings->bools.video_gpu_record && recording_enabled;
if (!vk->readback.streamed)
return;

View File

@ -5230,23 +5230,6 @@ static bool setting_append_list(
parent_group = msg_hash_to_str(MENU_ENUM_LABEL_RECORDING_SETTINGS);
START_SUB_GROUP(list, list_info, "State", &group_info, &subgroup_info, parent_group);
CONFIG_BOOL(
list, list_info,
recording_is_enabled(),
MENU_ENUM_LABEL_RECORD_ENABLE,
MENU_ENUM_LABEL_VALUE_RECORD_ENABLE,
false,
MENU_ENUM_LABEL_VALUE_OFF,
MENU_ENUM_LABEL_VALUE_ON,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler,
SD_FLAG_NONE
);
CONFIG_PATH(
list, list_info,
global->record.config,

View File

@ -51,6 +51,7 @@ unsigned recording_height = 0;
size_t recording_gpu_width = 0;
size_t recording_gpu_height = 0;
static bool recording_enable = false;
static bool streaming_enable = false;
static bool recording_use_output_dir = false;
static const record_driver_t *recording_driver = NULL;
@ -282,9 +283,9 @@ bool recording_deinit(void)
return true;
}
bool *recording_is_enabled(void)
bool recording_is_enabled(void)
{
return &recording_enable;
return recording_enable;
}
void recording_set_state(bool state)
@ -292,6 +293,16 @@ void recording_set_state(bool state)
recording_enable = state;
}
bool *streaming_is_enabled(void)
{
return &streaming_enable;
}
void streaming_set_state(bool state)
{
streaming_enable = state;
}
void recording_push_audio(const int16_t *data, size_t samples)
{
struct ffemu_audio_data ffemu_data;
@ -310,17 +321,17 @@ void recording_push_audio(const int16_t *data, size_t samples)
*
* Returns: true (1) if successful, otherwise false (0).
**/
bool recording_init(bool stream)
bool recording_init()
{
char output[PATH_MAX_LENGTH];
char buf[PATH_MAX_LENGTH];
struct ffemu_params params = {0};
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
bool *recording_enabled = recording_is_enabled();
bool recording_enabled = recording_is_enabled();
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
if (!*recording_enabled)
if (!recording_enabled)
return false;
output[0] = '\0';
@ -349,7 +360,7 @@ bool recording_init(bool stream)
strlcpy(output, global->record.path, sizeof(output));
else
{
if(stream)
if(!streaming_is_enabled())
if (!string_is_empty(settings->paths.path_stream_url))
strlcpy(output, settings->paths.path_stream_url, sizeof(output));
else

View File

@ -158,9 +158,9 @@ void find_record_driver(void);
*
* Returns: true (1) if successful, otherwise false (0).
**/
bool recording_init(bool stream);
bool recording_init(void);
bool *recording_is_enabled(void);
bool recording_is_enabled(void);
void recording_set_state(bool state);

View File

@ -884,10 +884,10 @@ static void retroarch_parse_input_and_config(int argc, char *argv[])
strlcpy(global->record.path, optarg,
sizeof(global->record.path));
{
bool *recording_enabled = recording_is_enabled();
bool recording_enabled = recording_is_enabled();
if (recording_enabled)
*recording_enabled = true;
recording_set_state(true);
}
break;
@ -3194,7 +3194,10 @@ static enum runloop_state runloop_check_state(
if (pressed && !old_pressed)
{
command_event(CMD_EVENT_RECORD_INIT, NULL);
if (!recording_is_enabled())
command_event(CMD_EVENT_RECORD_INIT, NULL);
else
command_event(CMD_EVENT_RECORD_DEINIT, NULL);
bsv_movie_check();
}