Skip to content

Commit

Permalink
Merge branch 'avisynth' into feature
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1t3cht committed Oct 15, 2023
2 parents 49fe603 + 858f4ac commit d8c611d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/avisynth_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
// Allocate storage for and initialise static members
namespace {
int avs_refcount = 0;
bool failed = false;
#ifdef _WIN32
HINSTANCE hLib = nullptr;
#else
Expand All @@ -66,8 +67,8 @@ const AVS_Linkage *AVS_linkage = nullptr;

typedef IScriptEnvironment* __stdcall FUNC(int);

AviSynthWrapper::AviSynthWrapper() {
if (!avs_refcount){
AviSynthWrapper::AviSynthWrapper() try {
if (!avs_refcount++) {
#ifdef _WIN32
#define CONCATENATE(x, y) x ## y
#define _Lstr(x) CONCATENATE(L, x)
Expand All @@ -94,15 +95,16 @@ AviSynthWrapper::AviSynthWrapper() {
if (!env)
throw AvisynthError("Failed to create a new avisynth script environment. Avisynth is too old?");

avs_refcount++;

AVS_linkage = env->GetAVSLinkage();

// Set memory limit
const int memoryMax = OPT_GET("Provider/Avisynth/Memory Max")->GetInt();
if (memoryMax)
env->SetMemoryMax(memoryMax);
}
} catch (AvisynthError const&) {
avs_refcount--;
throw;
}

AviSynthWrapper::~AviSynthWrapper() {
Expand Down

0 comments on commit d8c611d

Please sign in to comment.