static HRESULT StdMemAllocator_Free(IMemAllocator * iface) { StdMemAllocator *This = StdMemAllocator_from_IMemAllocator(iface); struct list * cursor; if (!list_empty(&This->base.used_list)) { WARN("Freeing allocator with outstanding samples!\n"); while ((cursor = list_head(&This->base.used_list)) != NULL) { StdMediaSample2 *pSample; list_remove(cursor); pSample = LIST_ENTRY(cursor, StdMediaSample2, listentry); pSample->pParent = NULL; } } while ((cursor = list_head(&This->base.free_list)) != NULL) { list_remove(cursor); StdMediaSample2_Delete(LIST_ENTRY(cursor, StdMediaSample2, listentry)); } /* free memory */ if (!VirtualFree(This->pMemory, 0, MEM_RELEASE)) { ERR("Couldn't free memory. Error: %u\n", GetLastError()); return HRESULT_FROM_WIN32(GetLastError()); } return S_OK; }
static ULONG WINAPI StdMediaSample2_Release(IMediaSample2 * iface) { StdMediaSample2 *This = impl_from_IMediaSample2(iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p)->(): new ref = %d\n", This, ref); if (!ref) { if (This->pParent) IMemAllocator_ReleaseBuffer(This->pParent, (IMediaSample *)iface); else StdMediaSample2_Delete(This); } return ref; }
static ULONG WINAPI StdMediaSample2_Release(IMediaSample2 * iface) { StdMediaSample2 *This = (StdMediaSample2 *)iface; ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p)->() Release from %d\n", iface, ref + 1); if (!ref) { if (This->pParent) IMemAllocator_ReleaseBuffer(This->pParent, (IMediaSample *)iface); else StdMediaSample2_Delete(This); return 0; } return ref; }
static HRESULT StdMemAllocator_Free(IMemAllocator * iface) { StdMemAllocator *This = (StdMemAllocator *)iface; struct list * cursor; assert(list_empty(&This->base.used_list)); while ((cursor = list_head(&This->base.free_list)) != NULL) { list_remove(cursor); StdMediaSample2_Delete(LIST_ENTRY(cursor, StdMediaSample2, listentry)); } /* free memory */ if (!VirtualFree(This->pMemory, 0, MEM_RELEASE)) { ERR("Couldn't free memory. Error: %ld\n", GetLastError()); return HRESULT_FROM_WIN32(GetLastError()); } return S_OK; }