diff --git a/plugins/obs-filters/noise-suppress-filter.c b/plugins/obs-filters/noise-suppress-filter.c index d019a2272..2b042bf2b 100644 --- a/plugins/obs-filters/noise-suppress-filter.c +++ b/plugins/obs-filters/noise-suppress-filter.c @@ -634,7 +634,7 @@ bool load_nvafx(void) blog(LOG_INFO, "[noise suppress]: NVIDIA AUDIO FX version: %i.%i.%i.%i", major, minor, build, revision); - if (version < (MIN_AFX_SDK_VERSION)) { + if (version < MIN_AFX_SDK_VERSION) { blog(LOG_INFO, "[noise suppress]: NVIDIA AUDIO Effects SDK is outdated. Please update both audio & video SDK."); } @@ -1227,7 +1227,7 @@ static obs_properties_t *noise_suppress_properties(void *data) 1.0f, 0.01f); } unsigned int version = get_lib_version(); - if (version < (MIN_AFX_SDK_VERSION)) { + if (version && version < MIN_AFX_SDK_VERSION) { obs_property_t *warning = obs_properties_add_text( ppts, "deprecation", NULL, OBS_TEXT_INFO); obs_property_text_set_info_type(warning, OBS_TEXT_INFO_WARNING); diff --git a/plugins/obs-filters/nvafx-load.h b/plugins/obs-filters/nvafx-load.h index 7fc94c007..0b02c426e 100644 --- a/plugins/obs-filters/nvafx-load.h +++ b/plugins/obs-filters/nvafx-load.h @@ -9,7 +9,7 @@ #define NVAFX_API #ifdef LIBNVAFX_ENABLED -#define MIN_AFX_SDK_VERSION 1 << 24 | 2 << 16 | 13 << 0 +#define MIN_AFX_SDK_VERSION (1 << 24 | 2 << 16 | 13 << 0) static HMODULE nv_audiofx = NULL; static HMODULE nv_cuda = NULL; @@ -312,15 +312,26 @@ static bool load_lib(void) static unsigned int get_lib_version(void) { + static unsigned int version = 0; + static bool version_checked = false; + + if (version_checked) + return version; + + version_checked = true; + char path[MAX_PATH]; if (!nvafx_get_sdk_path(path, sizeof(path))) return 0; SetDllDirectoryA(path); + struct win_version_info nto_ver = {0}; - get_dll_ver(L"NVAudioEffects.dll", &nto_ver); - unsigned int version = nto_ver.major << 24 | nto_ver.minor << 16 | - nto_ver.build << 8 | nto_ver.revis << 0; + if (get_dll_ver(L"NVAudioEffects.dll", &nto_ver)) + version = nto_ver.major << 24 | nto_ver.minor << 16 | + nto_ver.build << 8 | nto_ver.revis << 0; + + SetDllDirectoryA(NULL); return version; } #endif diff --git a/plugins/obs-filters/nvidia-greenscreen-filter.c b/plugins/obs-filters/nvidia-greenscreen-filter.c index 41b5b9993..7ea783d37 100644 --- a/plugins/obs-filters/nvidia-greenscreen-filter.c +++ b/plugins/obs-filters/nvidia-greenscreen-filter.c @@ -479,7 +479,7 @@ static void *nv_greenscreen_filter_create(obs_data_t *settings, uint8_t build = (filter->version >> 8) & 0x0000ff; uint8_t revision = (filter->version >> 0) & 0x000000ff; // sanity check - nvvfx_new_sdk = filter->version >= (MIN_VFX_SDK_VERSION) && + nvvfx_new_sdk = filter->version >= MIN_VFX_SDK_VERSION && nvvfx_new_sdk; } @@ -551,7 +551,7 @@ static obs_properties_t *nv_greenscreen_filter_properties(void *data) props, S_PROCESSING, TEXT_PROCESSING, 1, 4, 1); obs_property_set_long_description(partial, TEXT_PROCESSING_HINT); unsigned int version = get_lib_version(); - if (version < (MIN_VFX_SDK_VERSION)) { + if (version && version < MIN_VFX_SDK_VERSION) { obs_property_t *warning = obs_properties_add_text( props, "deprecation", NULL, OBS_TEXT_INFO); obs_property_text_set_info_type(warning, OBS_TEXT_INFO_WARNING); @@ -895,7 +895,7 @@ bool load_nvvfx(void) blog(LOG_INFO, "[NVIDIA VIDEO FX]: NVIDIA VIDEO FX version: %i.%i.%i.%i", major, minor, build, revision); - if (version < (MIN_VFX_SDK_VERSION)) { + if (version < MIN_VFX_SDK_VERSION) { blog(LOG_INFO, "[NVIDIA VIDEO FX]: NVIDIA VIDEO Effects SDK is outdated. Please update both audio & video SDK."); } diff --git a/plugins/obs-filters/nvvfx-load.h b/plugins/obs-filters/nvvfx-load.h index 4feb5afc6..cd1df985b 100644 --- a/plugins/obs-filters/nvvfx-load.h +++ b/plugins/obs-filters/nvvfx-load.h @@ -39,7 +39,7 @@ extern "C" { #define CUDARTAPI #ifdef LIBNVVFX_ENABLED -#define MIN_VFX_SDK_VERSION 0 << 24 | 7 << 16 | 1 << 8 | 0 << 0 +#define MIN_VFX_SDK_VERSION (0 << 24 | 7 << 16 | 1 << 8 | 0 << 0) static HMODULE nv_videofx = NULL; static HMODULE nv_cvimage = NULL; static HMODULE nv_cudart = NULL; @@ -817,14 +817,25 @@ static inline bool load_nv_vfx_libs() static unsigned int get_lib_version(void) { + static unsigned int version = 0; + static bool version_checked = false; + + if (version_checked) + return version; + + version_checked = true; + char path[MAX_PATH]; nvvfx_get_sdk_path(path, sizeof(path)); SetDllDirectoryA(path); + struct win_version_info nto_ver = {0}; - get_dll_ver(L"NVVideoEffects.dll", &nto_ver); - unsigned int version = nto_ver.major << 24 | nto_ver.minor << 16 | - nto_ver.build << 8 | nto_ver.revis << 0; + if (get_dll_ver(L"NVVideoEffects.dll", &nto_ver)) + version = nto_ver.major << 24 | nto_ver.minor << 16 | + nto_ver.build << 8 | nto_ver.revis << 0; + + SetDllDirectoryA(NULL); return version; } #endif