From eea1b3790bb5f9acd083eaddf12156c35bbaf273 Mon Sep 17 00:00:00 2001 From: twinaphex <libretro@gmail.com> Date: Sun, 4 Dec 2016 06:31:29 +0100 Subject: [PATCH] Try to prevent superfluous calls to recording functions if not necessary --- audio/audio_driver.c | 5 +++-- gfx/video_driver.c | 10 +++++----- record/record_driver.c | 8 +------- record/record_driver.h | 2 ++ 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index dd5b79b4b5..6d5023d57f 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -488,9 +488,9 @@ void audio_driver_set_nonblocking_state(bool enable) **/ static bool audio_driver_flush(const int16_t *data, size_t samples) { + struct resampler_data src_data; static struct retro_perf_counter resampler_proc = {0}; static struct retro_perf_counter audio_convert_s16 = {0}; - struct resampler_data src_data; const void *output_data = NULL; unsigned output_frames = 0; size_t output_size = sizeof(float); @@ -502,7 +502,8 @@ static bool audio_driver_flush(const int16_t *data, size_t samples) src_data.output_frames = 0; src_data.ratio = 0.0f; - recording_push_audio(data, samples); + if (recording_data) + recording_push_audio(data, samples); if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) || settings->audio.mute_enable) return true; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 5849c3eda5..de61008db3 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -1114,7 +1114,7 @@ static bool video_driver_frame_filter(const void *data, data, width, height, pitch); performance_counter_stop(&softfilter_process); - if (settings->video.post_filter_record) + if (settings->video.post_filter_record && recording_data) recording_dump_frame(video_driver_state_buffer, *output_width, *output_height, *output_pitch); @@ -1147,7 +1147,7 @@ bool video_driver_cached_frame(void) void *recording = recording_driver_get_data_ptr(); /* Cannot allow recording when pushing duped frames. */ - recording_driver_clear_data_ptr(); + recording_data = NULL; /* Not 100% safe, since the library might have * freed the memory, but no known implementations do this. @@ -1161,7 +1161,7 @@ bool video_driver_cached_frame(void) core_frame(&info); - recording_driver_set_data_ptr(recording); + recording_data = recording; return true; } @@ -2090,8 +2090,8 @@ void video_driver_frame(const void *data, unsigned width, !video_driver_state_filter || !settings->video.post_filter_record || !data - || video_driver_has_gpu_record() - ) + || video_driver_record_gpu_buffer + ) && recording_data ) recording_dump_frame(data, width, height, pitch); diff --git a/record/record_driver.c b/record/record_driver.c index ec3e25deeb..8dbfffb8fa 100644 --- a/record/record_driver.c +++ b/record/record_driver.c @@ -52,7 +52,7 @@ static bool recording_enable = false; static bool recording_use_output_dir = false; static const record_driver_t *recording_driver = NULL; -static void *recording_data = NULL; +void *recording_data = NULL; /** * record_driver_find_ident: @@ -187,9 +187,6 @@ void recording_dump_frame(const void *data, unsigned width, { struct ffemu_video_data ffemu_data = {0}; - if (!recording_data) - return; - ffemu_data.pitch = pitch; ffemu_data.width = width; ffemu_data.height = height; @@ -283,9 +280,6 @@ void recording_push_audio(const int16_t *data, size_t samples) { struct ffemu_audio_data ffemu_data; - if (!recording_data) - return; - ffemu_data.data = data; ffemu_data.frames = samples / 2; diff --git a/record/record_driver.h b/record/record_driver.h index 63d0d073ca..d70c4b5181 100644 --- a/record/record_driver.h +++ b/record/record_driver.h @@ -180,6 +180,8 @@ unsigned *recording_driver_get_height(void); void recording_driver_free_state(void); +extern void *recording_data; + RETRO_END_DECLS #endif