diff options
author | wm4 <wm4@nowhere> | 2015-06-14 17:51:59 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-06-14 17:56:24 +0200 |
commit | ec72feaba3631a4ab594bc9797ab5070f1da9198 (patch) | |
tree | 524da9de800e65b8b81660e487e1562eeb7575cc /video/out | |
parent | 725d840b7329fb00dfe4b1de82ac1ab570506c59 (diff) | |
download | mpv-ec72feaba3631a4ab594bc9797ab5070f1da9198.tar.bz2 mpv-ec72feaba3631a4ab594bc9797ab5070f1da9198.tar.xz |
win32: use atomics for COM interface refcount
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/w32_common.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/video/out/w32_common.c b/video/out/w32_common.c index 57e4a4a2f9..d2671fef15 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -37,6 +37,7 @@ #include "osdep/io.h" #include "osdep/threads.h" #include "osdep/w32_keyboard.h" +#include "osdep/atomics.h" #include "misc/dispatch.h" #include "misc/rendezvous.h" #include "talloc.h" @@ -111,7 +112,7 @@ struct vo_w32_state { typedef struct tagDropTarget { IDropTarget iface; - ULONG refCnt; + atomic_int refCnt; DWORD lastEffect; IDataObject* dataObj; struct vo_w32_state *w32; @@ -148,13 +149,13 @@ static HRESULT STDMETHODCALLTYPE DropTarget_QueryInterface(IDropTarget* This, static ULONG STDMETHODCALLTYPE DropTarget_AddRef(IDropTarget* This) { DropTarget* t = (DropTarget*)This; - return ++(t->refCnt); + return atomic_fetch_add(&t->refCnt, 1) + 1; } static ULONG STDMETHODCALLTYPE DropTarget_Release(IDropTarget* This) { DropTarget* t = (DropTarget*)This; - ULONG cRef = --(t->refCnt); + ULONG cRef = atomic_fetch_add(&t->refCnt, -1) - 1; if (cRef == 0) { DropTarget_Destroy(t); @@ -295,7 +296,7 @@ static void DropTarget_Init(DropTarget* This, struct vo_w32_state *w32) }; This->iface.lpVtbl = vtbl; - This->refCnt = 0; + atomic_store(&This->refCnt, 0); This->lastEffect = 0; This->dataObj = NULL; This->w32 = w32; |