diff --git a/command_event.c b/command_event.c index f388714ffb..c3d201c810 100644 --- a/command_event.c +++ b/command_event.c @@ -25,6 +25,7 @@ #include "performance.h" #include "dynamic.h" #include "content.h" +#include "movie.h" #include "screenshot.h" #include "msg_hash.h" #include "retroarch.h" diff --git a/input/input_driver.c b/input/input_driver.c index d74fb56c5e..fe9d85387a 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -19,6 +19,7 @@ #include "input_remapping.h" #include "../general.h" +#include "../movie.h" #include "../string_list_special.h" #include "../verbosity.h" diff --git a/movie.c b/movie.c index e418ab15c2..a72788fc70 100644 --- a/movie.c +++ b/movie.c @@ -47,6 +47,23 @@ struct bsv_movie 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) { uint32_t state_size; @@ -158,8 +175,7 @@ void bsv_movie_free(bsv_movie_t *handle) bool bsv_movie_get_input(int16_t *input) { - global_t *global = global_get_ptr(); - bsv_movie_t *handle = global->bsv.movie; + bsv_movie_t *handle = bsv_movie_state.movie; if (fread(input, sizeof(int16_t), 1, handle->file) != 1) return false; @@ -169,8 +185,7 @@ bool bsv_movie_get_input(int16_t *input) void bsv_movie_set_input(int16_t input) { - global_t *global = global_get_ptr(); - bsv_movie_t *handle = global->bsv.movie; + bsv_movie_t *handle = bsv_movie_state.movie; input = swap_if_big16(input); 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) { 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_init_handle(global->bsv.movie_start_path, + if (!(bsv_movie_init_handle(bsv_movie_state.movie_start_path, RARCH_MOVIE_PLAYBACK))) { RARCH_ERR("%s: \"%s\".\n", 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()"); } - 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_LOG("%s.\n", msg_hash_to_str(MSG_STARTING_MOVIE_PLAYBACK)); settings->rewind_granularity = 1; @@ -290,9 +304,9 @@ static void bsv_movie_init_state(void) snprintf(msg, sizeof(msg), "%s \"%s\".", 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_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_LOG("%s \"%s\".\n", msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), - global->bsv.movie_start_path); + bsv_movie_state.movie_start_path); settings->rewind_granularity = 1; } } bool bsv_movie_ctl(enum bsv_ctl_state state, void *data) { - global_t *global = global_get_ptr(); - switch (state) { case BSV_MOVIE_CTL_IS_INITED: - return global->bsv.movie; + return bsv_movie_state.movie; 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: - return global->bsv.movie && !global->bsv.movie_playback; + return bsv_movie_state.movie && !bsv_movie_state.movie_playback; 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: - global->bsv.movie_start_recording = true; + bsv_movie_state.movie_start_recording = true; break; case BSV_MOVIE_CTL_UNSET_START_RECORDING: - global->bsv.movie_start_recording = false; + bsv_movie_state.movie_start_recording = false; break; 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: - global->bsv.movie_start_playback = true; + bsv_movie_state.movie_start_playback = true; break; case BSV_MOVIE_CTL_UNSET_START_PLAYBACK: - global->bsv.movie_start_playback = false; + bsv_movie_state.movie_start_playback = false; break; case BSV_MOVIE_CTL_END: - return global->bsv.movie_end; + return bsv_movie_state.movie_end; case BSV_MOVIE_CTL_SET_END_EOF: - global->bsv.eof_exit = true; + bsv_movie_state.eof_exit = true; break; 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: - global->bsv.movie_end = true; + bsv_movie_state.movie_end = true; break; case BSV_MOVIE_CTL_UNSET_END: - global->bsv.movie_end = false; + bsv_movie_state.movie_end = false; break; case BSV_MOVIE_CTL_UNSET_PLAYBACK: - global->bsv.movie_playback = false; + bsv_movie_state.movie_playback = false; break; case BSV_MOVIE_CTL_DEINIT: - if (global->bsv.movie) - bsv_movie_free(global->bsv.movie); - global->bsv.movie = NULL; + if (bsv_movie_state.movie) + bsv_movie_free(bsv_movie_state.movie); + bsv_movie_state.movie = NULL; break; case BSV_MOVIE_CTL_INIT: bsv_movie_init_state(); break; 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; 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; case BSV_MOVIE_CTL_FRAME_REWIND: - bsv_movie_frame_rewind(global->bsv.movie); + bsv_movie_frame_rewind(bsv_movie_state.movie); break; default: return false; @@ -378,36 +390,24 @@ bool bsv_movie_ctl(enum bsv_ctl_state state, void *data) const char *bsv_movie_get_path(void) { - global_t *global = global_get_ptr(); - if (!global) - return NULL; - return global->bsv.movie_path; + return bsv_movie_state.movie_path; } void bsv_movie_set_path(const char *path) { - global_t *global = global_get_ptr(); - if (!global) - return; - strlcpy(global->bsv.movie_path, path, sizeof(global->bsv.movie_path)); + strlcpy(bsv_movie_state.movie_path, path, sizeof(bsv_movie_state.movie_path)); } void bsv_movie_set_start_path(const char *path) { - global_t *global = global_get_ptr(); - if (!global) - return; - strlcpy(global->bsv.movie_start_path, path, - sizeof(global->bsv.movie_start_path)); + strlcpy(bsv_movie_state.movie_start_path, path, + sizeof(bsv_movie_state.movie_start_path)); } bool bsv_movie_init_handle(const char *path, enum rarch_movie_type type) { - global_t *global = global_get_ptr(); - if (!global) - return false; - global->bsv.movie = bsv_movie_init(path, type); - if (!global->bsv.movie) + bsv_movie_state.movie = bsv_movie_init(path, type); + if (!bsv_movie_state.movie) return false; return true; } diff --git a/netplay.c b/netplay.c index f156a56f44..ac87ef4df4 100644 --- a/netplay.c +++ b/netplay.c @@ -29,6 +29,7 @@ #include "general.h" #include "autosave.h" #include "dynamic.h" +#include "movie.h" #include "msg_hash.h" #include "system.h" #include "runloop.h" diff --git a/retroarch.c b/retroarch.c index 39fab9e0aa..4df9d22854 100644 --- a/retroarch.c +++ b/retroarch.c @@ -38,6 +38,7 @@ #include #include "msg_hash.h" +#include "movie.h" #include "verbosity.h" #include "audio/audio_driver.h" diff --git a/rewind.c b/rewind.c index f66c74f0db..e053b79be6 100644 --- a/rewind.c +++ b/rewind.c @@ -24,6 +24,7 @@ #include "general.h" #include "msg_hash.h" #include "rewind.h" +#include "movie.h" #include "performance.h" #include "verbosity.h" #include "audio/audio_driver.h" diff --git a/runloop.c b/runloop.c index a8f64cb110..b36ba76d52 100644 --- a/runloop.c +++ b/runloop.c @@ -35,6 +35,7 @@ #include "autosave.h" #include "configuration.h" #include "performance.h" +#include "movie.h" #include "retroarch.h" #include "runloop.h" #include "rewind.h" diff --git a/runloop.h b/runloop.h index bd149b13de..60c29c9075 100644 --- a/runloop.h +++ b/runloop.h @@ -24,7 +24,6 @@ #include "core_info.h" #include "core_options.h" #include "driver.h" -#include "movie.h" #include "cheats.h" #include "dynamic.h" #include "system.h" @@ -197,21 +196,6 @@ typedef struct global } menu; #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 { bool load_disable;