diff options
Diffstat (limited to 'loader/dshow/iunk.h')
-rw-r--r-- | loader/dshow/iunk.h | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/loader/dshow/iunk.h b/loader/dshow/iunk.h index e87d80ba6d..6dbf00ffaa 100644 --- a/loader/dshow/iunk.h +++ b/loader/dshow/iunk.h @@ -1,48 +1,49 @@ #ifndef DS_IUNK_H #define DS_IUNK_H -#include "interfaces.h" #include "guids.h" +#include <stdlib.h> + +#define INHERIT_IUNKNOWN() \ + long STDCALL ( *QueryInterface )(IUnknown * This, GUID* riid, void **ppvObject); \ + long STDCALL ( *AddRef )(IUnknown * This); \ + long STDCALL ( *Release )(IUnknown * This); + +#define DECLARE_IUNKNOWN() \ + int refcount; -#define DECLARE_IUNKNOWN(CLASSNAME) \ - int refcount; \ - static long STDCALL QueryInterface(IUnknown * This, GUID* riid, void **ppvObject); \ - static long STDCALL AddRef (IUnknown * This); \ - static long STDCALL Release (IUnknown * This); - #define IMPLEMENT_IUNKNOWN(CLASSNAME) \ -long STDCALL CLASSNAME ::QueryInterface(IUnknown * This, GUID* riid, void **ppvObject) \ +static long STDCALL CLASSNAME ## _QueryInterface(IUnknown * This, \ + GUID* riid, void **ppvObject) \ { \ - Debug printf(#CLASSNAME "::QueryInterface() called\n");\ - if (!ppvObject) return 0x80004003; \ CLASSNAME * me = (CLASSNAME *)This; \ - unsigned int i = 0; \ - for(const GUID* r=me->interfaces; i<sizeof(CLASSNAME ::interfaces)/sizeof(CLASSNAME ::interfaces[0]); r++, i++) \ - if(!memcmp(r, riid, 16)) \ + GUID* r; unsigned int i = 0; \ + Debug printf(#CLASSNAME "_QueryInterface(%p) called\n", This);\ + if (!ppvObject) return 0x80004003; \ + for(r=me->interfaces; i<sizeof(me->interfaces)/sizeof(me->interfaces[0]); r++, i++) \ + if(!memcmp(r, riid, sizeof(*r))) \ { \ - This->vt->AddRef((IUnknown*)This); \ + me->vt->AddRef((IUnknown*)This); \ *ppvObject=This; \ return 0; \ } \ - Debug printf("Failed\n"); \ + Debug printf("Query failed!\n"); \ return E_NOINTERFACE; \ } \ \ -long STDCALL CLASSNAME ::AddRef ( \ - IUnknown * This) \ +static long STDCALL CLASSNAME ## _AddRef(IUnknown * This) \ { \ - Debug printf(#CLASSNAME "::AddRef() called\n"); \ CLASSNAME * me=( CLASSNAME *)This; \ + Debug printf(#CLASSNAME "_AddRef(%p) called (ref:%d)\n", This, me->refcount); \ return ++(me->refcount); \ } \ \ -long STDCALL CLASSNAME ::Release ( \ - IUnknown * This) \ +static long STDCALL CLASSNAME ## _Release(IUnknown * This) \ { \ - Debug printf(#CLASSNAME "::Release() called\n"); \ CLASSNAME* me=( CLASSNAME *)This; \ - if(--(me->refcount) ==0) \ - delete ( CLASSNAME *) This; \ + Debug printf(#CLASSNAME "_Release(%p) called (new ref:%d)\n", This, me->refcount - 1); \ + if(--(me->refcount) == 0) \ + CLASSNAME ## _Destroy(me); \ return 0; \ } |