virtualcam-module: Use OBS atomic funcs

These are a bit more portable if we ever, say, port to windows ARM
This commit is contained in:
jp9000 2022-07-25 18:00:53 -07:00
parent 5efb3ea42d
commit 382e37440e
3 changed files with 8 additions and 7 deletions

View File

@ -108,7 +108,7 @@ VCamFilter::VCamFilter()
th = std::thread([this] { Thread(); });
AddRef();
InterlockedIncrement(&locks);
os_atomic_inc_long(&locks);
}
VCamFilter::~VCamFilter()
@ -121,7 +121,7 @@ VCamFilter::~VCamFilter()
if (placeholder.scaled_data)
free(placeholder.scaled_data);
InterlockedDecrement(&locks);
os_atomic_dec_long(&locks);
}
const wchar_t *VCamFilter::FilterName() const

View File

@ -8,6 +8,7 @@
#include "../libdshowcapture/source/output-filter.hpp"
#include "../libdshowcapture/source/dshow-formats.hpp"
#include "../../../libobs/util/windows/WinHandle.hpp"
#include "../../../libobs/util/threading-windows.h"
#define DEFAULT_CX 1920
#define DEFAULT_CY 1080

View File

@ -51,12 +51,12 @@ STDMETHODIMP VCamFactory::QueryInterface(REFIID riid, void **p_ptr)
STDMETHODIMP_(ULONG) VCamFactory::AddRef()
{
return InterlockedIncrement(&refs);
return os_atomic_inc_long(&refs);
}
STDMETHODIMP_(ULONG) VCamFactory::Release()
{
long new_refs = InterlockedDecrement(&refs);
long new_refs = os_atomic_dec_long(&refs);
if (new_refs == 0) {
delete this;
return 0;
@ -89,9 +89,9 @@ STDMETHODIMP VCamFactory::CreateInstance(LPUNKNOWN parent, REFIID, void **p_ptr)
STDMETHODIMP VCamFactory::LockServer(BOOL lock)
{
if (lock) {
InterlockedIncrement(&locks);
os_atomic_inc_long(&locks);
} else {
InterlockedDecrement(&locks);
os_atomic_dec_long(&locks);
}
return S_OK;
@ -252,7 +252,7 @@ STDAPI DllInstall(BOOL install, LPCWSTR)
STDAPI DllCanUnloadNow()
{
return InterlockedOr(&locks, 0) == 0 ? S_OK : S_FALSE;
return os_atomic_load_long(&locks) ? S_OK : S_FALSE;
}
STDAPI DllGetClassObject(REFCLSID cls, REFIID riid, void **p_ptr)