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.
This commit is contained in:
Niels Martin Hansen 2007-08-28 21:34:44 +00:00
parent 4cf49cf9fb
commit fb7c7e1f74
2 changed files with 25 additions and 1 deletions

View file

@ -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);

View file

@ -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" };