From fb7c7e1f74643503b9d961f0688a36e3d7ef1349 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Tue, 28 Aug 2007 21:34:44 +0000 Subject: [PATCH] Make Avisynth video and audio provider load DirectShowSource.dll from the application directory if it exists. Audio provider should also fail properly now if the DirectShowSource function doesn't exist. Originally committed to SVN as r1537. --- aegisub/audio_provider_avs.cpp | 17 ++++++++++++++++- aegisub/video_provider_avs.cpp | 9 +++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/aegisub/audio_provider_avs.cpp b/aegisub/audio_provider_avs.cpp index d0fe8b151..09c5b0136 100644 --- a/aegisub/audio_provider_avs.cpp +++ b/aegisub/audio_provider_avs.cpp @@ -45,6 +45,7 @@ #include "avisynth_wrap.h" #include "utils.h" #include "options.h" +#include "standard_paths.h" //////////////////////// @@ -131,7 +132,21 @@ void AvisynthAudioProvider::OpenAVSAudio() { wxFileName fn(filename); const char * argnames[3] = { 0, "video", "audio" }; AVSValue args[3] = { env->SaveString(fn.GetShortPath().mb_str(wxConvLocal)), false, true }; - script = env->Invoke("DirectShowSource", AVSValue(args,3),argnames); + + // Load DirectShowSource.dll from app dir if it exists + wxFileName dsspath(StandardPaths::DecodePath(_T("?data/DirectShowSource.dll"))); + if (dsspath.FileExists()) { + env->Invoke("LoadPlugin",env->SaveString(dsspath.GetFullPath().mb_str(wxConvLocal))); + } + + // Load audio with DSS if it exists + if (env->FunctionExists("DirectShowSource")) { + script = env->Invoke("DirectShowSource", AVSValue(args,3),argnames); + } + // Otherwise fail + else { + throw AvisynthError("No suitable audio source filter found. Try placing DirectShowSource.dll in the Aegisub application directory."); + } } LoadFromClip(script); diff --git a/aegisub/video_provider_avs.cpp b/aegisub/video_provider_avs.cpp index 3fe70d3c3..554427754 100644 --- a/aegisub/video_provider_avs.cpp +++ b/aegisub/video_provider_avs.cpp @@ -298,6 +298,15 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori // Try DirectShowSource if (!dss2) { + // Load DirectShowSource.dll from app dir if it exists + wxFileName dsspath(StandardPaths::DecodePath(_T("?data/DirectShowSource.dll"))); + if (dsspath.FileExists()) { + AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loading DirectShowSource")); + env->Invoke("LoadPlugin",env->SaveString(dsspath.GetFullPath().mb_str(wxConvLocal))); + AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loaded DirectShowSource")); + } + + // Then try using DSS if (env->FunctionExists("DirectShowSource")) { if (fps == 0.0) { const char *argnames[3] = { 0, "video", "audio" };