- use Interlocked* functions in AddRef and Release.
- store the result of the Interlocked functions and use only this.
This commit is contained in:
parent
a010e3b3fa
commit
c905d691c8
|
@ -147,14 +147,15 @@ static HRESULT WINAPI ACMStream_fnQueryInterface(IAVIStream *iface,
|
|||
static ULONG WINAPI ACMStream_fnAddRef(IAVIStream *iface)
|
||||
{
|
||||
IAVIStreamImpl *This = (IAVIStreamImpl *)iface;
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
|
||||
TRACE("(%p) -> %ld\n", iface, This->ref + 1);
|
||||
TRACE("(%p) -> %ld\n", iface, ref);
|
||||
|
||||
/* also add reference to the nested stream */
|
||||
if (This->pStream != NULL)
|
||||
IAVIStream_AddRef(This->pStream);
|
||||
|
||||
return ++(This->ref);
|
||||
return ref;
|
||||
}
|
||||
|
||||
static ULONG WINAPI ACMStream_fnRelease(IAVIStream* iface)
|
||||
|
|
|
@ -282,21 +282,22 @@ static HRESULT WINAPI IAVIFile_fnQueryInterface(IAVIFile *iface, REFIID refiid,
|
|||
static ULONG WINAPI IAVIFile_fnAddRef(IAVIFile *iface)
|
||||
{
|
||||
IAVIFileImpl *This = (IAVIFileImpl *)iface;
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
|
||||
TRACE("(%p) -> %ld\n", iface, This->ref + 1);
|
||||
return InterlockedIncrement(&This->ref);
|
||||
TRACE("(%p) -> %ld\n", iface, ref);
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
static ULONG WINAPI IAVIFile_fnRelease(IAVIFile *iface)
|
||||
{
|
||||
IAVIFileImpl *This = (IAVIFileImpl *)iface;
|
||||
UINT i;
|
||||
ULONG ret;
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
TRACE("(%p) -> %ld\n", iface, This->ref - 1);
|
||||
TRACE("(%p) -> %ld\n", iface, ref);
|
||||
|
||||
ret = InterlockedDecrement(&This->ref);
|
||||
if (!ret) {
|
||||
if (!ref) {
|
||||
if (This->fDirty) {
|
||||
/* need to write headers to file */
|
||||
AVIFILE_SaveFile(This);
|
||||
|
@ -337,7 +338,7 @@ static ULONG WINAPI IAVIFile_fnRelease(IAVIFile *iface)
|
|||
|
||||
LocalFree((HLOCAL)This);
|
||||
}
|
||||
return ret;
|
||||
return ref;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile *iface, LPAVIFILEINFOW afi,
|
||||
|
@ -737,27 +738,28 @@ static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream *iface,
|
|||
static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream *iface)
|
||||
{
|
||||
IAVIStreamImpl *This = (IAVIStreamImpl *)iface;
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
|
||||
TRACE("(%p) -> %ld\n", iface, This->ref + 1);
|
||||
TRACE("(%p) -> %ld\n", iface, ref);
|
||||
|
||||
/* also add ref to parent, so that it doesn't kill us */
|
||||
if (This->paf != NULL)
|
||||
IAVIFile_AddRef((PAVIFILE)This->paf);
|
||||
|
||||
return InterlockedIncrement(&This->ref);
|
||||
return ref;
|
||||
}
|
||||
|
||||
static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface)
|
||||
{
|
||||
IAVIStreamImpl *This = (IAVIStreamImpl *)iface;
|
||||
ULONG ret = InterlockedDecrement(&This->ref);
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
TRACE("(%p) -> %ld\n", iface, ret);
|
||||
TRACE("(%p) -> %ld\n", iface, ref);
|
||||
|
||||
if (This->paf != NULL)
|
||||
IAVIFile_Release((PAVIFILE)This->paf);
|
||||
|
||||
return ret;
|
||||
return ref;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream *iface, LPARAM lParam1,
|
||||
|
|
|
@ -381,20 +381,23 @@ static HRESULT WINAPI IAVIEditStream_fnQueryInterface(IAVIEditStream*iface,REFII
|
|||
static ULONG WINAPI IAVIEditStream_fnAddRef(IAVIEditStream*iface)
|
||||
{
|
||||
IAVIEditStreamImpl *This = (IAVIEditStreamImpl *)iface;
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
|
||||
TRACE("(%p) -> %ld\n", iface, This->ref + 1);
|
||||
return ++(This->ref);
|
||||
TRACE("(%p) -> %ld\n", iface, ref);
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
static ULONG WINAPI IAVIEditStream_fnRelease(IAVIEditStream*iface)
|
||||
{
|
||||
IAVIEditStreamImpl *This = (IAVIEditStreamImpl *)iface;
|
||||
DWORD i;
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
TRACE("(%p) -> %ld\n", iface, This->ref - 1);
|
||||
TRACE("(%p) -> %ld\n", iface, ref);
|
||||
|
||||
if (!--(This->ref)) {
|
||||
/* releaase memory */
|
||||
if (!ref) {
|
||||
/* release memory */
|
||||
if (This->pg != NULL)
|
||||
AVIStreamGetFrameClose(This->pg);
|
||||
if (This->pStreams != NULL) {
|
||||
|
@ -408,7 +411,7 @@ static ULONG WINAPI IAVIEditStream_fnRelease(IAVIEditStream*iface)
|
|||
LocalFree((HLOCAL)This);
|
||||
return 0;
|
||||
}
|
||||
return This->ref;
|
||||
return ref;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IAVIEditStream_fnCut(IAVIEditStream*iface,LONG*plStart,
|
||||
|
|
|
@ -155,19 +155,21 @@ static HRESULT WINAPI IGetFrame_fnQueryInterface(IGetFrame *iface,
|
|||
static ULONG WINAPI IGetFrame_fnAddRef(IGetFrame *iface)
|
||||
{
|
||||
IGetFrameImpl *This = (IGetFrameImpl *)iface;
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
|
||||
TRACE("(%p)\n", iface);
|
||||
|
||||
return ++(This->ref);
|
||||
return ref;
|
||||
}
|
||||
|
||||
static ULONG WINAPI IGetFrame_fnRelease(IGetFrame *iface)
|
||||
{
|
||||
IGetFrameImpl *This = (IGetFrameImpl *)iface;
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
TRACE("(%p)\n", iface);
|
||||
|
||||
if (!--(This->ref)) {
|
||||
if (!ref) {
|
||||
AVIFILE_CloseCompressor(This);
|
||||
if (This->pStream != NULL) {
|
||||
IAVIStream_Release(This->pStream);
|
||||
|
@ -178,7 +180,7 @@ static ULONG WINAPI IGetFrame_fnRelease(IGetFrame *iface)
|
|||
return 0;
|
||||
}
|
||||
|
||||
return This->ref;
|
||||
return ref;
|
||||
}
|
||||
|
||||
static LPVOID WINAPI IGetFrame_fnGetFrame(IGetFrame *iface, LONG lPos)
|
||||
|
|
|
@ -163,14 +163,15 @@ static HRESULT WINAPI ICMStream_fnQueryInterface(IAVIStream *iface,
|
|||
static ULONG WINAPI ICMStream_fnAddRef(IAVIStream *iface)
|
||||
{
|
||||
IAVIStreamImpl *This = (IAVIStreamImpl *)iface;
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
|
||||
TRACE("(%p) -> %ld\n", iface, This->ref + 1);
|
||||
TRACE("(%p) -> %ld\n", iface, ref);
|
||||
|
||||
/* also add reference to the nested stream */
|
||||
if (This->pStream != NULL)
|
||||
IAVIStream_AddRef(This->pStream);
|
||||
|
||||
return ++(This->ref);
|
||||
return ref;
|
||||
}
|
||||
|
||||
static ULONG WINAPI ICMStream_fnRelease(IAVIStream* iface)
|
||||
|
|
|
@ -152,18 +152,21 @@ static HRESULT WINAPI ITmpFile_fnQueryInterface(IAVIFile *iface, REFIID refiid,
|
|||
static ULONG WINAPI ITmpFile_fnAddRef(IAVIFile *iface)
|
||||
{
|
||||
ITmpFileImpl *This = (ITmpFileImpl *)iface;
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
|
||||
TRACE("(%p) -> %ld\n", iface, This->ref + 1);
|
||||
return ++(This->ref);
|
||||
TRACE("(%p) -> %ld\n", iface, ref);
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
static ULONG WINAPI ITmpFile_fnRelease(IAVIFile *iface)
|
||||
{
|
||||
ITmpFileImpl *This = (ITmpFileImpl *)iface;
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
TRACE("(%p) -> %ld\n", iface, This->ref - 1);
|
||||
TRACE("(%p) -> %ld\n", iface, ref);
|
||||
|
||||
if (!--(This->ref)) {
|
||||
if (!ref) {
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < This->fInfo.dwStreams; i++) {
|
||||
|
@ -178,7 +181,7 @@ static ULONG WINAPI ITmpFile_fnRelease(IAVIFile *iface)
|
|||
return 0;
|
||||
}
|
||||
|
||||
return This->ref;
|
||||
return ref;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ITmpFile_fnInfo(IAVIFile *iface,
|
||||
|
|
|
@ -272,16 +272,17 @@ static ULONG WINAPI IAVIFile_fnAddRef(IAVIFile *iface)
|
|||
|
||||
TRACE("(%p)\n",iface);
|
||||
|
||||
return ++(This->ref);
|
||||
return InterlockedIncrement(&This->ref);
|
||||
}
|
||||
|
||||
static ULONG WINAPI IAVIFile_fnRelease(IAVIFile *iface)
|
||||
{
|
||||
IAVIFileImpl *This = (IAVIFileImpl *)iface;
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
TRACE("(%p)\n",iface);
|
||||
|
||||
if (!--(This->ref)) {
|
||||
if (!ref) {
|
||||
if (This->fDirty) {
|
||||
/* need to write headers to file */
|
||||
AVIFILE_SaveFile(This);
|
||||
|
@ -309,7 +310,7 @@ static ULONG WINAPI IAVIFile_fnRelease(IAVIFile *iface)
|
|||
LocalFree((HLOCAL)This);
|
||||
return 0;
|
||||
}
|
||||
return This->ref;
|
||||
return ref;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile *iface, LPAVIFILEINFOW afi,
|
||||
|
|
Loading…
Reference in New Issue