virtualcam-module: Only allow DLL unload when filter freed

Fixes a bug where the DLL could unload while the filter is currently
being destroyed, which would cause a crash in the host process
This commit is contained in:
jp9000 2022-07-25 12:07:03 -07:00
parent ef9c99f5f4
commit 5efb3ea42d
2 changed files with 5 additions and 1 deletions

View File

@ -10,6 +10,7 @@ using namespace DShow;
extern bool initialize_placeholder();
extern const uint8_t *get_placeholder_ptr();
extern const bool get_placeholder_size(int *out_cx, int *out_cy);
extern volatile long locks;
/* ========================================================================= */
@ -107,6 +108,7 @@ VCamFilter::VCamFilter()
th = std::thread([this] { Thread(); });
AddRef();
InterlockedIncrement(&locks);
}
VCamFilter::~VCamFilter()
@ -118,6 +120,8 @@ VCamFilter::~VCamFilter()
if (placeholder.scaled_data)
free(placeholder.scaled_data);
InterlockedDecrement(&locks);
}
const wchar_t *VCamFilter::FilterName() const

View File

@ -11,7 +11,7 @@ static const REGFILTERPINS AMSPinVideo = {L"Output", false, true,
nullptr, 1, &AMSMediaTypesV};
HINSTANCE dll_inst = nullptr;
static volatile long locks = 0;
volatile long locks = 0;
/* ========================================================================= */