Commit 7f767bb1 authored by Damjan Jovanovic's avatar Damjan Jovanovic Committed by Alexandre Julliard

strmbase: Store and use the chosen IMemAllocator instead of getting it from the input pin.

parent c0d43fb5
......@@ -402,6 +402,9 @@ ULONG WINAPI BaseOutputPinImpl_Release(IPin * iface)
if (!refCount)
{
FreeMediaType(&This->pin.mtCurrent);
if (This->pAllocator)
IMemAllocator_Release(This->pAllocator);
This->pAllocator = NULL;
CoTaskMemFree(This);
return 0;
}
......@@ -584,18 +587,10 @@ HRESULT WINAPI BaseOutputPinImpl_GetDeliveryBuffer(BaseOutputPin *This, IMediaSa
hr = VFW_E_NOT_CONNECTED;
else
{
IMemAllocator * pAlloc = NULL;
hr = IMemInputPin_GetAllocator(This->pMemInputPin, &pAlloc);
if (SUCCEEDED(hr))
hr = IMemAllocator_GetBuffer(pAlloc, ppSample, tStart, tStop, dwFlags);
hr = IMemAllocator_GetBuffer(This->pAllocator, ppSample, tStart, tStop, dwFlags);
if (SUCCEEDED(hr))
hr = IMediaSample_SetTime(*ppSample, tStart, tStop);
if (pAlloc)
IMemAllocator_Release(pAlloc);
}
return hr;
......@@ -653,17 +648,7 @@ HRESULT WINAPI BaseOutputPinImpl_Active(BaseOutputPin *This)
if (!This->pin.pConnectedTo || !This->pMemInputPin)
hr = VFW_E_NOT_CONNECTED;
else
{
IMemAllocator * pAlloc = NULL;
hr = IMemInputPin_GetAllocator(This->pMemInputPin, &pAlloc);
if (SUCCEEDED(hr))
hr = IMemAllocator_Commit(pAlloc);
if (pAlloc)
IMemAllocator_Release(pAlloc);
}
hr = IMemAllocator_Commit(This->pAllocator);
}
LeaveCriticalSection(This->pin.pCritSec);
......@@ -683,17 +668,7 @@ HRESULT WINAPI BaseOutputPinImpl_Inactive(BaseOutputPin *This)
if (!This->pin.pConnectedTo || !This->pMemInputPin)
hr = VFW_E_NOT_CONNECTED;
else
{
IMemAllocator * pAlloc = NULL;
hr = IMemInputPin_GetAllocator(This->pMemInputPin, &pAlloc);
if (SUCCEEDED(hr))
hr = IMemAllocator_Decommit(pAlloc);
if (pAlloc)
IMemAllocator_Release(pAlloc);
}
hr = IMemAllocator_Decommit(This->pAllocator);
}
LeaveCriticalSection(This->pin.pCritSec);
......@@ -714,15 +689,7 @@ HRESULT WINAPI BaseOutputPinImpl_BreakConnect(BaseOutputPin *This)
hr = VFW_E_NOT_CONNECTED;
else
{
IMemAllocator * pAlloc = NULL;
hr = IMemInputPin_GetAllocator(This->pMemInputPin, &pAlloc);
if (SUCCEEDED(hr))
hr = IMemAllocator_Decommit(pAlloc);
if (pAlloc)
IMemAllocator_Release(pAlloc);
hr = IMemAllocator_Decommit(This->pAllocator);
if (SUCCEEDED(hr))
hr = IPin_Disconnect(This->pin.pConnectedTo);
......@@ -795,7 +762,9 @@ HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(BasePin* iface, IPin * pRecei
if (SUCCEEDED(hr))
{
hr = This->pFuncsTable->pfnDecideAllocator(This, This->pMemInputPin, &pMemAlloc);
if (pMemAlloc)
if (SUCCEEDED(hr))
This->pAllocator = pMemAlloc;
else if (pMemAlloc)
IMemAllocator_Release(pMemAlloc);
}
......@@ -839,6 +808,7 @@ static HRESULT OutputPin_Init(const IPinVtbl *OutputPin_Vtbl, const PIN_INFO * p
/* Output pin attributes */
pPinImpl->pMemInputPin = NULL;
pPinImpl->pAllocator = NULL;
pPinImpl->pFuncsTable = pBaseOutputFuncsTable;
return S_OK;
......
......@@ -61,6 +61,7 @@ typedef struct BaseOutputPin
/* inheritance C style! */
BasePin pin;
IMemInputPin * pMemInputPin;
IMemAllocator * pAllocator;
const struct BaseOutputPinFuncTable* pFuncsTable;
} BaseOutputPin;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment