Handle exceptions from AviSynthWrapper ctor

This commit is contained in:
wangqr 2021-07-13 10:32:40 -04:00 committed by arch1t3cht
parent 21591b3e88
commit 691ab820b8
2 changed files with 8 additions and 2 deletions

View File

@ -63,7 +63,7 @@ public:
bool NeedsCache() const override { return true; } bool NeedsCache() const override { return true; }
}; };
AvisynthAudioProvider::AvisynthAudioProvider(agi::fs::path const& filename) { AvisynthAudioProvider::AvisynthAudioProvider(agi::fs::path const& filename) try {
agi::acs::CheckFileRead(filename); agi::acs::CheckFileRead(filename);
std::lock_guard<std::mutex> lock(avs_wrapper.GetMutex()); std::lock_guard<std::mutex> lock(avs_wrapper.GetMutex());
@ -100,6 +100,9 @@ AvisynthAudioProvider::AvisynthAudioProvider(agi::fs::path const& filename) {
throw agi::AudioProviderError("Avisynth error: " + errmsg); throw agi::AudioProviderError("Avisynth error: " + errmsg);
} }
} }
catch (AvisynthError& err) {
throw agi::AudioProviderError("Avisynth error: " + std::string(err.msg));
}
void AvisynthAudioProvider::LoadFromClip(AVSValue clip) { void AvisynthAudioProvider::LoadFromClip(AVSValue clip) {
// Check if it has audio // Check if it has audio

View File

@ -93,7 +93,7 @@ public:
bool HasAudio() const override { return has_audio; } bool HasAudio() const override { return has_audio; }
}; };
AvisynthVideoProvider::AvisynthVideoProvider(agi::fs::path const& filename, std::string const& colormatrix) { AvisynthVideoProvider::AvisynthVideoProvider(agi::fs::path const& filename, std::string const& colormatrix) try {
agi::acs::CheckFileRead(filename); agi::acs::CheckFileRead(filename);
std::lock_guard<std::mutex> lock(avs.GetMutex()); std::lock_guard<std::mutex> lock(avs.GetMutex());
@ -182,6 +182,9 @@ file_exit:
throw VideoOpenError("Avisynth error: " + std::string(err.msg)); throw VideoOpenError("Avisynth error: " + std::string(err.msg));
} }
} }
catch (AvisynthError const& err) {
throw VideoProviderError("Avisynth error: " + std::string(err.msg));
}
void AvisynthVideoProvider::Init(std::string const& colormatrix) { void AvisynthVideoProvider::Init(std::string const& colormatrix) {
auto script = source_clip; auto script = source_clip;