From 5b8868544896972faf3ac3325b2aea634cf55967 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 13 Jan 2019 07:46:35 +0100 Subject: [PATCH] Unroll this --- movie.c | 45 +-------------------------------------------- movie.h | 27 +++++++++++++++++++++++---- retroarch.c | 16 ++++++++++++++-- 3 files changed, 38 insertions(+), 50 deletions(-) diff --git a/movie.c b/movie.c index acc0e7554c..a2bc383f60 100644 --- a/movie.c +++ b/movie.c @@ -21,7 +21,6 @@ #include #include #include -#include #include "configuration.h" #include "movie.h" @@ -34,26 +33,6 @@ #include "command.h" #include "file_path_special.h" -struct bsv_movie -{ - intfstream_t *file; - - /* A ring buffer keeping track of positions - * in the file for each frame. */ - size_t *frame_pos; - size_t frame_mask; - size_t frame_ptr; - - size_t min_file_pos; - - size_t state_size; - uint8_t *state; - - bool playback; - bool first_rewind; - bool did_rewind; -}; - struct bsv_state { bool movie_start_recording; @@ -68,7 +47,7 @@ struct bsv_state char movie_start_path[PATH_MAX_LENGTH]; }; -static bsv_movie_t *bsv_movie_state_handle = NULL; +bsv_movie_t *bsv_movie_state_handle = NULL; static struct bsv_state bsv_movie_state; static bool bsv_movie_init_playback(bsv_movie_t *handle, const char *path) @@ -259,28 +238,6 @@ error: return NULL; } -/* Used for rewinding while playback/record. */ -void bsv_movie_set_frame_start(void) -{ - if (bsv_movie_state_handle) - bsv_movie_state_handle->frame_pos[bsv_movie_state_handle->frame_ptr] - = intfstream_tell(bsv_movie_state_handle->file); -} - -void bsv_movie_set_frame_end(void) -{ - if (!bsv_movie_state_handle) - return; - - bsv_movie_state_handle->frame_ptr = - (bsv_movie_state_handle->frame_ptr + 1) - & bsv_movie_state_handle->frame_mask; - - bsv_movie_state_handle->first_rewind = - !bsv_movie_state_handle->did_rewind; - bsv_movie_state_handle->did_rewind = false; -} - static void bsv_movie_frame_rewind(bsv_movie_t *handle) { handle->did_rewind = true; diff --git a/movie.h b/movie.h index 14372d84fe..901cd28994 100644 --- a/movie.h +++ b/movie.h @@ -22,6 +22,7 @@ #include #include +#include RETRO_BEGIN_DECLS @@ -56,6 +57,26 @@ enum bsv_ctl_state BSV_MOVIE_CTL_UNSET_END }; +struct bsv_movie +{ + intfstream_t *file; + + /* A ring buffer keeping track of positions + * in the file for each frame. */ + size_t *frame_pos; + size_t frame_mask; + size_t frame_ptr; + + size_t min_file_pos; + + size_t state_size; + uint8_t *state; + + bool playback; + bool first_rewind; + bool did_rewind; +}; + void bsv_movie_deinit(void); bool bsv_movie_init(void); @@ -68,10 +89,6 @@ void bsv_movie_set_path(const char *path); void bsv_movie_set_start_path(const char *path); -void bsv_movie_set_frame_start(void); - -void bsv_movie_set_frame_end(void); - bool bsv_movie_get_input(int16_t *bsv_data); bool bsv_movie_is_end_of_file(void); @@ -82,6 +99,8 @@ bool bsv_movie_check(void); bool bsv_movie_init_handle(const char *path, enum rarch_movie_type type); +extern bsv_movie_t *bsv_movie_state_handle; + RETRO_END_DECLS #endif diff --git a/retroarch.c b/retroarch.c index af73250cd2..feef5b45a3 100644 --- a/retroarch.c +++ b/retroarch.c @@ -3594,7 +3594,10 @@ int runloop_iterate(unsigned *sleep_ms) if (runloop_autosave) autosave_lock(); - bsv_movie_set_frame_start(); + /* Used for rewinding while playback/record. */ + if (bsv_movie_state_handle) + bsv_movie_state_handle->frame_pos[bsv_movie_state_handle->frame_ptr] + = intfstream_tell(bsv_movie_state_handle->file); camera_driver_poll(); @@ -3661,7 +3664,16 @@ int runloop_iterate(unsigned *sleep_ms) input_pop_analog_dpad(auto_binds); } - bsv_movie_set_frame_end(); + if (bsv_movie_state_handle) + { + bsv_movie_state_handle->frame_ptr = + (bsv_movie_state_handle->frame_ptr + 1) + & bsv_movie_state_handle->frame_mask; + + bsv_movie_state_handle->first_rewind = + !bsv_movie_state_handle->did_rewind; + bsv_movie_state_handle->did_rewind = false; + } if (runloop_autosave) autosave_unlock();