ad_faad: Make work with -demuxer lavf
[mplayer/glamo.git] / loader / dshow / iunk.h
blob0c2aee300b037ee78d2ced8fb18078e1de72d207
1 /*
2 * Modified for use with MPlayer, detailed changelog at
3 * http://svn.mplayerhq.hu/mplayer/trunk/
4 */
6 #ifndef MPLAYER_IUNK_H
7 #define MPLAYER_IUNK_H
9 #include "guids.h"
11 #define INHERIT_IUNKNOWN() \
12 long STDCALL ( *QueryInterface )(IUnknown * This, const GUID* riid, void **ppvObject); \
13 long STDCALL ( *AddRef )(IUnknown * This); \
14 long STDCALL ( *Release )(IUnknown * This);
16 #define DECLARE_IUNKNOWN() \
17 int refcount;
19 #define IMPLEMENT_IUNKNOWN(CLASSNAME) \
20 static long STDCALL CLASSNAME ## _QueryInterface(IUnknown * This, \
21 const GUID* riid, void **ppvObject) \
22 { \
23 CLASSNAME * me = (CLASSNAME *)This; \
24 GUID* r; unsigned int i = 0; \
25 Debug printf(#CLASSNAME "_QueryInterface(%p) called\n", This);\
26 if (!ppvObject) return E_POINTER; \
27 for(r=me->interfaces; i<sizeof(me->interfaces)/sizeof(me->interfaces[0]); r++, i++) \
28 if(!memcmp(r, riid, sizeof(*r))) \
29 { \
30 me->vt->AddRef((IUnknown*)This); \
31 *ppvObject=This; \
32 return 0; \
33 } \
34 Debug printf("Query failed! (GUID: 0x%x)\n", *(unsigned int*)riid); \
35 return E_NOINTERFACE; \
36 } \
38 static long STDCALL CLASSNAME ## _AddRef(IUnknown * This) \
39 { \
40 CLASSNAME * me=( CLASSNAME *)This; \
41 Debug printf(#CLASSNAME "_AddRef(%p) called (ref:%d)\n", This, me->refcount); \
42 return ++(me->refcount); \
43 } \
45 static long STDCALL CLASSNAME ## _Release(IUnknown * This) \
46 { \
47 CLASSNAME* me=( CLASSNAME *)This; \
48 Debug printf(#CLASSNAME "_Release(%p) called (new ref:%d)\n", This, me->refcount - 1); \
49 if(--(me->refcount) == 0) \
50 CLASSNAME ## _Destroy(me); \
51 return 0; \
54 #endif /* MPLAYER_IUNK_H */