Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/systemclock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/quartz/systemclock.c b/dlls/quartz/systemclock.c index 6bb1f47e6f7..2b75c8da89e 100644 --- a/dlls/quartz/systemclock.c +++ b/dlls/quartz/systemclock.c @@ -103,9 +103,9 @@ static void notify_thread(struct system_clock *clock) { if (!InterlockedCompareExchange(&clock->thread_created, TRUE, FALSE)) { - clock->thread = CreateThread(NULL, 0, SystemClockAdviseThread, clock, 0, NULL); clock->notify_event = CreateEventW(NULL, FALSE, FALSE, NULL); clock->stop_event = CreateEventW(NULL, TRUE, FALSE, NULL); + clock->thread = CreateThread(NULL, 0, SystemClockAdviseThread, clock, 0, NULL); } SetEvent(clock->notify_event); }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/acmwrapper.c | 13 +-- dlls/quartz/avidec.c | 11 +- dlls/strmbase/transform.c | 172 +++++++++++-------------------- dlls/winegstreamer/gsttffilter.c | 4 +- dlls/wineqtdecoder/qtvdecoder.c | 4 +- include/wine/strmbase.h | 17 +-- 6 files changed, 78 insertions(+), 143 deletions(-)
diff --git a/dlls/quartz/acmwrapper.c b/dlls/quartz/acmwrapper.c index adfb0227d37..d1047a12aa2 100644 --- a/dlls/quartz/acmwrapper.c +++ b/dlls/quartz/acmwrapper.c @@ -59,7 +59,6 @@ static inline ACMWrapperImpl *impl_from_TransformFilter( TransformFilter *iface static HRESULT WINAPI ACMWrapper_Receive(TransformFilter *tf, IMediaSample *pSample) { ACMWrapperImpl* This = impl_from_TransformFilter(tf); - AM_MEDIA_TYPE amt; IMediaSample* pOutSample = NULL; DWORD cbDstStream, cbSrcStream; LPBYTE pbDstStream; @@ -103,20 +102,12 @@ static HRESULT WINAPI ACMWrapper_Receive(TransformFilter *tf, IMediaSample *pSam
TRACE("Sample data ptr = %p, size = %d\n", pbSrcStream, cbSrcStream);
- hr = IPin_ConnectionMediaType(This->tf.ppPins[0], &amt); - if (FAILED(hr)) - { - ERR("Unable to retrieve media type\n"); - LeaveCriticalSection(&This->tf.csReceive); - return hr; - } - ash.pbSrc = pbSrcStream; ash.cbSrcLength = cbSrcStream;
while(hr == S_OK && ash.cbSrcLength) { - hr = BaseOutputPinImpl_GetDeliveryBuffer((BaseOutputPin*)This->tf.ppPins[1], &pOutSample, NULL, NULL, 0); + hr = BaseOutputPinImpl_GetDeliveryBuffer(&This->tf.source, &pOutSample, NULL, NULL, 0); if (FAILED(hr)) { ERR("Unable to get delivery buffer (%x)\n", hr); @@ -216,7 +207,7 @@ static HRESULT WINAPI ACMWrapper_Receive(TransformFilter *tf, IMediaSample *pSam TRACE("Sample stop time: %u.%03u\n", (DWORD)(tStart/10000000), (DWORD)((tStart/10000)%1000));
LeaveCriticalSection(&This->tf.csReceive); - hr = BaseOutputPinImpl_Deliver((BaseOutputPin*)This->tf.ppPins[1], pOutSample); + hr = BaseOutputPinImpl_Deliver(&This->tf.source, pOutSample); EnterCriticalSection(&This->tf.csReceive);
if (hr != S_OK && hr != VFW_E_NOT_CONNECTED) { diff --git a/dlls/quartz/avidec.c b/dlls/quartz/avidec.c index 4aefd353d3b..c207b5f6cd2 100644 --- a/dlls/quartz/avidec.c +++ b/dlls/quartz/avidec.c @@ -105,7 +105,6 @@ static int AVIDec_DropSample(AVIDecImpl *This, REFERENCE_TIME tStart) { static HRESULT WINAPI AVIDec_Receive(TransformFilter *tf, IMediaSample *pSample) { AVIDecImpl* This = impl_from_TransformFilter(tf); - AM_MEDIA_TYPE amt; HRESULT hr; DWORD res; IMediaSample* pOutSample = NULL; @@ -128,16 +127,10 @@ static HRESULT WINAPI AVIDec_Receive(TransformFilter *tf, IMediaSample *pSample)
TRACE("Sample data ptr = %p, size = %d\n", pbSrcStream, cbSrcStream);
- hr = IPin_ConnectionMediaType(This->tf.ppPins[0], &amt); - if (FAILED(hr)) { - ERR("Unable to retrieve media type\n"); - goto error; - } - /* Update input size to match sample size */ This->pBihIn->biSizeImage = cbSrcStream;
- hr = BaseOutputPinImpl_GetDeliveryBuffer((BaseOutputPin*)This->tf.ppPins[1], &pOutSample, NULL, NULL, 0); + hr = BaseOutputPinImpl_GetDeliveryBuffer(&This->tf.source, &pOutSample, NULL, NULL, 0); if (FAILED(hr)) { ERR("Unable to get delivery buffer (%x)\n", hr); goto error; @@ -195,7 +188,7 @@ static HRESULT WINAPI AVIDec_Receive(TransformFilter *tf, IMediaSample *pSample) IMediaSample_SetMediaTime(pOutSample, NULL, NULL);
LeaveCriticalSection(&This->tf.csReceive); - hr = BaseOutputPinImpl_Deliver((BaseOutputPin*)This->tf.ppPins[1], pOutSample); + hr = BaseOutputPinImpl_Deliver(&This->tf.source, pOutSample); EnterCriticalSection(&This->tf.csReceive); if (hr != S_OK && hr != VFW_E_NOT_CONNECTED) ERR("Error sending sample (%x)\n", hr); diff --git a/dlls/strmbase/transform.c b/dlls/strmbase/transform.c index c4a07891b4c..39b601af4eb 100644 --- a/dlls/strmbase/transform.c +++ b/dlls/strmbase/transform.c @@ -30,21 +30,6 @@ static const IPinVtbl TransformFilter_InputPin_Vtbl; static const IPinVtbl TransformFilter_OutputPin_Vtbl; static const IQualityControlVtbl TransformFilter_QualityControl_Vtbl;
-static inline BaseInputPin *impl_BaseInputPin_from_BasePin( BasePin *iface ) -{ - return CONTAINING_RECORD(iface, BaseInputPin, pin); -} - -static inline BaseInputPin *impl_BaseInputPin_from_IPin( IPin *iface ) -{ - return CONTAINING_RECORD(iface, BaseInputPin, pin.IPin_iface); -} - -static inline BaseOutputPin *impl_BaseOutputPin_from_IPin( IPin *iface ) -{ - return CONTAINING_RECORD(iface, BaseOutputPin, pin.IPin_iface); -} - static inline TransformFilter *impl_from_IBaseFilter( IBaseFilter *iface ) { return CONTAINING_RECORD(iface, TransformFilter, filter.IBaseFilter_iface); @@ -55,13 +40,16 @@ static inline TransformFilter *impl_from_BaseFilter( BaseFilter *iface ) return CONTAINING_RECORD(iface, TransformFilter, filter); }
+static inline TransformFilter *impl_from_sink_IPin(IPin *iface) +{ + return CONTAINING_RECORD(iface, TransformFilter, sink.pin.IPin_iface); +} + static HRESULT WINAPI TransformFilter_Input_CheckMediaType(BasePin *iface, const AM_MEDIA_TYPE * pmt) { - BaseInputPin* This = impl_BaseInputPin_from_BasePin(iface); - TransformFilter * pTransform; + TransformFilter *pTransform = impl_from_sink_IPin(&iface->IPin_iface);
TRACE("%p\n", iface); - pTransform = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
if (pTransform->pFuncsTable->pfnCheckInputType) return pTransform->pFuncsTable->pfnCheckInputType(pTransform, pmt); @@ -72,10 +60,10 @@ static HRESULT WINAPI TransformFilter_Input_CheckMediaType(BasePin *iface, const
static HRESULT WINAPI TransformFilter_Input_Receive(BaseInputPin *This, IMediaSample *pInSample) { + TransformFilter *pTransform = impl_from_sink_IPin(&This->pin.IPin_iface); HRESULT hr; - TransformFilter * pTransform; + TRACE("%p\n", This); - pTransform = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
EnterCriticalSection(&pTransform->csReceive); if (pTransform->filter.state == State_Stopped) @@ -99,9 +87,14 @@ static HRESULT WINAPI TransformFilter_Input_Receive(BaseInputPin *This, IMediaSa return hr; }
+static inline TransformFilter *impl_from_source_IPin(IPin *iface) +{ + return CONTAINING_RECORD(iface, TransformFilter, source.pin.IPin_iface); +} + static HRESULT WINAPI TransformFilter_Output_CheckMediaType(BasePin *This, const AM_MEDIA_TYPE *pmt) { - TransformFilter *pTransformFilter = impl_from_IBaseFilter(This->pinInfo.pFilter); + TransformFilter *pTransformFilter = impl_from_source_IPin(&This->IPin_iface); AM_MEDIA_TYPE* outpmt = &pTransformFilter->pmt;
if (IsEqualIID(&pmt->majortype, &outpmt->majortype) @@ -112,13 +105,13 @@ static HRESULT WINAPI TransformFilter_Output_CheckMediaType(BasePin *This, const
static HRESULT WINAPI TransformFilter_Output_DecideBufferSize(BaseOutputPin *This, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest) { - TransformFilter *pTransformFilter = impl_from_IBaseFilter(This->pin.pinInfo.pFilter); + TransformFilter *pTransformFilter = impl_from_source_IPin(&This->pin.IPin_iface); return pTransformFilter->pFuncsTable->pfnDecideBufferSize(pTransformFilter, pAlloc, ppropInputRequest); }
static HRESULT WINAPI TransformFilter_Output_GetMediaType(BasePin *This, int iPosition, AM_MEDIA_TYPE *pmt) { - TransformFilter *pTransform = impl_from_IBaseFilter(This->pinInfo.pFilter); + TransformFilter *pTransform = impl_from_source_IPin(&This->IPin_iface);
if (iPosition < 0) return E_INVALIDARG; @@ -132,33 +125,27 @@ static IPin *transform_get_pin(BaseFilter *iface, unsigned int index) { TransformFilter *filter = impl_from_BaseFilter(iface);
- if (index >= 2) - return NULL; - - return filter->ppPins[index]; + if (index == 0) + return &filter->sink.pin.IPin_iface; + else if (index == 1) + return &filter->source.pin.IPin_iface; + return NULL; }
static void transform_destroy(BaseFilter *iface) { TransformFilter *filter = impl_from_BaseFilter(iface); - ULONG i; - - for (i = 0; i < 2; ++i) - { - IPin *peer;
- if (SUCCEEDED(IPin_ConnectedTo(filter->ppPins[i], &peer))) - { - IPin_Disconnect(peer); - IPin_Release(peer); - } - IPin_Disconnect(filter->ppPins[i]); - } + if (filter->sink.pin.pConnectedTo) + IPin_Disconnect(filter->sink.pin.pConnectedTo); + IPin_Disconnect(&filter->sink.pin.IPin_iface);
- BaseInputPin_Destroy(impl_BaseInputPin_from_IPin(filter->ppPins[0])); - BaseOutputPin_Destroy(impl_BaseOutputPin_from_IPin(filter->ppPins[1])); + if (filter->source.pin.pConnectedTo) + IPin_Disconnect(filter->source.pin.pConnectedTo); + IPin_Disconnect(&filter->source.pin.IPin_iface);
- CoTaskMemFree(filter->ppPins); + strmbase_sink_cleanup(&filter->sink); + strmbase_source_cleanup(&filter->source);
filter->csReceive.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&filter->csReceive); @@ -205,7 +192,7 @@ static HRESULT WINAPI TransformFilterImpl_Stop(IBaseFilter *iface) if (This->pFuncsTable->pfnStopStreaming) hr = This->pFuncsTable->pfnStopStreaming(This); if (SUCCEEDED(hr)) - hr = BaseOutputPinImpl_Inactive(impl_BaseOutputPin_from_IPin(This->ppPins[1])); + hr = BaseOutputPinImpl_Inactive(&This->source); } LeaveCriticalSection(&This->csReceive);
@@ -245,11 +232,11 @@ static HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter *iface, REFERENCE_TIME { if (This->filter.state == State_Stopped) { - impl_BaseInputPin_from_IPin(This->ppPins[0])->end_of_stream = FALSE; + This->sink.end_of_stream = FALSE; if (This->pFuncsTable->pfnStartStreaming) hr = This->pFuncsTable->pfnStartStreaming(This); if (SUCCEEDED(hr)) - hr = BaseOutputPinImpl_Active(impl_BaseOutputPin_from_IPin(This->ppPins[1])); + hr = BaseOutputPinImpl_Active(&This->source); }
if (SUCCEEDED(hr)) @@ -285,6 +272,7 @@ static const IBaseFilterVtbl transform_vtbl = static HRESULT strmbase_transform_init(IUnknown *outer, const CLSID *clsid, const TransformFilterFuncTable *func_table, TransformFilter *filter) { + ISeekingPassThru *passthru; HRESULT hr; PIN_INFO piInput; PIN_INFO piOutput; @@ -299,8 +287,6 @@ static HRESULT strmbase_transform_init(IUnknown *outer, const CLSID *clsid, filter->pFuncsTable = func_table; ZeroMemory(&filter->pmt, sizeof(filter->pmt));
- filter->ppPins = CoTaskMemAlloc(2 * sizeof(IPin *)); - /* construct input pin */ piInput.dir = PINDIR_INPUT; piInput.pFilter = &filter->filter.IBaseFilter_iface; @@ -309,41 +295,30 @@ static HRESULT strmbase_transform_init(IUnknown *outer, const CLSID *clsid, piOutput.pFilter = &filter->filter.IBaseFilter_iface; lstrcpynW(piOutput.achName, wcsOutputPinName, ARRAY_SIZE(piOutput.achName));
- hr = BaseInputPin_Construct(&TransformFilter_InputPin_Vtbl, sizeof(BaseInputPin), &piInput, - &tf_input_BaseInputFuncTable, &filter->filter.csFilter, NULL, &filter->ppPins[0]); + strmbase_sink_init(&filter->sink, &TransformFilter_InputPin_Vtbl, &piInput, + &tf_input_BaseInputFuncTable, &filter->filter.csFilter, NULL);
- if (SUCCEEDED(hr)) - { - hr = BaseOutputPin_Construct(&TransformFilter_OutputPin_Vtbl, sizeof(BaseOutputPin), - &piOutput, &tf_output_BaseOutputFuncTable, &filter->filter.csFilter, - &filter->ppPins[1]); - - if (FAILED(hr)) - ERR("Cannot create output pin (%x)\n", hr); - else { - QualityControlImpl_Create(filter->ppPins[0], - &filter->filter.IBaseFilter_iface, &filter->qcimpl); - filter->qcimpl->IQualityControl_iface.lpVtbl = &TransformFilter_QualityControl_Vtbl; - } - } + strmbase_source_init(&filter->source, &TransformFilter_OutputPin_Vtbl, + &piOutput, &tf_output_BaseOutputFuncTable, &filter->filter.csFilter);
+ QualityControlImpl_Create(&filter->sink.pin.IPin_iface, + &filter->filter.IBaseFilter_iface, &filter->qcimpl); + filter->qcimpl->IQualityControl_iface.lpVtbl = &TransformFilter_QualityControl_Vtbl; + + filter->seekthru_unk = NULL; + hr = CoCreateInstance(&CLSID_SeekingPassThru, (IUnknown *)&filter->filter.IBaseFilter_iface, + CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&filter->seekthru_unk); if (SUCCEEDED(hr)) { - ISeekingPassThru *passthru; - filter->seekthru_unk = NULL; - hr = CoCreateInstance(&CLSID_SeekingPassThru, (IUnknown *)&filter->filter.IBaseFilter_iface, - CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&filter->seekthru_unk); - if (SUCCEEDED(hr)) - { - IUnknown_QueryInterface(filter->seekthru_unk, &IID_ISeekingPassThru, (void **)&passthru); - ISeekingPassThru_Init(passthru, FALSE, filter->ppPins[0]); - ISeekingPassThru_Release(passthru); - } + IUnknown_QueryInterface(filter->seekthru_unk, &IID_ISeekingPassThru, (void **)&passthru); + ISeekingPassThru_Init(passthru, FALSE, &filter->sink.pin.IPin_iface); + ISeekingPassThru_Release(passthru); }
if (FAILED(hr)) { - CoTaskMemFree(filter->ppPins); + strmbase_sink_cleanup(&filter->sink); + strmbase_source_cleanup(&filter->source); strmbase_filter_cleanup(&filter->filter); }
@@ -383,40 +358,22 @@ HRESULT WINAPI TransformFilterImpl_Notify(TransformFilter *iface, IBaseFilter *s
static HRESULT WINAPI TransformFilter_InputPin_EndOfStream(IPin * iface) { - BaseInputPin* This = impl_BaseInputPin_from_IPin(iface); - TransformFilter* pTransform; - IPin* ppin; - HRESULT hr; + TransformFilter *filter = impl_from_sink_IPin(iface);
- TRACE("(%p)->()\n", iface); - - /* Since we process samples synchronously, just forward notification downstream */ - pTransform = impl_from_IBaseFilter(This->pin.pinInfo.pFilter); - if (!pTransform) - hr = E_FAIL; - else - hr = IPin_ConnectedTo(pTransform->ppPins[1], &ppin); - if (SUCCEEDED(hr)) - { - hr = IPin_EndOfStream(ppin); - IPin_Release(ppin); - } + TRACE("iface %p.\n", iface);
- if (FAILED(hr)) - ERR("%x\n", hr); - return hr; + if (filter->source.pin.pConnectedTo) + return IPin_EndOfStream(filter->source.pin.pConnectedTo); + return VFW_E_NOT_CONNECTED; }
static HRESULT WINAPI TransformFilter_InputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt) { - BaseInputPin* This = impl_BaseInputPin_from_IPin(iface); - TransformFilter* pTransform; + TransformFilter *pTransform = impl_from_sink_IPin(iface); HRESULT hr = S_OK;
TRACE("(%p)->(%p, %p)\n", iface, pReceivePin, pmt);
- pTransform = impl_from_IBaseFilter(This->pin.pinInfo.pFilter); - if (pTransform->pFuncsTable->pfnSetMediaType) hr = pTransform->pFuncsTable->pfnSetMediaType(pTransform, PINDIR_INPUT, pmt);
@@ -435,12 +392,10 @@ static HRESULT WINAPI TransformFilter_InputPin_ReceiveConnection(IPin * iface, I
static HRESULT WINAPI TransformFilter_InputPin_Disconnect(IPin * iface) { - BaseInputPin* This = impl_BaseInputPin_from_IPin(iface); - TransformFilter* pTransform; + TransformFilter *pTransform = impl_from_sink_IPin(iface);
TRACE("(%p)->()\n", iface);
- pTransform = impl_from_IBaseFilter(This->pin.pinInfo.pFilter); if (pTransform->pFuncsTable->pfnBreakConnect) pTransform->pFuncsTable->pfnBreakConnect(pTransform, PINDIR_INPUT);
@@ -449,13 +404,11 @@ static HRESULT WINAPI TransformFilter_InputPin_Disconnect(IPin * iface)
static HRESULT WINAPI TransformFilter_InputPin_BeginFlush(IPin * iface) { - BaseInputPin* This = impl_BaseInputPin_from_IPin(iface); - TransformFilter* pTransform; + TransformFilter *pTransform = impl_from_sink_IPin(iface); HRESULT hr = S_OK;
TRACE("(%p)->()\n", iface);
- pTransform = impl_from_IBaseFilter(This->pin.pinInfo.pFilter); EnterCriticalSection(&pTransform->filter.csFilter); if (pTransform->pFuncsTable->pfnBeginFlush) hr = pTransform->pFuncsTable->pfnBeginFlush(pTransform); @@ -467,13 +420,11 @@ static HRESULT WINAPI TransformFilter_InputPin_BeginFlush(IPin * iface)
static HRESULT WINAPI TransformFilter_InputPin_EndFlush(IPin * iface) { - BaseInputPin* This = impl_BaseInputPin_from_IPin(iface); - TransformFilter* pTransform; + TransformFilter *pTransform = impl_from_sink_IPin(iface); HRESULT hr = S_OK;
TRACE("(%p)->()\n", iface);
- pTransform = impl_from_IBaseFilter(This->pin.pinInfo.pFilter); EnterCriticalSection(&pTransform->filter.csFilter); if (pTransform->pFuncsTable->pfnEndFlush) hr = pTransform->pFuncsTable->pfnEndFlush(pTransform); @@ -485,13 +436,11 @@ static HRESULT WINAPI TransformFilter_InputPin_EndFlush(IPin * iface)
static HRESULT WINAPI TransformFilter_InputPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) { - BaseInputPin* This = impl_BaseInputPin_from_IPin(iface); - TransformFilter* pTransform; + TransformFilter *pTransform = impl_from_sink_IPin(iface); HRESULT hr = S_OK;
TRACE("(%p)->(%s %s %e)\n", iface, wine_dbgstr_longlong(tStart), wine_dbgstr_longlong(tStop), dRate);
- pTransform = impl_from_IBaseFilter(This->pin.pinInfo.pFilter); EnterCriticalSection(&pTransform->filter.csFilter); if (pTransform->pFuncsTable->pfnNewSegment) hr = pTransform->pFuncsTable->pfnNewSegment(pTransform, tStart, tStop, dRate); @@ -525,7 +474,8 @@ static const IPinVtbl TransformFilter_InputPin_Vtbl =
static HRESULT WINAPI transform_source_QueryInterface(IPin *iface, REFIID iid, void **out) { - TransformFilter *filter = impl_from_IBaseFilter(impl_BaseOutputPin_from_IPin(iface)->pin.pinInfo.pFilter); + TransformFilter *filter = impl_from_source_IPin(iface); + if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IPin)) *out = iface; else if (IsEqualGUID(iid, &IID_IQualityControl)) diff --git a/dlls/winegstreamer/gsttffilter.c b/dlls/winegstreamer/gsttffilter.c index 60697e51c88..1a40ec68568 100644 --- a/dlls/winegstreamer/gsttffilter.c +++ b/dlls/winegstreamer/gsttffilter.c @@ -168,7 +168,7 @@ GstFlowReturn got_data(GstPad *pad, GstObject *parent, GstBuffer *buf)
gst_buffer_map(buf, &info, GST_MAP_READ);
- hr = BaseOutputPinImpl_GetDeliveryBuffer((BaseOutputPin*)This->tf.ppPins[1], &sample, NULL, NULL, 0); + hr = BaseOutputPinImpl_GetDeliveryBuffer(&This->tf.source, &sample, NULL, NULL, 0); if (FAILED(hr)) { ERR("Could not get output buffer: %08x\n", hr); return GST_FLOW_FLUSHING; @@ -205,7 +205,7 @@ GstFlowReturn got_data(GstPad *pad, GstObject *parent, GstBuffer *buf) IMediaSample_SetSyncPoint(sample, !GST_BUFFER_FLAG_IS_SET(buf, GST_BUFFER_FLAG_DELTA_UNIT)); IMediaSample_SetActualDataLength(sample, gst_buffer_get_size(buf));
- hr = BaseOutputPinImpl_Deliver((BaseOutputPin*)This->tf.ppPins[1], sample); + hr = BaseOutputPinImpl_Deliver(&This->tf.source, sample); IMediaSample_Release(sample); gst_buffer_unref(buf); if (FAILED(hr)) diff --git a/dlls/wineqtdecoder/qtvdecoder.c b/dlls/wineqtdecoder/qtvdecoder.c index 57101d4ec41..8108133f978 100644 --- a/dlls/wineqtdecoder/qtvdecoder.c +++ b/dlls/wineqtdecoder/qtvdecoder.c @@ -185,7 +185,7 @@ static void trackingCallback( }
EnterCriticalSection(&This->tf.csReceive); - hr = BaseOutputPinImpl_GetDeliveryBuffer((BaseOutputPin*)This->tf.ppPins[1], &pOutSample, NULL, NULL, 0); + hr = BaseOutputPinImpl_GetDeliveryBuffer(&This->tf.source, &pOutSample, NULL, NULL, 0); if (FAILED(hr)) { ERR("Unable to get delivery buffer (%x)\n", hr); goto error; @@ -236,7 +236,7 @@ static void trackingCallback( }
LeaveCriticalSection(&This->tf.csReceive); - hr = BaseOutputPinImpl_Deliver((BaseOutputPin*)This->tf.ppPins[1], pOutSample); + hr = BaseOutputPinImpl_Deliver(&This->tf.source, pOutSample); EnterCriticalSection(&This->tf.csReceive); if (hr != S_OK && hr != VFW_E_NOT_CONNECTED) ERR("Error sending sample (%x)\n", hr); diff --git a/include/wine/strmbase.h b/include/wine/strmbase.h index c19bc6ca06c..9c60e4c1fd6 100644 --- a/include/wine/strmbase.h +++ b/include/wine/strmbase.h @@ -206,16 +206,17 @@ HRESULT WINAPI EnumMediaTypes_Construct(BasePin *iface, BasePin_GetMediaType enu /* Transform Filter */ typedef struct TransformFilter { - BaseFilter filter; + BaseFilter filter; + BaseOutputPin source; + BaseInputPin sink;
- IPin **ppPins; - AM_MEDIA_TYPE pmt; - CRITICAL_SECTION csReceive; + AM_MEDIA_TYPE pmt; + CRITICAL_SECTION csReceive;
- const struct TransformFilterFuncTable * pFuncsTable; - struct QualityControlImpl *qcimpl; - /* IMediaSeeking and IMediaPosition are implemented by ISeekingPassThru */ - IUnknown *seekthru_unk; + const struct TransformFilterFuncTable * pFuncsTable; + struct QualityControlImpl *qcimpl; + /* IMediaSeeking and IMediaPosition are implemented by ISeekingPassThru */ + IUnknown *seekthru_unk; } TransformFilter;
typedef HRESULT (WINAPI *TransformFilter_DecideBufferSize) (TransformFilter *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest);
The pin and filter locks are always equal.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/videorenderer.c | 2 -- dlls/strmbase/renderer.c | 6 ------ 2 files changed, 8 deletions(-)
diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index e4b50e28fa0..21e56b42b26 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -363,13 +363,11 @@ static HRESULT WINAPI VideoRenderer_EndFlush(BaseRenderer* iface)
if (This->renderer.pMediaSample) { ResetEvent(This->hEvent); - LeaveCriticalSection(iface->pInputPin->pin.pCritSec); LeaveCriticalSection(&iface->filter.csFilter); LeaveCriticalSection(&iface->csRenderLock); WaitForSingleObject(This->hEvent, INFINITE); EnterCriticalSection(&iface->csRenderLock); EnterCriticalSection(&iface->filter.csFilter); - EnterCriticalSection(iface->pInputPin->pin.pCritSec); } if (This->renderer.filter.state == State_Paused) { ResetEvent(This->hEvent); diff --git a/dlls/strmbase/renderer.c b/dlls/strmbase/renderer.c index b216166d716..38e1b6c0adb 100644 --- a/dlls/strmbase/renderer.c +++ b/dlls/strmbase/renderer.c @@ -97,7 +97,6 @@ static HRESULT WINAPI BaseRenderer_InputPin_EndOfStream(IPin * iface) EnterCriticalSection(&pFilter->csRenderLock); EnterCriticalSection(&pFilter->filter.csFilter); hr = BaseInputPinImpl_EndOfStream(iface); - EnterCriticalSection(This->pin.pCritSec); if (SUCCEEDED(hr)) { if (pFilter->pFuncsTable->pfnEndOfStream) @@ -105,7 +104,6 @@ static HRESULT WINAPI BaseRenderer_InputPin_EndOfStream(IPin * iface) else hr = BaseRendererImpl_EndOfStream(pFilter); } - LeaveCriticalSection(This->pin.pCritSec); LeaveCriticalSection(&pFilter->filter.csFilter); LeaveCriticalSection(&pFilter->csRenderLock); return hr; @@ -121,7 +119,6 @@ static HRESULT WINAPI BaseRenderer_InputPin_BeginFlush(IPin * iface)
EnterCriticalSection(&pFilter->csRenderLock); EnterCriticalSection(&pFilter->filter.csFilter); - EnterCriticalSection(This->pin.pCritSec); hr = BaseInputPinImpl_BeginFlush(iface); if (SUCCEEDED(hr)) { @@ -130,7 +127,6 @@ static HRESULT WINAPI BaseRenderer_InputPin_BeginFlush(IPin * iface) else hr = BaseRendererImpl_BeginFlush(pFilter); } - LeaveCriticalSection(This->pin.pCritSec); LeaveCriticalSection(&pFilter->filter.csFilter); LeaveCriticalSection(&pFilter->csRenderLock); return hr; @@ -146,7 +142,6 @@ static HRESULT WINAPI BaseRenderer_InputPin_EndFlush(IPin * iface)
EnterCriticalSection(&pFilter->csRenderLock); EnterCriticalSection(&pFilter->filter.csFilter); - EnterCriticalSection(This->pin.pCritSec); hr = BaseInputPinImpl_EndFlush(iface); if (SUCCEEDED(hr)) { @@ -155,7 +150,6 @@ static HRESULT WINAPI BaseRenderer_InputPin_EndFlush(IPin * iface) else hr = BaseRendererImpl_EndFlush(pFilter); } - LeaveCriticalSection(This->pin.pCritSec); LeaveCriticalSection(&pFilter->filter.csFilter); LeaveCriticalSection(&pFilter->csRenderLock); return hr;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/dsoundrender.c | 28 ++++--- dlls/quartz/videorenderer.c | 15 ++-- dlls/quartz/vmr9.c | 18 ++--- dlls/strmbase/renderer.c | 144 +++++++++++++++++------------------- include/wine/strmbase.h | 2 +- 5 files changed, 98 insertions(+), 109 deletions(-)
diff --git a/dlls/quartz/dsoundrender.c b/dlls/quartz/dsoundrender.c index 49de73fe3ce..78af8266267 100644 --- a/dlls/quartz/dsoundrender.c +++ b/dlls/quartz/dsoundrender.c @@ -99,14 +99,14 @@ static inline DSoundRenderImpl *impl_from_IAMDirectSound(IAMDirectSound *iface) }
static REFERENCE_TIME time_from_pos(DSoundRenderImpl *This, DWORD pos) { - WAVEFORMATEX *wfx = (WAVEFORMATEX*)This->renderer.pInputPin->pin.mtCurrent.pbFormat; + WAVEFORMATEX *wfx = (WAVEFORMATEX *)This->renderer.sink.pin.mtCurrent.pbFormat; REFERENCE_TIME ret = 10000000; ret = ret * pos / wfx->nAvgBytesPerSec; return ret; }
static DWORD pos_from_time(DSoundRenderImpl *This, REFERENCE_TIME time) { - WAVEFORMATEX *wfx = (WAVEFORMATEX*)This->renderer.pInputPin->pin.mtCurrent.pbFormat; + WAVEFORMATEX *wfx = (WAVEFORMATEX *)This->renderer.sink.pin.mtCurrent.pbFormat; REFERENCE_TIME ret = time; ret *= wfx->nAvgBytesPerSec; ret /= 10000000; @@ -115,7 +115,7 @@ static DWORD pos_from_time(DSoundRenderImpl *This, REFERENCE_TIME time) { }
static void DSoundRender_UpdatePositions(DSoundRenderImpl *This, DWORD *seqwritepos, DWORD *minwritepos) { - WAVEFORMATEX *wfx = (WAVEFORMATEX*)This->renderer.pInputPin->pin.mtCurrent.pbFormat; + WAVEFORMATEX *wfx = (WAVEFORMATEX *)This->renderer.sink.pin.mtCurrent.pbFormat; BYTE *buf1, *buf2; DWORD size1, size2, playpos, writepos, old_writepos, old_playpos, adv; BOOL writepos_set = This->writepos < This->buf_size; @@ -153,7 +153,7 @@ static void DSoundRender_UpdatePositions(DSoundRenderImpl *This, DWORD *seqwrite
static HRESULT DSoundRender_GetWritePos(DSoundRenderImpl *This, DWORD *ret_writepos, REFERENCE_TIME write_at, DWORD *pfree, DWORD *skip) { - WAVEFORMATEX *wfx = (WAVEFORMATEX*)This->renderer.pInputPin->pin.mtCurrent.pbFormat; + WAVEFORMATEX *wfx = (WAVEFORMATEX *)This->renderer.sink.pin.mtCurrent.pbFormat; DWORD writepos, min_writepos, playpos; REFERENCE_TIME max_lag = 50 * 10000; REFERENCE_TIME min_lag = 25 * 10000; @@ -273,10 +273,8 @@ static HRESULT DSoundRender_SendSampleData(DSoundRenderImpl* This, REFERENCE_TIM ret = WaitForSingleObject(This->blocked, 10); EnterCriticalSection(&This->renderer.csRenderLock); This->in_loop = 0; - if (This->renderer.pInputPin->flushing || - This->renderer.filter.state == State_Stopped) { + if (This->renderer.sink.flushing || This->renderer.filter.state == State_Stopped) return This->renderer.filter.state == State_Paused ? S_OK : VFW_E_WRONG_STATE; - } if (ret != WAIT_TIMEOUT) ERR("%x\n", ret); continue; @@ -322,7 +320,7 @@ static HRESULT WINAPI DSoundRender_PrepareReceive(BaseRenderer *iface, IMediaSam
if (IMediaSample_GetMediaType(pSample, &amt) == S_OK) { - AM_MEDIA_TYPE *orig = &This->renderer.pInputPin->pin.mtCurrent; + AM_MEDIA_TYPE *orig = &This->renderer.sink.pin.mtCurrent; WAVEFORMATEX *origfmt = (WAVEFORMATEX *)orig->pbFormat; WAVEFORMATEX *newfmt = (WAVEFORMATEX *)amt->pbFormat;
@@ -445,7 +443,7 @@ static VOID WINAPI DSoundRender_OnStartStreaming(BaseRenderer * iface)
TRACE("(%p)\n", This);
- if (This->renderer.pInputPin->pin.pConnectedTo) + if (This->renderer.sink.pin.pConnectedTo) { if (This->renderer.filter.state == State_Paused) { @@ -460,7 +458,7 @@ static VOID WINAPI DSoundRender_OnStartStreaming(BaseRenderer * iface) static HRESULT WINAPI DSoundRender_CompleteConnect(BaseRenderer * iface, IPin * pReceivePin) { DSoundRenderImpl *This = impl_from_BaseRenderer(iface); - const AM_MEDIA_TYPE * pmt = &This->renderer.pInputPin->pin.mtCurrent; + const AM_MEDIA_TYPE *pmt = &This->renderer.sink.pin.mtCurrent; HRESULT hr = S_OK; WAVEFORMATEX *format; DSBUFFERDESC buf_desc; @@ -519,9 +517,9 @@ static HRESULT WINAPI DSoundRender_BreakConnect(BaseRenderer* iface)
if (This->threadid) { PostThreadMessageW(This->threadid, WM_APP, 0, 0); - LeaveCriticalSection(This->renderer.pInputPin->pin.pCritSec); + LeaveCriticalSection(This->renderer.sink.pin.pCritSec); WaitForSingleObject(This->advisethread, INFINITE); - EnterCriticalSection(This->renderer.pInputPin->pin.pCritSec); + EnterCriticalSection(This->renderer.sink.pin.pCritSec); CloseHandle(This->advisethread); } if (This->dsbuffer) @@ -728,9 +726,9 @@ static HRESULT WINAPI DSoundRender_Pause(IBaseFilter * iface) { if (This->renderer.filter.state == State_Stopped) { - if (This->renderer.pInputPin->pin.pConnectedTo) + if (This->renderer.sink.pin.pConnectedTo) ResetEvent(This->renderer.evComplete); - This->renderer.pInputPin->end_of_stream = 0; + This->renderer.sink.end_of_stream = 0; }
hr = IDirectSoundBuffer_Stop(This->dsbuffer); @@ -1050,7 +1048,7 @@ static HRESULT WINAPI ReferenceClock_GetTime(IReferenceClock *iface, DWORD writepos1, writepos2; EnterCriticalSection(&This->renderer.filter.csFilter); DSoundRender_UpdatePositions(This, &writepos1, &writepos2); - if (This->renderer.pInputPin && This->renderer.pInputPin->pin.mtCurrent.pbFormat) + if (This->renderer.sink.pin.mtCurrent.pbFormat) { *pTime = This->play_time + time_from_pos(This, This->last_playpos); hr = S_OK; diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index 21e56b42b26..a64fffe7a00 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -201,7 +201,7 @@ static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data,
TRACE("(%p)->(%p, %d)\n", This, data, size);
- hr = IPin_ConnectionMediaType(&This->renderer.pInputPin->pin.IPin_iface, &amt); + hr = IPin_ConnectionMediaType(&This->renderer.sink.pin.IPin_iface, &amt); if (FAILED(hr)) { ERR("Unable to retrieve media type\n"); return hr; @@ -424,7 +424,8 @@ static VOID WINAPI VideoRenderer_OnStartStreaming(BaseRenderer* iface)
TRACE("(%p)\n", This);
- if (This->renderer.pInputPin->pin.pConnectedTo && (This->renderer.filter.state == State_Stopped || !This->renderer.pInputPin->end_of_stream)) + if (This->renderer.sink.pin.pConnectedTo + && (This->renderer.filter.state == State_Stopped || !This->renderer.sink.end_of_stream)) { if (This->renderer.filter.state == State_Stopped) { @@ -511,9 +512,9 @@ static HRESULT WINAPI VideoRenderer_GetSourceRect(BaseControlVideo* iface, RECT static HRESULT WINAPI VideoRenderer_GetStaticImage(BaseControlVideo* iface, LONG *pBufferSize, LONG *pDIBImage) { VideoRendererImpl *This = impl_from_BaseControlVideo(iface); + AM_MEDIA_TYPE *amt = &This->renderer.sink.pin.mtCurrent; BITMAPINFOHEADER *bmiHeader; LONG needed_size; - AM_MEDIA_TYPE *amt = &This->renderer.pInputPin->pin.mtCurrent; char *ptr;
FIXME("(%p/%p)->(%p, %p): partial stub\n", This, iface, pBufferSize, pDIBImage); @@ -581,7 +582,7 @@ static VIDEOINFOHEADER* WINAPI VideoRenderer_GetVideoFormat(BaseControlVideo* if
TRACE("(%p/%p)\n", This, iface);
- pmt = &This->renderer.pInputPin->pin.mtCurrent; + pmt = &This->renderer.sink.pin.mtCurrent; if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo)) { return (VIDEOINFOHEADER*)pmt->pbFormat; } else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2)) { @@ -674,7 +675,7 @@ static HRESULT WINAPI VideoRenderer_Pause(IBaseFilter * iface) { if (This->renderer.filter.state == State_Stopped) { - This->renderer.pInputPin->end_of_stream = 0; + This->renderer.sink.end_of_stream = 0; ResetEvent(This->hEvent); VideoRenderer_AutoShowWindow(This); } @@ -824,13 +825,13 @@ HRESULT VideoRenderer_create(IUnknown *outer, void **out)
hr = BaseControlWindow_Init(&pVideoRenderer->baseControlWindow, &IVideoWindow_VTable, &pVideoRenderer->renderer.filter, &pVideoRenderer->renderer.filter.csFilter, - &pVideoRenderer->renderer.pInputPin->pin, &renderer_BaseWindowFuncTable); + &pVideoRenderer->renderer.sink.pin, &renderer_BaseWindowFuncTable); if (FAILED(hr)) goto fail;
hr = strmbase_video_init(&pVideoRenderer->baseControlVideo, &pVideoRenderer->renderer.filter, &pVideoRenderer->renderer.filter.csFilter, - &pVideoRenderer->renderer.pInputPin->pin, &renderer_BaseControlVideoFuncTable); + &pVideoRenderer->renderer.sink.pin, &renderer_BaseControlVideoFuncTable); if (FAILED(hr)) goto fail;
diff --git a/dlls/quartz/vmr9.c b/dlls/quartz/vmr9.c index 845b1c4f76e..38c708b14e8 100644 --- a/dlls/quartz/vmr9.c +++ b/dlls/quartz/vmr9.c @@ -204,7 +204,7 @@ static DWORD VMR9_SendSampleData(struct quartz_vmr *This, VMR9PresentationInfo *
TRACE("%p %p %d\n", This, data, size);
- amt = &This->renderer.pInputPin->pin.mtCurrent; + amt = &This->renderer.sink.pin.mtCurrent;
if (IsEqualIID(&amt->formattype, &FORMAT_VideoInfo)) { @@ -381,7 +381,7 @@ static HRESULT VMR9_maybe_init(struct quartz_vmr *This, BOOL force) HRESULT hr;
TRACE("my mode: %u, my window: %p, my last window: %p\n", This->mode, This->baseControlWindow.baseWindow.hWnd, This->hWndClippingWindow); - if (This->baseControlWindow.baseWindow.hWnd || !This->renderer.pInputPin->pin.pConnectedTo) + if (This->baseControlWindow.baseWindow.hWnd || !This->renderer.sink.pin.pConnectedTo) return S_OK;
if (This->mode == VMR9Mode_Windowless && !This->hWndClippingWindow) @@ -486,7 +486,7 @@ static HRESULT WINAPI VMR9_BreakConnect(BaseRenderer *This)
if (!pVMR9->mode) return S_FALSE; - if (This->pInputPin->pin.pConnectedTo && pVMR9->allocator && pVMR9->presenter) + if (This->sink.pin.pConnectedTo && pVMR9->allocator && pVMR9->presenter) { if (pVMR9->renderer.filter.state != State_Stopped) { @@ -635,9 +635,9 @@ static HRESULT WINAPI VMR9_GetSourceRect(BaseControlVideo* This, RECT *pSourceRe static HRESULT WINAPI VMR9_GetStaticImage(BaseControlVideo* This, LONG *pBufferSize, LONG *pDIBImage) { struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This); + AM_MEDIA_TYPE *amt = &pVMR9->renderer.sink.pin.mtCurrent; BITMAPINFOHEADER *bmiHeader; LONG needed_size; - AM_MEDIA_TYPE *amt = &pVMR9->renderer.pInputPin->pin.mtCurrent; char *ptr;
FIXME("(%p/%p)->(%p, %p): partial stub\n", pVMR9, This, pBufferSize, pDIBImage); @@ -705,7 +705,7 @@ static VIDEOINFOHEADER* WINAPI VMR9_GetVideoFormat(BaseControlVideo* This)
TRACE("(%p/%p)\n", pVMR9, This);
- pmt = &pVMR9->renderer.pInputPin->pin.mtCurrent; + pmt = &pVMR9->renderer.sink.pin.mtCurrent; if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo)) { return (VIDEOINFOHEADER*)pmt->pbFormat; } else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2)) { @@ -2181,14 +2181,14 @@ static HRESULT vmr_create(IUnknown *outer, void **out, const CLSID *clsid) if (FAILED(hr)) goto fail;
- hr = BaseControlWindow_Init(&pVMR->baseControlWindow, &IVideoWindow_VTable, &pVMR->renderer.filter, - &pVMR->renderer.filter.csFilter, &pVMR->renderer.pInputPin->pin, - &renderer_BaseWindowFuncTable); + hr = BaseControlWindow_Init(&pVMR->baseControlWindow, &IVideoWindow_VTable, + &pVMR->renderer.filter, &pVMR->renderer.filter.csFilter, + &pVMR->renderer.sink.pin, &renderer_BaseWindowFuncTable); if (FAILED(hr)) goto fail;
hr = strmbase_video_init(&pVMR->baseControlVideo, &pVMR->renderer.filter, - &pVMR->renderer.filter.csFilter, &pVMR->renderer.pInputPin->pin, + &pVMR->renderer.filter.csFilter, &pVMR->renderer.sink.pin, &renderer_BaseControlVideoFuncTable); if (FAILED(hr)) goto fail; diff --git a/dlls/strmbase/renderer.c b/dlls/strmbase/renderer.c index 38e1b6c0adb..f7aaaef2891 100644 --- a/dlls/strmbase/renderer.c +++ b/dlls/strmbase/renderer.c @@ -22,11 +22,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(strmbase);
-static inline BaseInputPin *impl_BaseInputPin_from_IPin( IPin *iface ) -{ - return CONTAINING_RECORD(iface, BaseInputPin, pin.IPin_iface); -} - static inline BaseRenderer *impl_from_IBaseFilter(IBaseFilter *iface) { return CONTAINING_RECORD(iface, BaseRenderer, filter.IBaseFilter_iface); @@ -45,54 +40,56 @@ static const IQualityControlVtbl Renderer_QualityControl_Vtbl = { QualityControlImpl_SetSink };
-static HRESULT WINAPI BaseRenderer_InputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt) +static inline BaseRenderer *impl_from_IPin(IPin *iface) +{ + return CONTAINING_RECORD(iface, BaseRenderer, sink.pin.IPin_iface); +} + +static HRESULT WINAPI BaseRenderer_InputPin_ReceiveConnection(IPin *iface, IPin *peer, const AM_MEDIA_TYPE *mt) { - BaseInputPin *This = impl_BaseInputPin_from_IPin(iface); - BaseRenderer *renderer = impl_from_IBaseFilter(This->pin.pinInfo.pFilter); + BaseRenderer *filter = impl_from_IPin(iface); HRESULT hr;
- TRACE("(%p/%p)->(%p, %p)\n", This, renderer, pReceivePin, pmt); + TRACE("iface %p, peer %p, mt %p.\n", iface, peer, mt);
- EnterCriticalSection(This->pin.pCritSec); - hr = BaseInputPinImpl_ReceiveConnection(iface, pReceivePin, pmt); + EnterCriticalSection(filter->sink.pin.pCritSec); + hr = BaseInputPinImpl_ReceiveConnection(iface, peer, mt); if (SUCCEEDED(hr)) { - if (renderer->pFuncsTable->pfnCompleteConnect) - hr = renderer->pFuncsTable->pfnCompleteConnect(renderer, pReceivePin); + if (filter->pFuncsTable->pfnCompleteConnect) + hr = filter->pFuncsTable->pfnCompleteConnect(filter, peer); } - LeaveCriticalSection(This->pin.pCritSec); + LeaveCriticalSection(filter->sink.pin.pCritSec);
return hr; }
static HRESULT WINAPI BaseRenderer_InputPin_Disconnect(IPin * iface) { - BaseInputPin *This = impl_BaseInputPin_from_IPin(iface); - BaseRenderer *renderer = impl_from_IBaseFilter(This->pin.pinInfo.pFilter); + BaseRenderer *filter = impl_from_IPin(iface); HRESULT hr;
- TRACE("(%p/%p)\n", This, renderer); + TRACE("iface %p.\n", iface);
- EnterCriticalSection(This->pin.pCritSec); + EnterCriticalSection(filter->sink.pin.pCritSec); hr = BasePinImpl_Disconnect(iface); if (SUCCEEDED(hr)) { - if (renderer->pFuncsTable->pfnBreakConnect) - hr = renderer->pFuncsTable->pfnBreakConnect(renderer); + if (filter->pFuncsTable->pfnBreakConnect) + hr = filter->pFuncsTable->pfnBreakConnect(filter); } - BaseRendererImpl_ClearPendingSample(renderer); - LeaveCriticalSection(This->pin.pCritSec); + BaseRendererImpl_ClearPendingSample(filter); + LeaveCriticalSection(filter->sink.pin.pCritSec);
return hr; }
static HRESULT WINAPI BaseRenderer_InputPin_EndOfStream(IPin * iface) { + BaseRenderer *pFilter = impl_from_IPin(iface); HRESULT hr; - BaseInputPin* This = impl_BaseInputPin_from_IPin(iface); - BaseRenderer *pFilter = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
- TRACE("(%p/%p)->()\n", This, pFilter); + TRACE("iface %p.\n", iface);
EnterCriticalSection(&pFilter->csRenderLock); EnterCriticalSection(&pFilter->filter.csFilter); @@ -111,11 +108,10 @@ static HRESULT WINAPI BaseRenderer_InputPin_EndOfStream(IPin * iface)
static HRESULT WINAPI BaseRenderer_InputPin_BeginFlush(IPin * iface) { - BaseInputPin* This = impl_BaseInputPin_from_IPin(iface); - BaseRenderer *pFilter = impl_from_IBaseFilter(This->pin.pinInfo.pFilter); + BaseRenderer *pFilter = impl_from_IPin(iface); HRESULT hr;
- TRACE("(%p/%p)->()\n", This, iface); + TRACE("iface %p.\n", iface);
EnterCriticalSection(&pFilter->csRenderLock); EnterCriticalSection(&pFilter->filter.csFilter); @@ -134,11 +130,10 @@ static HRESULT WINAPI BaseRenderer_InputPin_BeginFlush(IPin * iface)
static HRESULT WINAPI BaseRenderer_InputPin_EndFlush(IPin * iface) { - BaseInputPin* This = impl_BaseInputPin_from_IPin(iface); - BaseRenderer *pFilter = impl_from_IBaseFilter(This->pin.pinInfo.pFilter); + BaseRenderer *pFilter = impl_from_IPin(iface); HRESULT hr;
- TRACE("(%p/%p)->()\n", This, pFilter); + TRACE("iface %p.\n", iface);
EnterCriticalSection(&pFilter->csRenderLock); EnterCriticalSection(&pFilter->filter.csFilter); @@ -179,12 +174,11 @@ static const IPinVtbl BaseRenderer_InputPin_Vtbl =
static IPin *renderer_get_pin(BaseFilter *iface, unsigned int index) { - BaseRenderer *This = impl_from_BaseFilter(iface); - - if (index >= 1) - return NULL; + BaseRenderer *filter = impl_from_BaseFilter(iface);
- return &This->pInputPin->pin.IPin_iface; + if (index == 0) + return &filter->sink.pin.IPin_iface; + return NULL; }
static void renderer_destroy(BaseFilter *iface) @@ -221,16 +215,16 @@ static const BaseFilterFuncTable RendererBaseFilterFuncTable = { .filter_query_interface = renderer_query_interface, };
-static HRESULT WINAPI BaseRenderer_Input_CheckMediaType(BasePin *pin, const AM_MEDIA_TYPE * pmt) +static HRESULT WINAPI BaseRenderer_Input_CheckMediaType(BasePin *pin, const AM_MEDIA_TYPE *mt) { - BaseRenderer *This = impl_from_IBaseFilter(pin->pinInfo.pFilter); - return This->pFuncsTable->pfnCheckMediaType(This, pmt); + BaseRenderer *filter = impl_from_IPin(&pin->IPin_iface); + return filter->pFuncsTable->pfnCheckMediaType(filter, mt); }
-static HRESULT WINAPI BaseRenderer_Receive(BaseInputPin *pin, IMediaSample * pSample) +static HRESULT WINAPI BaseRenderer_Receive(BaseInputPin *pin, IMediaSample *sample) { - BaseRenderer *This = impl_from_IBaseFilter(pin->pin.pinInfo.pFilter); - return BaseRendererImpl_Receive(This, pSample); + BaseRenderer *filter = impl_from_IPin(&pin->pin.IPin_iface); + return BaseRendererImpl_Receive(filter, sample); }
static const BaseInputPinFuncTable input_BaseInputFuncTable = { @@ -242,57 +236,53 @@ static const BaseInputPinFuncTable input_BaseInputFuncTable = { };
-HRESULT WINAPI strmbase_renderer_init(BaseRenderer *This, const IBaseFilterVtbl *vtbl, +HRESULT WINAPI strmbase_renderer_init(BaseRenderer *filter, const IBaseFilterVtbl *vtbl, IUnknown *outer, const CLSID *clsid, const WCHAR *sink_name, DWORD_PTR debug_info, const BaseRendererFuncTable *pBaseFuncsTable) { PIN_INFO piInput; HRESULT hr;
- strmbase_filter_init(&This->filter, vtbl, outer, clsid, debug_info, &RendererBaseFilterFuncTable); + strmbase_filter_init(&filter->filter, vtbl, outer, clsid, debug_info, &RendererBaseFilterFuncTable);
- This->pFuncsTable = pBaseFuncsTable; + filter->pFuncsTable = pBaseFuncsTable;
/* construct input pin */ piInput.dir = PINDIR_INPUT; - piInput.pFilter = &This->filter.IBaseFilter_iface; + piInput.pFilter = &filter->filter.IBaseFilter_iface; lstrcpynW(piInput.achName, sink_name, ARRAY_SIZE(piInput.achName));
- hr = BaseInputPin_Construct(&BaseRenderer_InputPin_Vtbl, sizeof(BaseInputPin), &piInput, - &input_BaseInputFuncTable, &This->filter.csFilter, NULL, (IPin **)&This->pInputPin); + strmbase_sink_init(&filter->sink, &BaseRenderer_InputPin_Vtbl, &piInput, + &input_BaseInputFuncTable, &filter->filter.csFilter, NULL);
- if (SUCCEEDED(hr)) + hr = CreatePosPassThru(outer ? outer : (IUnknown *)&filter->filter.IBaseFilter_iface, TRUE, + &filter->sink.pin.IPin_iface, &filter->pPosition); + if (FAILED(hr)) { - hr = CreatePosPassThru(outer ? outer : (IUnknown *)&This->filter.IBaseFilter_iface, TRUE, - &This->pInputPin->pin.IPin_iface, &This->pPosition); - if (FAILED(hr)) - return hr; + strmbase_sink_cleanup(&filter->sink); + strmbase_filter_cleanup(&filter->filter); + return hr; + }
- InitializeCriticalSection(&This->csRenderLock); - This->csRenderLock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__": BaseRenderer.csRenderLock"); - This->evComplete = CreateEventW(NULL, TRUE, TRUE, NULL); - This->ThreadSignal = CreateEventW(NULL, TRUE, TRUE, NULL); - This->RenderEvent = CreateEventW(NULL, FALSE, FALSE, NULL); - This->pMediaSample = NULL; + InitializeCriticalSection(&filter->csRenderLock); + filter->csRenderLock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__": BaseRenderer.csRenderLock"); + filter->evComplete = CreateEventW(NULL, TRUE, TRUE, NULL); + filter->ThreadSignal = CreateEventW(NULL, TRUE, TRUE, NULL); + filter->RenderEvent = CreateEventW(NULL, FALSE, FALSE, NULL); + filter->pMediaSample = NULL;
- QualityControlImpl_Create(&This->pInputPin->pin.IPin_iface, &This->filter.IBaseFilter_iface, &This->qcimpl); - This->qcimpl->IQualityControl_iface.lpVtbl = &Renderer_QualityControl_Vtbl; - } + QualityControlImpl_Create(&filter->sink.pin.IPin_iface, &filter->filter.IBaseFilter_iface, &filter->qcimpl); + filter->qcimpl->IQualityControl_iface.lpVtbl = &Renderer_QualityControl_Vtbl;
- return hr; + return S_OK; }
void strmbase_renderer_cleanup(BaseRenderer *filter) { - IPin *peer; - - if (SUCCEEDED(IPin_ConnectedTo(&filter->pInputPin->pin.IPin_iface, &peer))) - { - IPin_Disconnect(peer); - IPin_Release(peer); - } - IPin_Disconnect(&filter->pInputPin->pin.IPin_iface); - BaseInputPin_Destroy(filter->pInputPin); + if (filter->sink.pin.pConnectedTo) + IPin_Disconnect(filter->sink.pin.pConnectedTo); + IPin_Disconnect(&filter->sink.pin.IPin_iface); + strmbase_sink_cleanup(&filter->sink);
if (filter->pPosition) IUnknown_Release(filter->pPosition); @@ -316,7 +306,7 @@ HRESULT WINAPI BaseRendererImpl_Receive(BaseRenderer *This, IMediaSample * pSamp
TRACE("(%p)->%p\n", This, pSample);
- if (This->pInputPin->end_of_stream || This->pInputPin->flushing) + if (This->sink.end_of_stream || This->sink.flushing) return S_FALSE;
if (This->filter.state == State_Stopped) @@ -436,9 +426,9 @@ HRESULT WINAPI BaseRendererImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStart) SetEvent(This->evComplete); ResetEvent(This->ThreadSignal);
- if (This->pInputPin->pin.pConnectedTo) + if (This->sink.pin.pConnectedTo) { - This->pInputPin->end_of_stream = FALSE; + This->sink.end_of_stream = FALSE; } else if (This->filter.filterInfo.pGraph) { @@ -479,9 +469,9 @@ HRESULT WINAPI BaseRendererImpl_Pause(IBaseFilter * iface) { if (This->filter.state == State_Stopped) { - if (This->pInputPin->pin.pConnectedTo) + if (This->sink.pin.pConnectedTo) ResetEvent(This->evComplete); - This->pInputPin->end_of_stream = FALSE; + This->sink.end_of_stream = FALSE; } else if (This->pFuncsTable->pfnOnStopStreaming) This->pFuncsTable->pfnOnStopStreaming(This); diff --git a/include/wine/strmbase.h b/include/wine/strmbase.h index 9c60e4c1fd6..8de92b2826b 100644 --- a/include/wine/strmbase.h +++ b/include/wine/strmbase.h @@ -534,7 +534,7 @@ typedef struct BaseRendererTag { BaseFilter filter;
- BaseInputPin *pInputPin; + BaseInputPin sink; IUnknown *pPosition; CRITICAL_SECTION csRenderLock; HANDLE evComplete;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/filtergraph.c | 39 +++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-)
diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c index d89c9e25341..aec93926eba 100644 --- a/dlls/quartz/tests/filtergraph.c +++ b/dlls/quartz/tests/filtergraph.c @@ -1163,6 +1163,8 @@ struct testfilter struct testpin *pins; unsigned int pin_count, enum_idx;
+ HRESULT state_hr; + IAMFilterMiscFlags IAMFilterMiscFlags_iface; ULONG misc_flags;
@@ -1344,7 +1346,7 @@ static HRESULT WINAPI testfilter_Stop(IBaseFilter *iface) check_state_transition(filter, State_Stopped);
filter->state = State_Stopped; - return S_OK; + return filter->state_hr; }
static HRESULT WINAPI testfilter_Pause(IBaseFilter *iface) @@ -1355,7 +1357,7 @@ static HRESULT WINAPI testfilter_Pause(IBaseFilter *iface) check_state_transition(filter, State_Paused);
filter->state = State_Paused; - return S_OK; + return filter->state_hr; }
static HRESULT WINAPI testfilter_Run(IBaseFilter *iface, REFERENCE_TIME start) @@ -1367,7 +1369,7 @@ static HRESULT WINAPI testfilter_Run(IBaseFilter *iface, REFERENCE_TIME start)
filter->state = State_Running; filter->start_time = start; - return S_OK; + return filter->state_hr; }
static HRESULT WINAPI testfilter_GetState(IBaseFilter *iface, DWORD timeout, FILTER_STATE *state) @@ -1376,7 +1378,7 @@ static HRESULT WINAPI testfilter_GetState(IBaseFilter *iface, DWORD timeout, FIL if (winetest_debug > 1) trace("%p->GetState(%u)\n", filter, timeout);
*state = filter->state; - return S_OK; + return filter->state_hr; }
static HRESULT WINAPI testfilter_SetSyncSource(IBaseFilter *iface, IReferenceClock *clock) @@ -2954,6 +2956,7 @@ static void test_filter_state(void) IReferenceClock *clock; IMediaControl *control; IMediaFilter *filter; + OAFilterState state; HRESULT hr; ULONG ref;
@@ -3094,6 +3097,34 @@ todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); check_filter_state(graph, State_Stopped);
+ sink.state_hr = S_FALSE; + hr = IMediaControl_Pause(control); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + sink.state_hr = VFW_S_STATE_INTERMEDIATE; + hr = IMediaControl_GetState(control, 0, &state); + todo_wine ok(hr == VFW_S_STATE_INTERMEDIATE, "Got hr %#x.\n", hr); + ok(state == State_Paused, "Got state %u.\n", state); + + sink.state_hr = VFW_S_CANT_CUE; + hr = IMediaControl_GetState(control, 0, &state); + todo_wine ok(hr == VFW_S_CANT_CUE, "Got hr %#x.\n", hr); + ok(state == State_Paused, "Got state %u.\n", state); + + sink.state_hr = VFW_S_STATE_INTERMEDIATE; + source.state_hr = VFW_S_CANT_CUE; + hr = IMediaControl_GetState(control, 0, &state); + todo_wine ok(hr == VFW_S_CANT_CUE, "Got hr %#x.\n", hr); + ok(state == State_Paused, "Got state %u.\n", state); + + sink.state_hr = VFW_S_CANT_CUE; + source.state_hr = VFW_S_STATE_INTERMEDIATE; + hr = IMediaControl_GetState(control, 0, &state); + todo_wine ok(hr == VFW_S_CANT_CUE, "Got hr %#x.\n", hr); + ok(state == State_Paused, "Got state %u.\n", state); + + sink.state_hr = source.state_hr = S_OK; + /* Destroying the graph while it's running stops all filters. */
hr = IMediaFilter_Run(filter, 0);