1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-15 19:35:49 +00:00
mpv/loader/dshow/iunk.h
arpi 6e718683eb C++ -> C (import from avifile cvs)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3057 b3059339-0415-0410-9bf9-f77b7e298cf2
2001-11-21 19:12:39 +00:00

51 lines
1.5 KiB
C

#ifndef DS_IUNK_H
#define DS_IUNK_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 IMPLEMENT_IUNKNOWN(CLASSNAME) \
static long STDCALL CLASSNAME ## _QueryInterface(IUnknown * This, \
GUID* riid, void **ppvObject) \
{ \
CLASSNAME * me = (CLASSNAME *)This; \
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))) \
{ \
me->vt->AddRef((IUnknown*)This); \
*ppvObject=This; \
return 0; \
} \
Debug printf("Query failed!\n"); \
return E_NOINTERFACE; \
} \
\
static long STDCALL CLASSNAME ## _AddRef(IUnknown * This) \
{ \
CLASSNAME * me=( CLASSNAME *)This; \
Debug printf(#CLASSNAME "_AddRef(%p) called (ref:%d)\n", This, me->refcount); \
return ++(me->refcount); \
} \
\
static long STDCALL CLASSNAME ## _Release(IUnknown * This) \
{ \
CLASSNAME* me=( 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; \
}
#endif /* DS_IUNK_H */