- Fix logic in Stream_fnRelease, refcount should be decremented before
authorPaul Vriens <Paul.Vriens@xs4all.nl>
Wed, 12 Jan 2005 19:29:22 +0000 (19:29 +0000)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 12 Jan 2005 19:29:22 +0000 (19:29 +0000)
  the test for 0.
- Use Interlocked* functions in Stream_fnRelease .
- Store the result of the Interlocked functions and this in the
  TRACE.

dlls/avifil32/acmstream.c
dlls/avifil32/icmstream.c

index 2f1874449aa991d7f1c9827e9574b46f6ce58c67..f44a77b0b4c3420b99e3cc17b3c74a8f165d2120 100644 (file)
@@ -160,10 +160,11 @@ static ULONG WINAPI ACMStream_fnAddRef(IAVIStream *iface)
 static ULONG WINAPI ACMStream_fnRelease(IAVIStream* iface)
 {
   IAVIStreamImpl *This = (IAVIStreamImpl *)iface;
+  ULONG ref = InterlockedDecrement(&This->ref);
 
-  TRACE("(%p) -> %ld\n", iface, This->ref - 1);
+  TRACE("(%p) -> %ld\n", iface, ref);
 
-  if (This->ref == 0) {
+  if (ref == 0) {
     /* destruct */
     if (This->has != NULL) {
       if (This->acmStreamHdr.fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED)
@@ -202,7 +203,7 @@ static ULONG WINAPI ACMStream_fnRelease(IAVIStream* iface)
   if (This->pStream != NULL)
     IAVIStream_Release(This->pStream);
 
-  return --This->ref;
+  return ref;
 }
 
 /* lParam1: PAVISTREAM
index 7091f13e23ec0727f9c1b1ad091fb05932fc70a7..838a0879605fa4e9c0e0fc7a65b712f919d15515 100644 (file)
@@ -176,10 +176,11 @@ static ULONG WINAPI ICMStream_fnAddRef(IAVIStream *iface)
 static ULONG WINAPI ICMStream_fnRelease(IAVIStream* iface)
 {
   IAVIStreamImpl *This = (IAVIStreamImpl *)iface;
+  ULONG ref = InterlockedDecrement(&This->ref);
 
-  TRACE("(%p) -> %ld\n", iface, This->ref - 1);
+  TRACE("(%p) -> %ld\n", iface, ref);
 
-  if (This->ref == 0) {
+  if (ref == 0) {
     /* destruct */
     if (This->pg != NULL) {
       AVIStreamGetFrameClose(This->pg);
@@ -224,7 +225,7 @@ static ULONG WINAPI ICMStream_fnRelease(IAVIStream* iface)
   if (This->pStream != NULL)
     IAVIStream_Release(This->pStream);
 
-  return --This->ref;
+  return ref;
 }
 
 /* lParam1: PAVISTREAM