Commit 60bf76db authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

strmbase: Remove non-standard custom allocator logic from strmbase.

Implement function overrides for parser.c where a custom allocator was needed.
parent 7602829c
......@@ -698,7 +698,9 @@ static const BasePinFuncTable output_BaseFuncTable = {
};
static const BaseOutputPinFuncTable output_BaseOutputFuncTable = {
VfwPin_DecideBufferSize
VfwPin_DecideBufferSize,
BaseOutputPinImpl_DecideAllocator,
BaseOutputPinImpl_BreakConnect
};
static HRESULT
......
......@@ -838,7 +838,9 @@ static const BasePinFuncTable output_BaseFuncTable = {
};
static const BaseOutputPinFuncTable output_BaseOutputFuncTable = {
FileAsyncReaderPin_DecideBufferSize
FileAsyncReaderPin_DecideBufferSize,
BaseOutputPinImpl_DecideAllocator,
BaseOutputPinImpl_BreakConnect
};
static HRESULT FileAsyncReader_Construct(HANDLE hFile, IBaseFilter * pBaseFilter, LPCRITICAL_SECTION pCritSec, IPin ** ppPin)
......
......@@ -45,6 +45,8 @@ static HRESULT WINAPI Parser_ChangeStop(IMediaSeeking *iface);
static HRESULT WINAPI Parser_ChangeRate(IMediaSeeking *iface);
static HRESULT WINAPI Parser_OutputPin_DecideBufferSize(BaseOutputPin *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest);
static HRESULT WINAPI Parser_OutputPin_GetMediaType(BasePin *iface, int iPosition, AM_MEDIA_TYPE *pmt);
static HRESULT WINAPI Parser_OutputPin_DecideAllocator(BaseOutputPin *This, IMemInputPin *pPin, IMemAllocator **pAlloc);
static HRESULT WINAPI Parser_OutputPin_BreakConnect(BaseOutputPin *This);
static inline ParserImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
{
......@@ -416,7 +418,9 @@ static const BasePinFuncTable output_BaseFuncTable = {
};
static const BaseOutputPinFuncTable output_BaseOutputFuncTable = {
Parser_OutputPin_DecideBufferSize
Parser_OutputPin_DecideBufferSize,
Parser_OutputPin_DecideAllocator,
Parser_OutputPin_BreakConnect
};
HRESULT Parser_AddPin(ParserImpl * This, const PIN_INFO * piOutput, ALLOCATOR_PROPERTIES * props, const AM_MEDIA_TYPE * amt)
......@@ -440,7 +444,6 @@ HRESULT Parser_AddPin(ParserImpl * This, const PIN_INFO * piOutput, ALLOCATOR_PR
pin->dwSamplesProcessed = 0;
pin->pin.pin.pinInfo.pFilter = (LPVOID)This;
pin->pin.custom_allocator = 1;
pin->allocProps = *props;
This->cStreams++;
BaseFilterImpl_IncrementPinVersion((BaseFilter*)This);
......@@ -471,7 +474,7 @@ static HRESULT Parser_RemoveOutputPins(ParserImpl * This)
for (i = 0; i < This->cStreams; i++)
{
hr = BaseOutputPinImpl_BreakConnect((BaseOutputPin *)ppOldPins[i + 1]);
hr = ((BaseOutputPin *)ppOldPins[i + 1])->pFuncsTable->pfnBreakConnect((BaseOutputPin *)ppOldPins[i + 1]);
TRACE("Disconnect: %08x\n", hr);
IPin_Release(ppOldPins[i + 1]);
}
......@@ -575,6 +578,41 @@ static HRESULT WINAPI Parser_OutputPin_GetMediaType(BasePin *iface, int iPositio
return S_OK;
}
static HRESULT WINAPI Parser_OutputPin_DecideAllocator(BaseOutputPin *iface, IMemInputPin *pPin, IMemAllocator **pAlloc)
{
Parser_OutputPin *This = (Parser_OutputPin *)iface;
HRESULT hr;
pAlloc = NULL;
if (This->alloc)
hr = IMemInputPin_NotifyAllocator(pPin, This->alloc, This->readonly);
else
hr = VFW_E_NO_ALLOCATOR;
return hr;
}
static HRESULT WINAPI Parser_OutputPin_BreakConnect(BaseOutputPin *This)
{
HRESULT hr;
TRACE("(%p)->()\n", This);
EnterCriticalSection(This->pin.pCritSec);
if (!This->pin.pConnectedTo || !This->pMemInputPin)
hr = VFW_E_NOT_CONNECTED;
else
{
hr = IPin_Disconnect(This->pin.pConnectedTo);
IPin_Disconnect((IPin *)This);
}
LeaveCriticalSection(This->pin.pCritSec);
return hr;
}
static HRESULT WINAPI Parser_OutputPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
{
Parser_OutputPin *This = (Parser_OutputPin *)iface;
......@@ -628,7 +666,7 @@ static HRESULT WINAPI Parser_OutputPin_Connect(IPin * iface, IPin * pReceivePin,
/* Set the allocator to our input pin's */
EnterCriticalSection(This->pin.pin.pCritSec);
This->pin.alloc = parser->pInputPin->pAlloc;
This->alloc = parser->pInputPin->pAlloc;
LeaveCriticalSection(This->pin.pin.pCritSec);
return BaseOutputPinImpl_Connect(iface, pReceivePin, pmt);
......
......@@ -46,6 +46,9 @@ typedef struct Parser_OutputPin
AM_MEDIA_TYPE * pmt;
LONGLONG dwSamplesProcessed;
ALLOCATOR_PROPERTIES allocProps;
IMemAllocator *alloc;
BOOL readonly;
} Parser_OutputPin;
extern HRESULT Parser_AddPin(ParserImpl * This, const PIN_INFO * piOutput, ALLOCATOR_PROPERTIES * props, const AM_MEDIA_TYPE * amt);
......
......@@ -695,7 +695,7 @@ HRESULT WINAPI BaseOutputPinImpl_BreakConnect(BaseOutputPin *This)
{
if (!This->pin.pConnectedTo || !This->pMemInputPin)
hr = VFW_E_NOT_CONNECTED;
else if (!This->custom_allocator)
else
{
IMemAllocator * pAlloc = NULL;
......@@ -710,10 +710,6 @@ HRESULT WINAPI BaseOutputPinImpl_BreakConnect(BaseOutputPin *This)
if (SUCCEEDED(hr))
hr = IPin_Disconnect(This->pin.pConnectedTo);
}
else /* Kill the allocator! */
{
hr = IPin_Disconnect(This->pin.pConnectedTo);
}
IPin_Disconnect((IPin *)This);
}
LeaveCriticalSection(This->pin.pCritSec);
......@@ -730,36 +726,24 @@ HRESULT WINAPI BaseOutputPinImpl_DecideAllocator(BaseOutputPin *This, IMemInputP
{
HRESULT hr;
if (!This->custom_allocator)
{
hr = IMemInputPin_GetAllocator(pPin, pAlloc);
if (hr == VFW_E_NO_ALLOCATOR)
/* Input pin provides no allocator, use standard memory allocator */
hr = BaseOutputPinImpl_InitAllocator(This, pAlloc);
hr = IMemInputPin_GetAllocator(pPin, pAlloc);
if (SUCCEEDED(hr))
{
ALLOCATOR_PROPERTIES rProps;
ZeroMemory(&rProps, sizeof(ALLOCATOR_PROPERTIES));
IMemInputPin_GetAllocatorRequirements(pPin, &rProps);
hr = This->pFuncsTable->pfnDecideBufferSize(This, *pAlloc, &rProps);
}
if (hr == VFW_E_NO_ALLOCATOR)
/* Input pin provides no allocator, use standard memory allocator */
hr = BaseOutputPinImpl_InitAllocator(This, pAlloc);
if (SUCCEEDED(hr))
hr = IMemInputPin_NotifyAllocator(pPin, *pAlloc, This->readonly);
}
else
if (SUCCEEDED(hr))
{
pAlloc = NULL;
ALLOCATOR_PROPERTIES rProps;
ZeroMemory(&rProps, sizeof(ALLOCATOR_PROPERTIES));
if (This->alloc)
hr = IMemInputPin_NotifyAllocator(pPin, This->alloc, This->readonly);
else
hr = VFW_E_NO_ALLOCATOR;
IMemInputPin_GetAllocatorRequirements(pPin, &rProps);
hr = This->pFuncsTable->pfnDecideBufferSize(This, *pAlloc, &rProps);
}
if (SUCCEEDED(hr))
hr = IMemInputPin_NotifyAllocator(pPin, *pAlloc, FALSE);
return hr;
}
......@@ -793,7 +777,7 @@ HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(BasePin* iface, IPin * pRecei
if (SUCCEEDED(hr))
{
hr = BaseOutputPinImpl_DecideAllocator(This, This->pMemInputPin, &pMemAlloc);
hr = This->pFuncsTable->pfnDecideAllocator(This, This->pMemInputPin, &pMemAlloc);
if (pMemAlloc)
IMemAllocator_Release(pMemAlloc);
}
......@@ -837,13 +821,6 @@ static HRESULT OutputPin_Init(const IPinVtbl *OutputPin_Vtbl, const PIN_INFO * p
pPinImpl->pMemInputPin = NULL;
pPinImpl->pFuncsTable = pBaseOutputFuncsTable;
/* If custom_allocator is set, you will need to specify an allocator
* in the alloc member of the struct before an output pin can connect
*/
pPinImpl->custom_allocator = 0;
pPinImpl->alloc = NULL;
pPinImpl->readonly = FALSE;
return S_OK;
}
......
......@@ -162,7 +162,9 @@ static const BasePinFuncTable tf_output_BaseFuncTable = {
};
static const BaseOutputPinFuncTable tf_output_BaseOutputFuncTable = {
TransformFilter_Output_DecideBufferSize
TransformFilter_Output_DecideBufferSize,
BaseOutputPinImpl_DecideAllocator,
BaseOutputPinImpl_BreakConnect
};
static HRESULT TransformFilter_Init(const IBaseFilterVtbl *pVtbl, const CLSID* pClsid, const TransformFilterFuncTable* pFuncsTable, TransformFilter* pTransformFilter)
......
......@@ -57,20 +57,21 @@ typedef struct BaseOutputPin
{
/* inheritance C style! */
BasePin pin;
IMemInputPin * pMemInputPin;
BOOL custom_allocator;
IMemAllocator *alloc;
BOOL readonly;
const struct BaseOutputPinFuncTable* pFuncsTable;
} BaseOutputPin;
typedef HRESULT (WINAPI *BaseOutputPin_DecideBufferSize)(BaseOutputPin *This, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest);
typedef HRESULT (WINAPI *BaseOutputPin_DecideAllocator)(BaseOutputPin *This, IMemInputPin *pPin, IMemAllocator **pAlloc);
typedef HRESULT (WINAPI *BaseOutputPin_BreakConnect)(BaseOutputPin * This);
typedef struct BaseOutputPinFuncTable {
/* Required */
/* Required for BaseOutputPinImpl_DecideAllocator */
BaseOutputPin_DecideBufferSize pfnDecideBufferSize;
/* Required for BaseOutputPinImpl_AttemptConnection */
BaseOutputPin_DecideAllocator pfnDecideAllocator;
BaseOutputPin_BreakConnect pfnBreakConnect;
} BaseOutputPinFuncTable;
typedef struct BaseInputPin
......
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