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) ...@@ -402,6 +402,9 @@ ULONG WINAPI BaseOutputPinImpl_Release(IPin * iface)
if (!refCount) if (!refCount)
{ {
FreeMediaType(&This->pin.mtCurrent); FreeMediaType(&This->pin.mtCurrent);
if (This->pAllocator)
IMemAllocator_Release(This->pAllocator);
This->pAllocator = NULL;
CoTaskMemFree(This); CoTaskMemFree(This);
return 0; return 0;
} }
...@@ -584,18 +587,10 @@ HRESULT WINAPI BaseOutputPinImpl_GetDeliveryBuffer(BaseOutputPin *This, IMediaSa ...@@ -584,18 +587,10 @@ HRESULT WINAPI BaseOutputPinImpl_GetDeliveryBuffer(BaseOutputPin *This, IMediaSa
hr = VFW_E_NOT_CONNECTED; hr = VFW_E_NOT_CONNECTED;
else else
{ {
IMemAllocator * pAlloc = NULL; hr = IMemAllocator_GetBuffer(This->pAllocator, ppSample, tStart, tStop, dwFlags);
hr = IMemInputPin_GetAllocator(This->pMemInputPin, &pAlloc);
if (SUCCEEDED(hr))
hr = IMemAllocator_GetBuffer(pAlloc, ppSample, tStart, tStop, dwFlags);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = IMediaSample_SetTime(*ppSample, tStart, tStop); hr = IMediaSample_SetTime(*ppSample, tStart, tStop);
if (pAlloc)
IMemAllocator_Release(pAlloc);
} }
return hr; return hr;
...@@ -653,17 +648,7 @@ HRESULT WINAPI BaseOutputPinImpl_Active(BaseOutputPin *This) ...@@ -653,17 +648,7 @@ HRESULT WINAPI BaseOutputPinImpl_Active(BaseOutputPin *This)
if (!This->pin.pConnectedTo || !This->pMemInputPin) if (!This->pin.pConnectedTo || !This->pMemInputPin)
hr = VFW_E_NOT_CONNECTED; hr = VFW_E_NOT_CONNECTED;
else else
{ hr = IMemAllocator_Commit(This->pAllocator);
IMemAllocator * pAlloc = NULL;
hr = IMemInputPin_GetAllocator(This->pMemInputPin, &pAlloc);
if (SUCCEEDED(hr))
hr = IMemAllocator_Commit(pAlloc);
if (pAlloc)
IMemAllocator_Release(pAlloc);
}
} }
LeaveCriticalSection(This->pin.pCritSec); LeaveCriticalSection(This->pin.pCritSec);
...@@ -683,17 +668,7 @@ HRESULT WINAPI BaseOutputPinImpl_Inactive(BaseOutputPin *This) ...@@ -683,17 +668,7 @@ HRESULT WINAPI BaseOutputPinImpl_Inactive(BaseOutputPin *This)
if (!This->pin.pConnectedTo || !This->pMemInputPin) if (!This->pin.pConnectedTo || !This->pMemInputPin)
hr = VFW_E_NOT_CONNECTED; hr = VFW_E_NOT_CONNECTED;
else else
{ hr = IMemAllocator_Decommit(This->pAllocator);
IMemAllocator * pAlloc = NULL;
hr = IMemInputPin_GetAllocator(This->pMemInputPin, &pAlloc);
if (SUCCEEDED(hr))
hr = IMemAllocator_Decommit(pAlloc);
if (pAlloc)
IMemAllocator_Release(pAlloc);
}
} }
LeaveCriticalSection(This->pin.pCritSec); LeaveCriticalSection(This->pin.pCritSec);
...@@ -714,15 +689,7 @@ HRESULT WINAPI BaseOutputPinImpl_BreakConnect(BaseOutputPin *This) ...@@ -714,15 +689,7 @@ HRESULT WINAPI BaseOutputPinImpl_BreakConnect(BaseOutputPin *This)
hr = VFW_E_NOT_CONNECTED; hr = VFW_E_NOT_CONNECTED;
else else
{ {
IMemAllocator * pAlloc = NULL; hr = IMemAllocator_Decommit(This->pAllocator);
hr = IMemInputPin_GetAllocator(This->pMemInputPin, &pAlloc);
if (SUCCEEDED(hr))
hr = IMemAllocator_Decommit(pAlloc);
if (pAlloc)
IMemAllocator_Release(pAlloc);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = IPin_Disconnect(This->pin.pConnectedTo); hr = IPin_Disconnect(This->pin.pConnectedTo);
...@@ -795,7 +762,9 @@ HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(BasePin* iface, IPin * pRecei ...@@ -795,7 +762,9 @@ HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(BasePin* iface, IPin * pRecei
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
hr = This->pFuncsTable->pfnDecideAllocator(This, This->pMemInputPin, &pMemAlloc); hr = This->pFuncsTable->pfnDecideAllocator(This, This->pMemInputPin, &pMemAlloc);
if (pMemAlloc) if (SUCCEEDED(hr))
This->pAllocator = pMemAlloc;
else if (pMemAlloc)
IMemAllocator_Release(pMemAlloc); IMemAllocator_Release(pMemAlloc);
} }
...@@ -839,6 +808,7 @@ static HRESULT OutputPin_Init(const IPinVtbl *OutputPin_Vtbl, const PIN_INFO * p ...@@ -839,6 +808,7 @@ static HRESULT OutputPin_Init(const IPinVtbl *OutputPin_Vtbl, const PIN_INFO * p
/* Output pin attributes */ /* Output pin attributes */
pPinImpl->pMemInputPin = NULL; pPinImpl->pMemInputPin = NULL;
pPinImpl->pAllocator = NULL;
pPinImpl->pFuncsTable = pBaseOutputFuncsTable; pPinImpl->pFuncsTable = pBaseOutputFuncsTable;
return S_OK; return S_OK;
......
...@@ -61,6 +61,7 @@ typedef struct BaseOutputPin ...@@ -61,6 +61,7 @@ typedef struct BaseOutputPin
/* inheritance C style! */ /* inheritance C style! */
BasePin pin; BasePin pin;
IMemInputPin * pMemInputPin; IMemInputPin * pMemInputPin;
IMemAllocator * pAllocator;
const struct BaseOutputPinFuncTable* pFuncsTable; const struct BaseOutputPinFuncTable* pFuncsTable;
} BaseOutputPin; } 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