Skip to content

Commit 5f35b8b

Browse files
committed
Use osdep/io.h, and make Meson partial dependency
1 parent 84f5c6f commit 5f35b8b

2 files changed

Lines changed: 36 additions & 35 deletions

File tree

meson.build

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,11 +772,13 @@ if features['uchardet']
772772
endif
773773

774774
vapoursynth = dependency('vapoursynth', version: '>= 56', required: get_option('vapoursynth'))
775-
vapoursynth_script = dependency('vapoursynth-script', version: '>= 56',
776-
required: get_option('vapoursynth'))
775+
vapoursynth_script = dependency('vapoursynth-script', version: '>= 56', required: get_option('vapoursynth'))
777776
features += {'vapoursynth': vapoursynth.found() and vapoursynth_script.found()}
778777
if features['vapoursynth']
779-
dependencies += [vapoursynth, vapoursynth_script]
778+
vapoursynth_headers = vapoursynth.partial_dependency(compile_args: true, includes: true)
779+
vapoursynth_script_headers = vapoursynth_script.partial_dependency(compile_args: true, includes: true)
780+
781+
dependencies += [vapoursynth_headers, vapoursynth_script_headers]
780782
sources += files('video/filter/vf_vapoursynth.c')
781783
endif
782784

video/filter/vf_vapoursynth.c

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#include "video/sws_utils.h"
4343

4444
#ifdef _WIN32
45-
#include <Windows.h>
45+
#include "osdep/io.h"
4646
#else
4747
#include <dlfcn.h>
4848
#endif
@@ -809,57 +809,56 @@ static const m_option_t vf_opts_fields[] = {
809809

810810
static int drv_vss_init(struct priv *p)
811811
{
812-
typedef VS_CC const VSSCRIPTAPI *(*getVSScriptAPI_fn)(int);
813-
typedef VS_CC const char *(*getVSScriptAPILastError_fn)(void);
814-
815-
getVSScriptAPI_fn getVSScriptAPI_func = NULL;
816-
getVSScriptAPILastError_fn getVSScriptAPILastError_func = NULL;
812+
const char *vsscript_path = getenv("VSSCRIPT_PATH");
813+
const int dl_mode = RTLD_NOW | RTLD_LOCAL;
814+
void *vsscript_lib = NULL;
817815

818816
#ifdef _WIN32
819-
const wchar_t *vsscript_path = _wgetenv(L"VSSCRIPT_PATH");
820-
const HMODULE lib = LoadLibraryExW(vsscript_path ? vsscript_path : L"VSScript.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
821-
if (lib) {
822-
getVSScriptAPI_func = (getVSScriptAPI_fn) GetProcAddress(lib, "getVSScriptAPI");
823-
getVSScriptAPILastError_func = (getVSScriptAPILastError_fn) GetProcAddress(lib, "getVSScriptAPILastError");
824-
}
825-
#else
826-
817+
vsscript_lib = dlopen(vsscript_path ? vsscript_path : "VSScript.dll", dl_mode);
818+
#else // _WIN32
819+
if (vsscript_path) {
820+
vsscript_lib = dlopen(vsscript_path, dl_mode);
821+
} else {
827822
#ifdef __APPLE__
828823
const char *lib_name_r74 = "libvsscript.4.dylib";
829824
const char *lib_name_old = "libvapoursynth-script.4.dylib";
830-
#else
825+
#else // __APPLE__
831826
const char *lib_name_r74 = "libvsscript.so.4";
832827
const char *lib_name_old = "libvapoursynth-script.so.4";
833-
#endif
828+
#endif // __APPLE__
834829

835-
const char *vsscript_path = getenv("VSSCRIPT_PATH");
836-
const int dl_mode = RTLD_LAZY | RTLD_GLOBAL;
837-
void *lib;
838-
839-
if (vsscript_path) {
840-
lib = dlopen(vsscript_path, dl_mode);
841-
} else {
842-
lib = dlopen(lib_name_r74, dl_mode);
843-
if (!lib) {
844-
lib = dlopen(lib_name_old, dl_mode);
830+
vsscript_lib = dlopen(lib_name_r74, dl_mode);
831+
if (!vsscript_lib) {
832+
vsscript_lib = dlopen(lib_name_old, dl_mode);
845833
}
846834
}
835+
#endif // _WIN32
836+
837+
typedef VS_CC const VSSCRIPTAPI *(*getVSScriptAPI_fn)(int);
838+
typedef VS_CC const char *(*getVSScriptAPILastError_fn)(void);
839+
840+
getVSScriptAPI_fn getVSScriptAPI_func = NULL;
841+
getVSScriptAPILastError_fn getVSScriptAPILastError_func = NULL;
847842

848-
if (lib) {
849-
getVSScriptAPI_func = (getVSScriptAPI_fn) dlsym(lib, "getVSScriptAPI");
850-
getVSScriptAPILastError_func = (getVSScriptAPILastError_fn) dlsym(lib, "getVSScriptAPILastError");
843+
if (vsscript_lib) {
844+
getVSScriptAPI_func = (getVSScriptAPI_fn) dlsym(vsscript_lib, "getVSScriptAPI");
845+
getVSScriptAPILastError_func = (getVSScriptAPILastError_fn) dlsym(vsscript_lib, "getVSScriptAPILastError");
851846
}
852-
#endif
847+
848+
const char *unknown_error_msg = "Last error unknown";
853849

854850
if (getVSScriptAPI_func) {
855851
p->vs_script_api = getVSScriptAPI_func(VSSCRIPT_API_VERSION);
856852
if (!p->vs_script_api) {
857-
const char *last_error_msg = getVSScriptAPILastError_func ? getVSScriptAPILastError_func() : "Last error unknown";
853+
const char *vs_error_msg = getVSScriptAPILastError_func ? getVSScriptAPILastError_func() : NULL;
854+
const char *last_error_msg = vs_error_msg ? vs_error_msg : unknown_error_msg;
858855
MP_FATAL(p, "Failed to initialize VapourSynth VSScript library: %s\n", last_error_msg);
859856
return -1;
860857
}
861858
} else {
862-
MP_FATAL(p, "Failed to load VapourSynth VSScript library\n");
859+
const char *dl_error_msg = dlerror();
860+
const char *last_error_msg = dl_error_msg ? dl_error_msg : unknown_error_msg;
861+
MP_FATAL(p, "Failed to load VapourSynth VSScript library: %s\n", last_error_msg);
863862
return -1;
864863
}
865864

0 commit comments

Comments
 (0)