From fe77a1a0b8c29a9fa2d0c45f6779b4a6459872f3 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Tue, 27 Sep 2022 22:59:01 +0200 Subject: [PATCH] avisynth: Check if file exists before creating provider Since FileNotFound exceptions don't abort the provider search, opening an invalid path would show errors such as "avisynth not found" when Avisynth wasn't installed, even if Avisynth wasn't selected as the video provider. --- src/audio_provider_avs.cpp | 3 +-- src/video_provider_avs.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/audio_provider_avs.cpp b/src/audio_provider_avs.cpp index 0daa77e8e..fff0ed823 100644 --- a/src/audio_provider_avs.cpp +++ b/src/audio_provider_avs.cpp @@ -64,8 +64,6 @@ public: }; AvisynthAudioProvider::AvisynthAudioProvider(agi::fs::path const& filename) try { - agi::acs::CheckFileRead(filename); - std::lock_guard lock(avs_wrapper.GetMutex()); try { @@ -150,6 +148,7 @@ void AvisynthAudioProvider::FillBuffer(void *buf, int64_t start, int64_t count) } std::unique_ptr CreateAvisynthAudioProvider(agi::fs::path const& file, agi::BackgroundRunner *) { + agi::acs::CheckFileRead(file); return agi::make_unique(file); } #endif diff --git a/src/video_provider_avs.cpp b/src/video_provider_avs.cpp index 7c779e800..263310675 100644 --- a/src/video_provider_avs.cpp +++ b/src/video_provider_avs.cpp @@ -94,8 +94,6 @@ public: }; AvisynthVideoProvider::AvisynthVideoProvider(agi::fs::path const& filename, std::string const& colormatrix) try { - agi::acs::CheckFileRead(filename); - std::lock_guard lock(avs.GetMutex()); #ifdef _WIN32 @@ -326,6 +324,7 @@ void AvisynthVideoProvider::GetFrame(int n, VideoFrame &out) { namespace agi { class BackgroundRunner; } std::unique_ptr CreateAvisynthVideoProvider(agi::fs::path const& path, std::string const& colormatrix, agi::BackgroundRunner *) { + agi::acs::CheckFileRead(path); return agi::make_unique(path, colormatrix); } #endif // HAVE_AVISYNTH