strmbase: Remove non-standard custom allocator logic from strmbase.
Implement function overrides for parser.c where a custom allocator was needed.
diff --git a/dlls/qcap/vfwcapture.c b/dlls/qcap/vfwcapture.c
index a0d7ad7..1dc2e0f 100644
--- a/dlls/qcap/vfwcapture.c
+++ b/dlls/qcap/vfwcapture.c
@@ -698,7 +698,9 @@
};
static const BaseOutputPinFuncTable output_BaseOutputFuncTable = {
- VfwPin_DecideBufferSize
+ VfwPin_DecideBufferSize,
+ BaseOutputPinImpl_DecideAllocator,
+ BaseOutputPinImpl_BreakConnect
};
static HRESULT
diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c
index a985d9b..a05f605 100644
--- a/dlls/quartz/filesource.c
+++ b/dlls/quartz/filesource.c
@@ -838,7 +838,9 @@
};
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)
diff --git a/dlls/quartz/parser.c b/dlls/quartz/parser.c
index e5e12ac..1a2e7b3 100644
--- a/dlls/quartz/parser.c
+++ b/dlls/quartz/parser.c
@@ -45,6 +45,8 @@
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 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 @@
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 @@
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 @@
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 @@
/* 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);
diff --git a/dlls/quartz/parser.h b/dlls/quartz/parser.h
index 06ca757..1c210d0 100644
--- a/dlls/quartz/parser.h
+++ b/dlls/quartz/parser.h
@@ -46,6 +46,9 @@
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);
diff --git a/dlls/strmbase/pin.c b/dlls/strmbase/pin.c
index 96def2c..d985d6d 100644
--- a/dlls/strmbase/pin.c
+++ b/dlls/strmbase/pin.c
@@ -695,7 +695,7 @@
{
if (!This->pin.pConnectedTo || !This->pMemInputPin)
hr = VFW_E_NOT_CONNECTED;
- else if (!This->custom_allocator)
+ else
{
IMemAllocator * pAlloc = NULL;
@@ -710,10 +710,6 @@
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,35 +726,23 @@
{
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);
+
+ if (SUCCEEDED(hr))
{
- hr = IMemInputPin_GetAllocator(pPin, pAlloc);
+ ALLOCATOR_PROPERTIES rProps;
+ ZeroMemory(&rProps, sizeof(ALLOCATOR_PROPERTIES));
- if (hr == VFW_E_NO_ALLOCATOR)
- /* Input pin provides no allocator, use standard memory allocator */
- hr = BaseOutputPinImpl_InitAllocator(This, pAlloc);
-
- if (SUCCEEDED(hr))
- {
- ALLOCATOR_PROPERTIES rProps;
- ZeroMemory(&rProps, sizeof(ALLOCATOR_PROPERTIES));
-
- IMemInputPin_GetAllocatorRequirements(pPin, &rProps);
- hr = This->pFuncsTable->pfnDecideBufferSize(This, *pAlloc, &rProps);
- }
-
- if (SUCCEEDED(hr))
- hr = IMemInputPin_NotifyAllocator(pPin, *pAlloc, This->readonly);
+ IMemInputPin_GetAllocatorRequirements(pPin, &rProps);
+ hr = This->pFuncsTable->pfnDecideBufferSize(This, *pAlloc, &rProps);
}
- else
- {
- pAlloc = NULL;
- if (This->alloc)
- hr = IMemInputPin_NotifyAllocator(pPin, This->alloc, This->readonly);
- else
- hr = VFW_E_NO_ALLOCATOR;
- }
+ if (SUCCEEDED(hr))
+ hr = IMemInputPin_NotifyAllocator(pPin, *pAlloc, FALSE);
return hr;
}
@@ -793,7 +777,7 @@
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 @@
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;
}
diff --git a/dlls/strmbase/transform.c b/dlls/strmbase/transform.c
index fce543d..7a4cb84 100644
--- a/dlls/strmbase/transform.c
+++ b/dlls/strmbase/transform.c
@@ -162,7 +162,9 @@
};
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)
diff --git a/include/wine/strmbase.h b/include/wine/strmbase.h
index 3ca7d79..f6c2a67 100644
--- a/include/wine/strmbase.h
+++ b/include/wine/strmbase.h
@@ -57,20 +57,21 @@
{
/* 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