win-capture: Cache data to reduce load time
Caches the D3D graphics offsets to file for the sake of improving module load time. If the D3D/DXGI DLL versions change, the data will be refreshed.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <windows.h>
|
||||
#include <obs-module.h>
|
||||
#include <util/windows/win-version.h>
|
||||
#include <util/platform.h>
|
||||
|
||||
OBS_DECLARE_MODULE()
|
||||
OBS_MODULE_USE_DEFAULT_LOCALE("win-capture", "en-US")
|
||||
@@ -10,6 +11,8 @@ extern struct obs_source_info monitor_capture_info;
|
||||
extern struct obs_source_info window_capture_info;
|
||||
extern struct obs_source_info game_capture_info;
|
||||
|
||||
extern bool cached_versions_match(void);
|
||||
extern bool load_cached_graphics_offsets(bool is32bit);
|
||||
extern bool load_graphics_offsets(bool is32bit);
|
||||
|
||||
/* temporary, will eventually be erased once we figure out how to create both
|
||||
@@ -24,6 +27,13 @@ bool obs_module_load(void)
|
||||
{
|
||||
struct win_version_info ver;
|
||||
bool win8_or_above = false;
|
||||
char *config_dir;
|
||||
|
||||
config_dir = obs_module_config_path(NULL);
|
||||
if (config_dir) {
|
||||
os_mkdirs(config_dir);
|
||||
bfree(config_dir);
|
||||
}
|
||||
|
||||
get_win_ver(&ver);
|
||||
|
||||
@@ -40,7 +50,11 @@ bool obs_module_load(void)
|
||||
|
||||
obs_register_source(&window_capture_info);
|
||||
|
||||
if (load_graphics_offsets(IS32BIT)) {
|
||||
if (cached_versions_match() && load_cached_graphics_offsets(IS32BIT)) {
|
||||
load_cached_graphics_offsets(!IS32BIT);
|
||||
obs_register_source(&game_capture_info);
|
||||
|
||||
} else if (load_graphics_offsets(IS32BIT)) {
|
||||
load_graphics_offsets(!IS32BIT);
|
||||
obs_register_source(&game_capture_info);
|
||||
}
|
||||
|
Reference in New Issue
Block a user