static ULONG WINAPI ICMStream_fnRelease(IAVIStream* iface) { IAVIStreamImpl *This = impl_from_IAVIStream(iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) -> %d\n", iface, ref); if (ref == 0) { /* destruct */ if (This->pg != NULL) { AVIStreamGetFrameClose(This->pg); This->pg = NULL; } if (This->pStream != NULL) { IAVIStream_Release(This->pStream); This->pStream = NULL; } if (This->hic != NULL) { if (This->lpbiPrev != NULL) { ICDecompressEnd(This->hic); HeapFree(GetProcessHeap(), 0, This->lpbiPrev); This->lpbiPrev = NULL; This->lpPrev = NULL; } ICCompressEnd(This->hic); This->hic = NULL; } if (This->lpbiCur != NULL) { HeapFree(GetProcessHeap(), 0, This->lpbiCur); This->lpbiCur = NULL; This->lpCur = NULL; } if (This->lpbiOutput != NULL) { HeapFree(GetProcessHeap(), 0, This->lpbiOutput); This->lpbiOutput = NULL; This->cbOutput = 0; } if (This->lpbiInput != NULL) { HeapFree(GetProcessHeap(), 0, This->lpbiInput); This->lpbiInput = NULL; This->cbInput = 0; } HeapFree(GetProcessHeap(), 0, This); return 0; } /* also release reference to the nested stream */ if (This->pStream != NULL) IAVIStream_Release(This->pStream); return ref; }
static ULONG WINAPI IAVIEditStream_fnRelease(IAVIEditStream*iface) { IAVIEditStreamImpl *This = impl_from_IAVIEditStream(iface); DWORD i; ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) -> %d\n", iface, ref); if (!ref) { /* release memory */ if (This->pg != NULL) AVIStreamGetFrameClose(This->pg); if (This->pStreams != NULL) { for (i = 0; i < This->nStreams; i++) { if (This->pStreams[i].pStream != NULL) IAVIStream_Release(This->pStreams[i].pStream); } HeapFree(GetProcessHeap(), 0, This->pStreams); } HeapFree(GetProcessHeap(), 0, This); return 0; } return ref; }
static HRESULT AVIFILE_RemoveStream(IAVIEditStreamImpl* const This, DWORD nr) { assert(This != NULL); assert(nr < This->nStreams); /* remove part nr */ IAVIStream_Release(This->pStreams[nr].pStream); This->nStreams--; if (nr < This->nStreams) memmove(&This->pStreams[nr], &This->pStreams[nr + 1], (This->nStreams - nr) * sizeof(This->pStreams[0])); This->pStreams[This->nStreams].pStream = NULL; This->pStreams[This->nStreams].dwStart = 0; This->pStreams[This->nStreams].dwLength = 0; /* try to merge the part before the deleted one and the one after it */ if (0 < nr && 0 < This->nStreams && This->pStreams[nr - 1].pStream == This->pStreams[nr].pStream) { if (EditStreamEnd(This, nr - 1) == This->pStreams[nr].dwStart) { This->pStreams[nr - 1].dwLength += This->pStreams[nr].dwLength; return AVIFILE_RemoveStream(This, nr); } } return AVIERR_OK; }
static ULONG WINAPI ACMStream_fnRelease(IAVIStream* iface) { IAVIStreamImpl *This = (IAVIStreamImpl *)iface; ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) -> %d\n", iface, ref); if (ref == 0) { /* destruct */ if (This->has != NULL) { if (This->acmStreamHdr.fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED) acmStreamUnprepareHeader(This->has, &This->acmStreamHdr, 0); acmStreamClose(This->has, 0); This->has = NULL; } HeapFree(GetProcessHeap(), 0, This->acmStreamHdr.pbSrc); This->acmStreamHdr.pbSrc = NULL; HeapFree(GetProcessHeap(), 0, This->acmStreamHdr.pbDst); This->acmStreamHdr.pbDst = NULL; if (This->lpInFormat != NULL) { HeapFree(GetProcessHeap(), 0, This->lpInFormat); This->lpInFormat = NULL; This->cbInFormat = 0; } if (This->lpOutFormat != NULL) { HeapFree(GetProcessHeap(), 0, This->lpOutFormat); This->lpOutFormat = NULL; This->cbOutFormat = 0; } if (This->pStream != NULL) { IAVIStream_Release(This->pStream); This->pStream = NULL; } HeapFree(GetProcessHeap(), 0, This); return 0; } /* also release reference to the nested stream */ if (This->pStream != NULL) IAVIStream_Release(This->pStream); return ref; }
static ULONG WINAPI IGetFrame_fnRelease(IGetFrame *iface) { IGetFrameImpl *This = impl_from_IGetFrame(iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p)\n", iface); if (!ref) { AVIFILE_CloseCompressor(This); if (This->pStream != NULL) { IAVIStream_Release(This->pStream); This->pStream = NULL; } HeapFree(GetProcessHeap(), 0, iface); } return ref; }