mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-21 18:21:51 +00:00
Move bsv global state to movie.c
This commit is contained in:
parent
251075fc03
commit
f1a0068dc7
@ -25,6 +25,7 @@
|
|||||||
#include "performance.h"
|
#include "performance.h"
|
||||||
#include "dynamic.h"
|
#include "dynamic.h"
|
||||||
#include "content.h"
|
#include "content.h"
|
||||||
|
#include "movie.h"
|
||||||
#include "screenshot.h"
|
#include "screenshot.h"
|
||||||
#include "msg_hash.h"
|
#include "msg_hash.h"
|
||||||
#include "retroarch.h"
|
#include "retroarch.h"
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "input_remapping.h"
|
#include "input_remapping.h"
|
||||||
|
|
||||||
#include "../general.h"
|
#include "../general.h"
|
||||||
|
#include "../movie.h"
|
||||||
#include "../string_list_special.h"
|
#include "../string_list_special.h"
|
||||||
#include "../verbosity.h"
|
#include "../verbosity.h"
|
||||||
|
|
||||||
|
104
movie.c
104
movie.c
@ -47,6 +47,23 @@ struct bsv_movie
|
|||||||
bool did_rewind;
|
bool did_rewind;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct bsv_state
|
||||||
|
{
|
||||||
|
/* Movie playback/recording support. */
|
||||||
|
bsv_movie_t *movie;
|
||||||
|
char movie_path[PATH_MAX_LENGTH];
|
||||||
|
bool movie_playback;
|
||||||
|
bool eof_exit;
|
||||||
|
|
||||||
|
/* Immediate playback/recording. */
|
||||||
|
char movie_start_path[PATH_MAX_LENGTH];
|
||||||
|
bool movie_start_recording;
|
||||||
|
bool movie_start_playback;
|
||||||
|
bool movie_end;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bsv_state bsv_movie_state;
|
||||||
|
|
||||||
static bool init_playback(bsv_movie_t *handle, const char *path)
|
static bool init_playback(bsv_movie_t *handle, const char *path)
|
||||||
{
|
{
|
||||||
uint32_t state_size;
|
uint32_t state_size;
|
||||||
@ -158,8 +175,7 @@ void bsv_movie_free(bsv_movie_t *handle)
|
|||||||
|
|
||||||
bool bsv_movie_get_input(int16_t *input)
|
bool bsv_movie_get_input(int16_t *input)
|
||||||
{
|
{
|
||||||
global_t *global = global_get_ptr();
|
bsv_movie_t *handle = bsv_movie_state.movie;
|
||||||
bsv_movie_t *handle = global->bsv.movie;
|
|
||||||
if (fread(input, sizeof(int16_t), 1, handle->file) != 1)
|
if (fread(input, sizeof(int16_t), 1, handle->file) != 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -169,8 +185,7 @@ bool bsv_movie_get_input(int16_t *input)
|
|||||||
|
|
||||||
void bsv_movie_set_input(int16_t input)
|
void bsv_movie_set_input(int16_t input)
|
||||||
{
|
{
|
||||||
global_t *global = global_get_ptr();
|
bsv_movie_t *handle = bsv_movie_state.movie;
|
||||||
bsv_movie_t *handle = global->bsv.movie;
|
|
||||||
|
|
||||||
input = swap_if_big16(input);
|
input = swap_if_big16(input);
|
||||||
fwrite(&input, sizeof(int16_t), 1, handle->file);
|
fwrite(&input, sizeof(int16_t), 1, handle->file);
|
||||||
@ -266,20 +281,19 @@ void bsv_movie_frame_rewind(bsv_movie_t *handle)
|
|||||||
static void bsv_movie_init_state(void)
|
static void bsv_movie_init_state(void)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
global_t *global = global_get_ptr();
|
|
||||||
|
|
||||||
if (bsv_movie_ctl(BSV_MOVIE_CTL_START_PLAYBACK, NULL))
|
if (bsv_movie_ctl(BSV_MOVIE_CTL_START_PLAYBACK, NULL))
|
||||||
{
|
{
|
||||||
if (!(bsv_movie_init_handle(global->bsv.movie_start_path,
|
if (!(bsv_movie_init_handle(bsv_movie_state.movie_start_path,
|
||||||
RARCH_MOVIE_PLAYBACK)))
|
RARCH_MOVIE_PLAYBACK)))
|
||||||
{
|
{
|
||||||
RARCH_ERR("%s: \"%s\".\n",
|
RARCH_ERR("%s: \"%s\".\n",
|
||||||
msg_hash_to_str(MSG_FAILED_TO_LOAD_MOVIE_FILE),
|
msg_hash_to_str(MSG_FAILED_TO_LOAD_MOVIE_FILE),
|
||||||
global->bsv.movie_start_path);
|
bsv_movie_state.movie_start_path);
|
||||||
retro_fail(1, "event_init_movie()");
|
retro_fail(1, "event_init_movie()");
|
||||||
}
|
}
|
||||||
|
|
||||||
global->bsv.movie_playback = true;
|
bsv_movie_state.movie_playback = true;
|
||||||
rarch_main_msg_queue_push_new(MSG_STARTING_MOVIE_PLAYBACK, 2, 180, false);
|
rarch_main_msg_queue_push_new(MSG_STARTING_MOVIE_PLAYBACK, 2, 180, false);
|
||||||
RARCH_LOG("%s.\n", msg_hash_to_str(MSG_STARTING_MOVIE_PLAYBACK));
|
RARCH_LOG("%s.\n", msg_hash_to_str(MSG_STARTING_MOVIE_PLAYBACK));
|
||||||
settings->rewind_granularity = 1;
|
settings->rewind_granularity = 1;
|
||||||
@ -290,9 +304,9 @@ static void bsv_movie_init_state(void)
|
|||||||
snprintf(msg, sizeof(msg),
|
snprintf(msg, sizeof(msg),
|
||||||
"%s \"%s\".",
|
"%s \"%s\".",
|
||||||
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
|
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
|
||||||
global->bsv.movie_start_path);
|
bsv_movie_state.movie_start_path);
|
||||||
|
|
||||||
if (!(bsv_movie_init_handle(global->bsv.movie_start_path,
|
if (!(bsv_movie_init_handle(bsv_movie_state.movie_start_path,
|
||||||
RARCH_MOVIE_RECORD)))
|
RARCH_MOVIE_RECORD)))
|
||||||
{
|
{
|
||||||
rarch_main_msg_queue_push_new(MSG_FAILED_TO_START_MOVIE_RECORD, 1, 180, true);
|
rarch_main_msg_queue_push_new(MSG_FAILED_TO_START_MOVIE_RECORD, 1, 180, true);
|
||||||
@ -303,71 +317,69 @@ static void bsv_movie_init_state(void)
|
|||||||
rarch_main_msg_queue_push(msg, 1, 180, true);
|
rarch_main_msg_queue_push(msg, 1, 180, true);
|
||||||
RARCH_LOG("%s \"%s\".\n",
|
RARCH_LOG("%s \"%s\".\n",
|
||||||
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
|
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
|
||||||
global->bsv.movie_start_path);
|
bsv_movie_state.movie_start_path);
|
||||||
settings->rewind_granularity = 1;
|
settings->rewind_granularity = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bsv_movie_ctl(enum bsv_ctl_state state, void *data)
|
bool bsv_movie_ctl(enum bsv_ctl_state state, void *data)
|
||||||
{
|
{
|
||||||
global_t *global = global_get_ptr();
|
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case BSV_MOVIE_CTL_IS_INITED:
|
case BSV_MOVIE_CTL_IS_INITED:
|
||||||
return global->bsv.movie;
|
return bsv_movie_state.movie;
|
||||||
case BSV_MOVIE_CTL_PLAYBACK_ON:
|
case BSV_MOVIE_CTL_PLAYBACK_ON:
|
||||||
return global->bsv.movie && global->bsv.movie_playback;
|
return bsv_movie_state.movie && bsv_movie_state.movie_playback;
|
||||||
case BSV_MOVIE_CTL_PLAYBACK_OFF:
|
case BSV_MOVIE_CTL_PLAYBACK_OFF:
|
||||||
return global->bsv.movie && !global->bsv.movie_playback;
|
return bsv_movie_state.movie && !bsv_movie_state.movie_playback;
|
||||||
case BSV_MOVIE_CTL_START_RECORDING:
|
case BSV_MOVIE_CTL_START_RECORDING:
|
||||||
return global->bsv.movie_start_recording;
|
return bsv_movie_state.movie_start_recording;
|
||||||
case BSV_MOVIE_CTL_SET_START_RECORDING:
|
case BSV_MOVIE_CTL_SET_START_RECORDING:
|
||||||
global->bsv.movie_start_recording = true;
|
bsv_movie_state.movie_start_recording = true;
|
||||||
break;
|
break;
|
||||||
case BSV_MOVIE_CTL_UNSET_START_RECORDING:
|
case BSV_MOVIE_CTL_UNSET_START_RECORDING:
|
||||||
global->bsv.movie_start_recording = false;
|
bsv_movie_state.movie_start_recording = false;
|
||||||
break;
|
break;
|
||||||
case BSV_MOVIE_CTL_START_PLAYBACK:
|
case BSV_MOVIE_CTL_START_PLAYBACK:
|
||||||
return global->bsv.movie_start_playback;
|
return bsv_movie_state.movie_start_playback;
|
||||||
case BSV_MOVIE_CTL_SET_START_PLAYBACK:
|
case BSV_MOVIE_CTL_SET_START_PLAYBACK:
|
||||||
global->bsv.movie_start_playback = true;
|
bsv_movie_state.movie_start_playback = true;
|
||||||
break;
|
break;
|
||||||
case BSV_MOVIE_CTL_UNSET_START_PLAYBACK:
|
case BSV_MOVIE_CTL_UNSET_START_PLAYBACK:
|
||||||
global->bsv.movie_start_playback = false;
|
bsv_movie_state.movie_start_playback = false;
|
||||||
break;
|
break;
|
||||||
case BSV_MOVIE_CTL_END:
|
case BSV_MOVIE_CTL_END:
|
||||||
return global->bsv.movie_end;
|
return bsv_movie_state.movie_end;
|
||||||
case BSV_MOVIE_CTL_SET_END_EOF:
|
case BSV_MOVIE_CTL_SET_END_EOF:
|
||||||
global->bsv.eof_exit = true;
|
bsv_movie_state.eof_exit = true;
|
||||||
break;
|
break;
|
||||||
case BSV_MOVIE_CTL_END_EOF:
|
case BSV_MOVIE_CTL_END_EOF:
|
||||||
return global->bsv.movie_end && global->bsv.eof_exit;
|
return bsv_movie_state.movie_end && bsv_movie_state.eof_exit;
|
||||||
case BSV_MOVIE_CTL_SET_END:
|
case BSV_MOVIE_CTL_SET_END:
|
||||||
global->bsv.movie_end = true;
|
bsv_movie_state.movie_end = true;
|
||||||
break;
|
break;
|
||||||
case BSV_MOVIE_CTL_UNSET_END:
|
case BSV_MOVIE_CTL_UNSET_END:
|
||||||
global->bsv.movie_end = false;
|
bsv_movie_state.movie_end = false;
|
||||||
break;
|
break;
|
||||||
case BSV_MOVIE_CTL_UNSET_PLAYBACK:
|
case BSV_MOVIE_CTL_UNSET_PLAYBACK:
|
||||||
global->bsv.movie_playback = false;
|
bsv_movie_state.movie_playback = false;
|
||||||
break;
|
break;
|
||||||
case BSV_MOVIE_CTL_DEINIT:
|
case BSV_MOVIE_CTL_DEINIT:
|
||||||
if (global->bsv.movie)
|
if (bsv_movie_state.movie)
|
||||||
bsv_movie_free(global->bsv.movie);
|
bsv_movie_free(bsv_movie_state.movie);
|
||||||
global->bsv.movie = NULL;
|
bsv_movie_state.movie = NULL;
|
||||||
break;
|
break;
|
||||||
case BSV_MOVIE_CTL_INIT:
|
case BSV_MOVIE_CTL_INIT:
|
||||||
bsv_movie_init_state();
|
bsv_movie_init_state();
|
||||||
break;
|
break;
|
||||||
case BSV_MOVIE_CTL_SET_FRAME_START:
|
case BSV_MOVIE_CTL_SET_FRAME_START:
|
||||||
bsv_movie_set_frame_start(global->bsv.movie);
|
bsv_movie_set_frame_start(bsv_movie_state.movie);
|
||||||
break;
|
break;
|
||||||
case BSV_MOVIE_CTL_SET_FRAME_END:
|
case BSV_MOVIE_CTL_SET_FRAME_END:
|
||||||
bsv_movie_set_frame_end(global->bsv.movie);
|
bsv_movie_set_frame_end(bsv_movie_state.movie);
|
||||||
break;
|
break;
|
||||||
case BSV_MOVIE_CTL_FRAME_REWIND:
|
case BSV_MOVIE_CTL_FRAME_REWIND:
|
||||||
bsv_movie_frame_rewind(global->bsv.movie);
|
bsv_movie_frame_rewind(bsv_movie_state.movie);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@ -378,36 +390,24 @@ bool bsv_movie_ctl(enum bsv_ctl_state state, void *data)
|
|||||||
|
|
||||||
const char *bsv_movie_get_path(void)
|
const char *bsv_movie_get_path(void)
|
||||||
{
|
{
|
||||||
global_t *global = global_get_ptr();
|
return bsv_movie_state.movie_path;
|
||||||
if (!global)
|
|
||||||
return NULL;
|
|
||||||
return global->bsv.movie_path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void bsv_movie_set_path(const char *path)
|
void bsv_movie_set_path(const char *path)
|
||||||
{
|
{
|
||||||
global_t *global = global_get_ptr();
|
strlcpy(bsv_movie_state.movie_path, path, sizeof(bsv_movie_state.movie_path));
|
||||||
if (!global)
|
|
||||||
return;
|
|
||||||
strlcpy(global->bsv.movie_path, path, sizeof(global->bsv.movie_path));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void bsv_movie_set_start_path(const char *path)
|
void bsv_movie_set_start_path(const char *path)
|
||||||
{
|
{
|
||||||
global_t *global = global_get_ptr();
|
strlcpy(bsv_movie_state.movie_start_path, path,
|
||||||
if (!global)
|
sizeof(bsv_movie_state.movie_start_path));
|
||||||
return;
|
|
||||||
strlcpy(global->bsv.movie_start_path, path,
|
|
||||||
sizeof(global->bsv.movie_start_path));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bsv_movie_init_handle(const char *path, enum rarch_movie_type type)
|
bool bsv_movie_init_handle(const char *path, enum rarch_movie_type type)
|
||||||
{
|
{
|
||||||
global_t *global = global_get_ptr();
|
bsv_movie_state.movie = bsv_movie_init(path, type);
|
||||||
if (!global)
|
if (!bsv_movie_state.movie)
|
||||||
return false;
|
|
||||||
global->bsv.movie = bsv_movie_init(path, type);
|
|
||||||
if (!global->bsv.movie)
|
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "general.h"
|
#include "general.h"
|
||||||
#include "autosave.h"
|
#include "autosave.h"
|
||||||
#include "dynamic.h"
|
#include "dynamic.h"
|
||||||
|
#include "movie.h"
|
||||||
#include "msg_hash.h"
|
#include "msg_hash.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "runloop.h"
|
#include "runloop.h"
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include <retro_stat.h>
|
#include <retro_stat.h>
|
||||||
|
|
||||||
#include "msg_hash.h"
|
#include "msg_hash.h"
|
||||||
|
#include "movie.h"
|
||||||
#include "verbosity.h"
|
#include "verbosity.h"
|
||||||
|
|
||||||
#include "audio/audio_driver.h"
|
#include "audio/audio_driver.h"
|
||||||
|
1
rewind.c
1
rewind.c
@ -24,6 +24,7 @@
|
|||||||
#include "general.h"
|
#include "general.h"
|
||||||
#include "msg_hash.h"
|
#include "msg_hash.h"
|
||||||
#include "rewind.h"
|
#include "rewind.h"
|
||||||
|
#include "movie.h"
|
||||||
#include "performance.h"
|
#include "performance.h"
|
||||||
#include "verbosity.h"
|
#include "verbosity.h"
|
||||||
#include "audio/audio_driver.h"
|
#include "audio/audio_driver.h"
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "autosave.h"
|
#include "autosave.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "performance.h"
|
#include "performance.h"
|
||||||
|
#include "movie.h"
|
||||||
#include "retroarch.h"
|
#include "retroarch.h"
|
||||||
#include "runloop.h"
|
#include "runloop.h"
|
||||||
#include "rewind.h"
|
#include "rewind.h"
|
||||||
|
16
runloop.h
16
runloop.h
@ -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 "movie.h"
|
|
||||||
#include "cheats.h"
|
#include "cheats.h"
|
||||||
#include "dynamic.h"
|
#include "dynamic.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
@ -197,21 +196,6 @@ typedef struct global
|
|||||||
} menu;
|
} menu;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
/* Movie playback/recording support. */
|
|
||||||
bsv_movie_t *movie;
|
|
||||||
char movie_path[PATH_MAX_LENGTH];
|
|
||||||
bool movie_playback;
|
|
||||||
bool eof_exit;
|
|
||||||
|
|
||||||
/* Immediate playback/recording. */
|
|
||||||
char movie_start_path[PATH_MAX_LENGTH];
|
|
||||||
bool movie_start_recording;
|
|
||||||
bool movie_start_playback;
|
|
||||||
bool movie_end;
|
|
||||||
} bsv;
|
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
bool load_disable;
|
bool load_disable;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user