diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 6d5023d57f..f5918be411 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -502,7 +502,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples) src_data.output_frames = 0; src_data.ratio = 0.0f; - if (recording_data) + if (drivers_data[DRIVER_RECORDING]) recording_push_audio(data, samples); if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) || settings->audio.mute_enable) diff --git a/driver.c b/driver.c index 6c754fe7f8..288064c4b0 100644 --- a/driver.c +++ b/driver.c @@ -52,6 +52,8 @@ #define HASH_RECORD_DRIVER 0x144cd2cfU #define HASH_WIFI_DRIVER 0x64d7d17fU +void *drivers_data[DRIVER_LAST+1]; + /** * find_driver_nonempty: * @label : string of driver type to be found. diff --git a/driver.h b/driver.h index 475564058b..1d2a7bdb6c 100644 --- a/driver.h +++ b/driver.h @@ -45,7 +45,9 @@ enum DRIVER_LOCATION, DRIVER_MENU, DRIVERS_VIDEO_INPUT, - DRIVER_WIFI + DRIVER_WIFI, + DRIVER_RECORDING, + DRIVER_LAST, }; enum @@ -57,7 +59,8 @@ enum DRIVER_LOCATION_MASK = 1 << DRIVER_LOCATION, DRIVER_MENU_MASK = 1 << DRIVER_MENU, DRIVERS_VIDEO_INPUT_MASK = 1 << DRIVERS_VIDEO_INPUT, - DRIVER_WIFI_MASK = 1 << DRIVER_WIFI + DRIVER_WIFI_MASK = 1 << DRIVER_WIFI, + DRIVER_RECORDING_MASK = 1 << DRIVER_RECORDING }; enum driver_ctl_state @@ -122,6 +125,8 @@ typedef struct driver_ctx_info bool driver_ctl(enum driver_ctl_state state, void *data); +extern void *drivers_data[DRIVER_LAST+1]; + RETRO_END_DECLS #endif diff --git a/gfx/video_driver.c b/gfx/video_driver.c index de61008db3..e62f9278ca 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 && recording_data) + if (settings->video.post_filter_record && drivers_data[DRIVER_RECORDING]) 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_data = NULL; + drivers_data[DRIVER_RECORDING] = 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_data = recording; + drivers_data[DRIVER_RECORDING] = recording; return true; } @@ -2091,7 +2091,7 @@ void video_driver_frame(const void *data, unsigned width, || !settings->video.post_filter_record || !data || video_driver_record_gpu_buffer - ) && recording_data + ) && drivers_data[DRIVER_RECORDING] ) recording_dump_frame(data, width, height, pitch); diff --git a/record/record_driver.c b/record/record_driver.c index 8dbfffb8fa..c4d7cb1aa4 100644 --- a/record/record_driver.c +++ b/record/record_driver.c @@ -52,7 +52,6 @@ static bool recording_enable = false; static bool recording_use_output_dir = false; static const record_driver_t *recording_driver = NULL; -void *recording_data = NULL; /** * record_driver_find_ident: @@ -244,22 +243,22 @@ void recording_dump_frame(const void *data, unsigned width, ffemu_data.is_dupe = !data; if (recording_driver && recording_driver->push_video) - recording_driver->push_video(recording_data, &ffemu_data); + recording_driver->push_video(drivers_data[DRIVER_RECORDING], &ffemu_data); } bool recording_deinit(void) { - if (!recording_data || !recording_driver) + if (!drivers_data[DRIVER_RECORDING] || !recording_driver) return false; if (recording_driver->finalize) - recording_driver->finalize(recording_data); + recording_driver->finalize(drivers_data[DRIVER_RECORDING]); if (recording_driver->free) - recording_driver->free(recording_data); + recording_driver->free(drivers_data[DRIVER_RECORDING]); - recording_data = NULL; - recording_driver = NULL; + drivers_data[DRIVER_RECORDING] = NULL; + recording_driver = NULL; command_event(CMD_EVENT_GPU_RECORD_DEINIT, NULL); @@ -284,7 +283,7 @@ void recording_push_audio(const int16_t *data, size_t samples) ffemu_data.frames = samples / 2; if (recording_driver && recording_driver->push_audio) - recording_driver->push_audio(recording_data, &ffemu_data); + recording_driver->push_audio(drivers_data[DRIVER_RECORDING], &ffemu_data); } /** @@ -426,7 +425,7 @@ bool recording_init(void) params.fb_width, params.fb_height, (unsigned)params.pix_fmt); - if (!record_driver_init_first(&recording_driver, &recording_data, ¶ms)) + if (!record_driver_init_first(&recording_driver, &drivers_data[DRIVER_RECORDING], ¶ms)) { RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_START_RECORDING)); command_event(CMD_EVENT_GPU_RECORD_DEINIT, NULL); @@ -439,17 +438,17 @@ bool recording_init(void) void *recording_driver_get_data_ptr(void) { - return recording_data; + return drivers_data[DRIVER_RECORDING]; } void recording_driver_clear_data_ptr(void) { - recording_data = NULL; + drivers_data[DRIVER_RECORDING] = NULL; } void recording_driver_set_data_ptr(void *data) { - recording_data = data; + drivers_data[DRIVER_RECORDING] = data; } bool *recording_driver_get_use_output_dir_ptr(void)