2005-04-15 20:17:14 +00:00
|
|
|
/*
|
|
|
|
* Modified for use with MPlayer, detailed CVS changelog at
|
|
|
|
* http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
|
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
2001-08-16 00:50:02 +00:00
|
|
|
#ifndef DS_IUNK_H
|
|
|
|
#define DS_IUNK_H
|
|
|
|
|
2001-03-20 00:05:27 +00:00
|
|
|
#include "guids.h"
|
2001-11-21 19:12:39 +00:00
|
|
|
|
|
|
|
#define INHERIT_IUNKNOWN() \
|
2002-09-13 19:43:17 +00:00
|
|
|
long STDCALL ( *QueryInterface )(IUnknown * This, const GUID* riid, void **ppvObject); \
|
2001-11-21 19:12:39 +00:00
|
|
|
long STDCALL ( *AddRef )(IUnknown * This); \
|
|
|
|
long STDCALL ( *Release )(IUnknown * This);
|
|
|
|
|
|
|
|
#define DECLARE_IUNKNOWN() \
|
|
|
|
int refcount;
|
2001-08-16 00:50:02 +00:00
|
|
|
|
2001-03-20 00:05:27 +00:00
|
|
|
#define IMPLEMENT_IUNKNOWN(CLASSNAME) \
|
2001-11-21 19:12:39 +00:00
|
|
|
static long STDCALL CLASSNAME ## _QueryInterface(IUnknown * This, \
|
2002-09-13 19:43:17 +00:00
|
|
|
const GUID* riid, void **ppvObject) \
|
2001-03-20 00:05:27 +00:00
|
|
|
{ \
|
2001-08-16 00:50:02 +00:00
|
|
|
CLASSNAME * me = (CLASSNAME *)This; \
|
2001-11-21 19:12:39 +00:00
|
|
|
GUID* r; unsigned int i = 0; \
|
|
|
|
Debug printf(#CLASSNAME "_QueryInterface(%p) called\n", This);\
|
2002-11-26 21:00:20 +00:00
|
|
|
if (!ppvObject) return E_POINTER; \
|
2001-11-21 19:12:39 +00:00
|
|
|
for(r=me->interfaces; i<sizeof(me->interfaces)/sizeof(me->interfaces[0]); r++, i++) \
|
|
|
|
if(!memcmp(r, riid, sizeof(*r))) \
|
2001-03-20 00:05:27 +00:00
|
|
|
{ \
|
2001-11-21 19:12:39 +00:00
|
|
|
me->vt->AddRef((IUnknown*)This); \
|
2001-03-20 00:05:27 +00:00
|
|
|
*ppvObject=This; \
|
|
|
|
return 0; \
|
|
|
|
} \
|
2002-11-26 21:00:20 +00:00
|
|
|
Debug printf("Query failed! (GUID: 0x%x)\n", *(unsigned int*)riid); \
|
2001-08-16 00:50:02 +00:00
|
|
|
return E_NOINTERFACE; \
|
2001-03-20 00:05:27 +00:00
|
|
|
} \
|
|
|
|
\
|
2001-11-21 19:12:39 +00:00
|
|
|
static long STDCALL CLASSNAME ## _AddRef(IUnknown * This) \
|
2001-03-20 00:05:27 +00:00
|
|
|
{ \
|
|
|
|
CLASSNAME * me=( CLASSNAME *)This; \
|
2001-11-21 19:12:39 +00:00
|
|
|
Debug printf(#CLASSNAME "_AddRef(%p) called (ref:%d)\n", This, me->refcount); \
|
2001-03-20 00:05:27 +00:00
|
|
|
return ++(me->refcount); \
|
|
|
|
} \
|
|
|
|
\
|
2001-11-21 19:12:39 +00:00
|
|
|
static long STDCALL CLASSNAME ## _Release(IUnknown * This) \
|
2001-03-20 00:05:27 +00:00
|
|
|
{ \
|
|
|
|
CLASSNAME* me=( CLASSNAME *)This; \
|
2001-11-21 19:12:39 +00:00
|
|
|
Debug printf(#CLASSNAME "_Release(%p) called (new ref:%d)\n", This, me->refcount - 1); \
|
|
|
|
if(--(me->refcount) == 0) \
|
|
|
|
CLASSNAME ## _Destroy(me); \
|
2001-03-20 00:05:27 +00:00
|
|
|
return 0; \
|
|
|
|
}
|
|
|
|
|
2001-08-16 00:50:02 +00:00
|
|
|
#endif /* DS_IUNK_H */
|