mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 10:10:57 +00:00
Move code to movie.c
This commit is contained in:
parent
7b26c43adc
commit
1cf7d758b5
94
movie.c
94
movie.c
@ -31,6 +31,9 @@
|
||||
#include "msg_hash.h"
|
||||
#include "verbosity.h"
|
||||
|
||||
#include "command.h"
|
||||
#include "file_path_special.h"
|
||||
|
||||
struct bsv_movie
|
||||
{
|
||||
FILE *file;
|
||||
@ -458,3 +461,94 @@ bool bsv_movie_init_handle(const char *path,
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Checks if movie is being played back. */
|
||||
static bool runloop_check_movie_playback(void)
|
||||
{
|
||||
if (!bsv_movie_ctl(BSV_MOVIE_CTL_END, NULL))
|
||||
return false;
|
||||
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED), 2, 180, false);
|
||||
RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED));
|
||||
|
||||
command_event(CMD_EVENT_BSV_MOVIE_DEINIT, NULL);
|
||||
|
||||
bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_END, NULL);
|
||||
bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_PLAYBACK, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Checks if movie is being recorded. */
|
||||
static bool runloop_check_movie_record(void)
|
||||
{
|
||||
if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
||||
return false;
|
||||
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED), 2, 180, true);
|
||||
RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED));
|
||||
|
||||
command_event(CMD_EVENT_BSV_MOVIE_DEINIT, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool runloop_check_movie_init(void)
|
||||
{
|
||||
char msg[128] = {0};
|
||||
char path[PATH_MAX_LENGTH] = {0};
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
||||
return false;
|
||||
|
||||
settings->rewind_granularity = 1;
|
||||
|
||||
if (settings->state_slot > 0)
|
||||
snprintf(path, sizeof(path), "%s%d",
|
||||
bsv_movie_get_path(), settings->state_slot);
|
||||
else
|
||||
strlcpy(path, bsv_movie_get_path(), sizeof(path));
|
||||
|
||||
strlcat(path,
|
||||
file_path_str(FILE_PATH_BSV_EXTENSION),
|
||||
sizeof(path));
|
||||
|
||||
snprintf(msg, sizeof(msg), "%s \"%s\".",
|
||||
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
|
||||
path);
|
||||
|
||||
bsv_movie_init_handle(path, RARCH_MOVIE_RECORD);
|
||||
|
||||
if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
||||
return false;
|
||||
|
||||
if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
||||
{
|
||||
runloop_msg_queue_push(msg, 2, 180, true);
|
||||
RARCH_LOG("%s \"%s\".\n",
|
||||
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
|
||||
path);
|
||||
}
|
||||
else
|
||||
{
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD),
|
||||
2, 180, true);
|
||||
RARCH_ERR("%s\n",
|
||||
msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bsv_movie_check(void)
|
||||
{
|
||||
if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_ON, NULL))
|
||||
return runloop_check_movie_playback();
|
||||
if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
||||
return runloop_check_movie_init();
|
||||
return runloop_check_movie_record();
|
||||
}
|
||||
|
2
movie.h
2
movie.h
@ -77,6 +77,8 @@ void bsv_movie_set_start_path(const char *path);
|
||||
|
||||
bool bsv_movie_ctl(enum bsv_ctl_state state, void *data);
|
||||
|
||||
bool bsv_movie_check(void);
|
||||
|
||||
bool bsv_movie_init_handle(const char *path, enum rarch_movie_type type);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
93
runloop.c
93
runloop.c
@ -207,97 +207,6 @@ char* runloop_msg_queue_pull(void)
|
||||
return strdup(msg_info.msg);
|
||||
}
|
||||
|
||||
/* Checks if movie is being played back. */
|
||||
static bool runloop_check_movie_playback(void)
|
||||
{
|
||||
if (!bsv_movie_ctl(BSV_MOVIE_CTL_END, NULL))
|
||||
return false;
|
||||
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED), 2, 180, false);
|
||||
RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED));
|
||||
|
||||
command_event(CMD_EVENT_BSV_MOVIE_DEINIT, NULL);
|
||||
|
||||
bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_END, NULL);
|
||||
bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_PLAYBACK, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Checks if movie is being recorded. */
|
||||
static bool runloop_check_movie_record(void)
|
||||
{
|
||||
if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
||||
return false;
|
||||
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED), 2, 180, true);
|
||||
RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED));
|
||||
|
||||
command_event(CMD_EVENT_BSV_MOVIE_DEINIT, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool runloop_check_movie_init(void)
|
||||
{
|
||||
char msg[128] = {0};
|
||||
char path[PATH_MAX_LENGTH] = {0};
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
||||
return false;
|
||||
|
||||
settings->rewind_granularity = 1;
|
||||
|
||||
if (settings->state_slot > 0)
|
||||
snprintf(path, sizeof(path), "%s%d",
|
||||
bsv_movie_get_path(), settings->state_slot);
|
||||
else
|
||||
strlcpy(path, bsv_movie_get_path(), sizeof(path));
|
||||
|
||||
strlcat(path,
|
||||
file_path_str(FILE_PATH_BSV_EXTENSION),
|
||||
sizeof(path));
|
||||
|
||||
snprintf(msg, sizeof(msg), "%s \"%s\".",
|
||||
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
|
||||
path);
|
||||
|
||||
bsv_movie_init_handle(path, RARCH_MOVIE_RECORD);
|
||||
|
||||
if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
||||
return false;
|
||||
|
||||
if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
||||
{
|
||||
runloop_msg_queue_push(msg, 2, 180, true);
|
||||
RARCH_LOG("%s \"%s\".\n",
|
||||
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
|
||||
path);
|
||||
}
|
||||
else
|
||||
{
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD),
|
||||
2, 180, true);
|
||||
RARCH_ERR("%s\n",
|
||||
msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool runloop_check_movie(void)
|
||||
{
|
||||
if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_ON, NULL))
|
||||
return runloop_check_movie_playback();
|
||||
if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
||||
return runloop_check_movie_init();
|
||||
return runloop_check_movie_record();
|
||||
}
|
||||
|
||||
/* Checks if slowmotion toggle/hold was being pressed and/or held. */
|
||||
static bool runloop_check_slowmotion(bool *ptr)
|
||||
{
|
||||
@ -727,7 +636,7 @@ static bool runloop_check_state(event_cmd_state_t *cmd,
|
||||
runloop_check_slowmotion(&tmp);
|
||||
|
||||
if (runloop_cmd_triggered(cmd, RARCH_MOVIE_RECORD_TOGGLE))
|
||||
runloop_check_movie();
|
||||
bsv_movie_check();
|
||||
|
||||
if (runloop_cmd_triggered(cmd, RARCH_SHADER_NEXT) ||
|
||||
runloop_cmd_triggered(cmd, RARCH_SHADER_PREV))
|
||||
|
Loading…
Reference in New Issue
Block a user