From ec72feaba3631a4ab594bc9797ab5070f1da9198 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 14 Jun 2015 17:51:59 +0200 Subject: win32: use atomics for COM interface refcount --- video/out/w32_common.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'video') 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; -- cgit v1.2.3