From 79b3f4ccb053551afbea59d3d8999a6fef158202 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Wed, 18 Oct 2023 13:31:47 +0200 Subject: [PATCH] vapoursynth: Add option to enable/disable user plugin loading On Windows, plugins are shipped with Aegisub now and loaded from aegisub_vs.py, so user plugins installed out of Aegisub are more likely to just interfere with that (like when the user has an old version of libvslsmashsource installed). So this option defaults to off on Windows, but to on everywhere else since VS plugins aren't shipped with Aegisub there. Note that this option only disables autoloading of user plugins. VapourSynth loads system plugins no matter what. --- src/audio_provider_vs.cpp | 6 +++++- src/libresrc/default_config.json | 1 + src/libresrc/default_config_win.json | 6 ++++-- src/libresrc/meson.build | 12 +++++++++--- src/libresrc/osx/default_config.json | 1 + src/preferences.cpp | 4 +++- src/video_provider_vs.cpp | 2 +- 7 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/audio_provider_vs.cpp b/src/audio_provider_vs.cpp index 2d81f06bb..db9d6a871 100644 --- a/src/audio_provider_vs.cpp +++ b/src/audio_provider_vs.cpp @@ -58,7 +58,11 @@ VapourSynthAudioProvider::VapourSynthAudioProvider(agi::fs::path const& filename VSCleanCache(); - script = vs.GetScriptAPI()->createScript(nullptr); + VSCore *core = vs.GetAPI()->createCore(OPT_GET("Provider/VapourSynth/Autoload User Plugins")->GetBool() ? 0 : VSCoreCreationFlags::ccfDisableAutoLoading); + if (core == nullptr) { + throw VapourSynthError("Error creating core"); + } + script = vs.GetScriptAPI()->createScript(core); if (script == nullptr) { throw VapourSynthError("Error creating script API"); } diff --git a/src/libresrc/default_config.json b/src/libresrc/default_config.json index a93416e41..f2451d7ea 100644 --- a/src/libresrc/default_config.json +++ b/src/libresrc/default_config.json @@ -354,6 +354,7 @@ "Log Level" : "quiet" }, "VapourSynth" : { + "Autoload User Plugins": true, "Cache" : { "Files" : 500, "Size" : 1000 diff --git a/src/libresrc/default_config_win.json b/src/libresrc/default_config_win.json index 44b291343..5e3b68269 100644 --- a/src/libresrc/default_config_win.json +++ b/src/libresrc/default_config_win.json @@ -2,7 +2,9 @@ "Audio" : { "Player" : "DirectSound" }, - "Subtitle" : { - "Provider" : "CSRI/xy-vsfilter_aegisub" + "Provider" : { + "VapourSynth" : { + "Autoload User Plugins": false + } } } diff --git a/src/libresrc/meson.build b/src/libresrc/meson.build index 0b9414736..8d727b4c0 100644 --- a/src/libresrc/meson.build +++ b/src/libresrc/meson.build @@ -9,9 +9,15 @@ resrc = [ output: ['bitmap.cpp', 'bitmap.h']) ] -conf_platform_json = configure_file(input: 'default_config_platform.json.in', - output: '@BASENAME@', - configuration: conf_platform) +if host_machine.system() == 'windows' + conf_platform_json = configure_file(input: 'default_config_win.json', + output: 'default_config_platform.json', + copy: true) +else + conf_platform_json = configure_file(input: 'default_config_platform.json.in', + output: '@BASENAME@', + configuration: conf_platform) +endif if host_machine.system() == 'darwin' resmanifest = 'manifest_osx.respack' diff --git a/src/libresrc/osx/default_config.json b/src/libresrc/osx/default_config.json index 80b54b52e..8a43c5423 100644 --- a/src/libresrc/osx/default_config.json +++ b/src/libresrc/osx/default_config.json @@ -354,6 +354,7 @@ "Log Level" : "quiet" }, "VapourSynth" : { + "Autoload User Plugins": true, "Cache" : { "Files" : 500, "Size" : 1000 diff --git a/src/preferences.cpp b/src/preferences.cpp index ff468f000..ac3aad97c 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -476,7 +476,9 @@ void VapourSynth(wxTreebook *book, Preferences *parent) { const wxString log_levels[] = { "Quiet", "Fatal", "Critical", "Warning", "Information", "Debug" }; wxArrayString log_levels_choice(6, log_levels); - p->OptionChoice(general, _("Log Level"), log_levels_choice, "Provider/Video/VapourSynth/Log Level"); + p->OptionChoice(general, _("Log level"), log_levels_choice, "Provider/Video/VapourSynth/Log Level"); + p->CellSkip(general); + p->OptionAdd(general, _("Load user plugins"), "Provider/VapourSynth/Autoload User Plugins"); auto video = p->PageSizer(_("Default Video Script")); diff --git a/src/video_provider_vs.cpp b/src/video_provider_vs.cpp index da4a3d1a5..a59c583e1 100644 --- a/src/video_provider_vs.cpp +++ b/src/video_provider_vs.cpp @@ -123,7 +123,7 @@ VapourSynthVideoProvider::VapourSynthVideoProvider(agi::fs::path const& filename VSCleanCache(); int err1, err2; - VSCore *core = vs.GetAPI()->createCore(0); + VSCore *core = vs.GetAPI()->createCore(OPT_GET("Provider/VapourSynth/Autoload User Plugins")->GetBool() ? 0 : VSCoreCreationFlags::ccfDisableAutoLoading); if (core == nullptr) { throw VapourSynthError("Error creating core"); }