static HRESULT WINAPI BaseMemAllocator_Commit(IMemAllocator * iface) { BaseMemAllocator *This = impl_from_IMemAllocator(iface); HRESULT hr; TRACE("(%p)->()\n", This); EnterCriticalSection(This->pCritSect); { if (!This->props.cbAlign) hr = VFW_E_BADALIGN; else if (!This->props.cbBuffer) hr = VFW_E_SIZENOTSET; else if (!This->props.cBuffers) hr = VFW_E_BUFFER_NOTSET; else if (This->bDecommitQueued && This->bCommitted) { This->bDecommitQueued = FALSE; hr = S_OK; } else if (This->bCommitted) hr = S_OK; else { if (!(This->hSemWaiting = CreateSemaphoreW(NULL, This->props.cBuffers, This->props.cBuffers, NULL))) { ERR("Couldn't create semaphore (error was %u)\n", GetLastError()); hr = HRESULT_FROM_WIN32(GetLastError()); } else { hr = This->fnAlloc(iface); if (SUCCEEDED(hr)) This->bCommitted = TRUE; else ERR("fnAlloc failed with error 0x%x\n", hr); } } } LeaveCriticalSection(This->pCritSect); return hr; }
static HRESULT WINAPI BaseMemAllocator_Commit(IMemAllocator * iface) { BaseMemAllocator *This = (BaseMemAllocator *)iface; HRESULT hr; TRACE("(%p)->()\n", This); EnterCriticalSection(&This->csState); { if (!This->pProps) hr = VFW_E_SIZENOTSET; else if (This->bCommitted) hr = S_OK; else if (This->bDecommitQueued) { This->bDecommitQueued = FALSE; hr = S_OK; } else { if (!(This->hSemWaiting = CreateSemaphoreW(NULL, This->pProps->cBuffers, This->pProps->cBuffers, NULL))) { ERR("Couldn't create semaphore (error was %ld)\n", GetLastError()); hr = HRESULT_FROM_WIN32(GetLastError()); } else { hr = This->fnAlloc(iface); if (SUCCEEDED(hr)) This->bCommitted = TRUE; else ERR("fnAlloc failed with error 0x%lx\n", hr); } } } LeaveCriticalSection(&This->csState); return hr; }