diff --git a/driver.c b/driver.c index acbac4b376..6cc5cab60a 100644 --- a/driver.c +++ b/driver.c @@ -307,14 +307,13 @@ void driver_set_nonblock_state(void) bool driver_update_system_av_info(const struct retro_system_av_info *info) { struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); - driver_t *driver = driver_get_ptr(); memcpy(av_info, info, sizeof(*av_info)); event_command(EVENT_CMD_REINIT); /* Cannot continue recording with different parameters. * Take the easiest route out and just restart the recording. */ - if (driver->recording_data) + if (recording_driver_get_data_ptr()) { rarch_main_msg_queue_push_new( MSG_RESTARTING_RECORDING_DUE_TO_DRIVER_REINIT, 2, 180, false); diff --git a/dynamic.c b/dynamic.c index bc8b9d9dc5..a66e93ff13 100644 --- a/dynamic.c +++ b/dynamic.c @@ -662,10 +662,9 @@ static bool rarch_game_specific_options(char **output) bool rarch_environment_cb(unsigned cmd, void *data) { unsigned p; - driver_t *driver = driver_get_ptr(); - settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + rarch_system_info_t *system = rarch_system_info_get_ptr(); if (ignore_environment_cb) return false; @@ -1049,7 +1048,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) (const struct retro_audio_callback*)data; RARCH_LOG("Environ SET_AUDIO_CALLBACK.\n"); - if (driver->recording_data) /* A/V sync is a must. */ + if (recording_driver_get_data_ptr()) /* A/V sync is a must. */ return false; #ifdef HAVE_NETPLAY diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 8aaba963d6..dae4a19a69 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -1136,13 +1136,13 @@ void video_driver_set_pixel_format(enum retro_pixel_format fmt) static bool video_driver_cached_frame(void) { driver_t *driver = driver_get_ptr(); - void *recording = driver ? driver->recording_data : NULL; + void *recording = recording_driver_get_data_ptr(); if (runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL)) return true; /* Maybe return false here for indication of idleness? */ /* Cannot allow recording when pushing duped frames. */ - driver->recording_data = NULL; + recording_driver_clear_data_ptr(); /* Not 100% safe, since the library might have * freed the memory, but no known implementations do this. @@ -1156,7 +1156,7 @@ static bool video_driver_cached_frame(void) video_driver_state.frame_cache.height, video_driver_state.frame_cache.pitch); - driver->recording_data = recording; + recording_driver_set_data_ptr(recording); return true; } diff --git a/record/record_driver.c b/record/record_driver.c index 4911c322ee..0f2372443e 100644 --- a/record/record_driver.c +++ b/record/record_driver.c @@ -416,3 +416,27 @@ bool recording_init(void) return true; } + +void *recording_driver_get_data_ptr(void) +{ + driver_t *driver = driver_get_ptr(); + if (!driver) + return NULL; + return driver->recording_data; +} + +void recording_driver_clear_data_ptr(void) +{ + driver_t *driver = driver_get_ptr(); + if (!driver) + return; + driver->recording_data = NULL; +} + +void recording_driver_set_data_ptr(void *data) +{ + driver_t *driver = driver_get_ptr(); + if (!driver) + return; + driver->recording_data = data; +} diff --git a/record/record_driver.h b/record/record_driver.h index 504df02f9a..4bdd86a08a 100644 --- a/record/record_driver.h +++ b/record/record_driver.h @@ -166,6 +166,12 @@ void recording_set_state(bool state); void recording_push_audio(const int16_t *data, size_t samples); +void *recording_driver_get_data_ptr(void); + +void recording_driver_clear_data_ptr(void); + +void recording_driver_set_data_ptr(void *data); + #ifdef __cplusplus } #endif diff --git a/runloop.c b/runloop.c index 265827ec23..6e58ce1ccb 100644 --- a/runloop.c +++ b/runloop.c @@ -1079,7 +1079,7 @@ int rarch_main_iterate(unsigned *sleep_ms) retro_time_t delta = current - frame_time_last; bool is_locked_fps = (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) || input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL)) | - !!driver->recording_data; + !!recording_driver_get_data_ptr(); runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, &is_slowmotion);