[MPlayer-dev-eng] [PATCH] fix return value of Directshow's AddRef and Release
Vladimir Voroshilov
voroshil at gmail.com
Sun Jan 28 07:24:11 CET 2007
Hi, All.
Attached patch fixes return value from IUnknown::AddRef and
IUnknown::Release methods.
Before this patch return value of above methods differs in
outputpin.c, inputpin.c and iunk.h (one of them return 0, others -
reference counter).
Return value does not have real sense in almost cases, because MSDN
says that applications should use it only for debug purposes. But i
think consistent behaviour is better.
--
Regards,
Vladimir Voroshilov mailto:voroshil at gmail.com
JID: voroshil at jabber.ru
ICQ: 95587719
-------------- next part --------------
Index: outputpin.c
===================================================================
--- outputpin.c (revision 22035)
+++ outputpin.c (working copy)
@@ -879,8 +879,7 @@
static HRESULT STDCALL COutputPin_AddRef(IUnknown* This)
{
Debug printf("COutputPin_AddRef(%p) called (%d)\n", This, ((COutputPin*)This)->refcount);
- ((COutputPin*)This)->refcount++;
- return 0;
+ return ++((COutputPin*)This)->refcount;
}
/**
@@ -899,9 +898,12 @@
{
Debug printf("COutputPin_Release(%p) called (%d)\n", This, ((COutputPin*)This)->refcount);
if (--((COutputPin*)This)->refcount <= 0)
+ {
COutputPin_Destroy((COutputPin*)This);
return 0;
+ }
+ return ((COutputPin*)This)->refcount;
}
/**
@@ -919,8 +921,7 @@
{
COutputMemPin* p = (COutputMemPin*) This;
Debug printf("COutputMemPin_AddRef(%p) called (%p, %d)\n", p, p->parent, p->parent->refcount);
- p->parent->refcount++;
- return 0;
+ return ++p->parent->refcount;
}
/**
@@ -941,8 +942,12 @@
Debug printf("COutputMemPin_Release(%p) called (%p, %d)\n",
p, p->parent, p->parent->refcount);
if (--p->parent->refcount <= 0)
+ {
COutputPin_Destroy(p->parent);
+
return 0;
+ }
+ return p->parent->refcount;
}
/**
Index: iunk.h
===================================================================
--- iunk.h (revision 22035)
+++ iunk.h (working copy)
@@ -48,8 +48,11 @@
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; \
+ } \
+ return me->refcount; \
}
#endif /* DS_IUNK_H */
Index: cmediasample.c
===================================================================
--- cmediasample.c (revision 22035)
+++ cmediasample.c (working copy)
@@ -42,8 +42,7 @@
static long STDCALL CMediaSample_AddRef(IUnknown* This)
{
Debug printf("CMediaSample_AddRef(%p) called\n", This);
- ((CMediaSample*)This)->refcount++;
- return 0;
+ return ++((CMediaSample*)This)->refcount;
}
void CMediaSample_Destroy(CMediaSample* This)
@@ -67,8 +66,9 @@
{
parent->all->vt->ReleaseBuffer((IMemAllocator*)(parent->all),
(IMediaSample*)This);
+ return 0;
}
- return 0;
+ return ((CMediaSample*) This)->refcount;
}
static HRESULT STDCALL CMediaSample_GetPointer(IMediaSample* This,
More information about the MPlayer-dev-eng
mailing list