Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/strmbase/renderer.c | 142 ++++++++++++++++++--------------------- include/wine/strmbase.h | 2 - 2 files changed, 66 insertions(+), 78 deletions(-)
diff --git a/dlls/strmbase/renderer.c b/dlls/strmbase/renderer.c index 1f0a747a2ce..bc2d0551fe3 100644 --- a/dlls/strmbase/renderer.c +++ b/dlls/strmbase/renderer.c @@ -169,7 +169,72 @@ static HRESULT sink_query_interface(struct strmbase_pin *iface, REFIID iid, void static HRESULT WINAPI BaseRenderer_Receive(struct strmbase_sink *pin, IMediaSample *sample) { struct strmbase_renderer *filter = impl_from_IPin(&pin->pin.IPin_iface); - return BaseRendererImpl_Receive(filter, sample); + REFERENCE_TIME start, stop; + AM_MEDIA_TYPE *mt; + HRESULT hr; + + if (filter->eos || filter->sink.flushing) + return S_FALSE; + + if (filter->filter.state == State_Stopped) + return VFW_E_WRONG_STATE; + + if (IMediaSample_GetMediaType(sample, &mt) == S_OK) + { + TRACE("Format change.\n"); + strmbase_dump_media_type(mt); + + if (FAILED(filter->pFuncsTable->pfnCheckMediaType(filter, mt))) + return VFW_E_TYPE_NOT_ACCEPTED; + DeleteMediaType(mt); + } + + EnterCriticalSection(&filter->csRenderLock); + if (filter->filter.state == State_Paused) + SetEvent(filter->state_event); + + if (filter->filter.clock && SUCCEEDED(IMediaSample_GetTime(sample, &start, &stop))) + { + REFERENCE_TIME now; + DWORD_PTR cookie; + + strmbase_passthrough_update_time(&filter->passthrough, start); + + IReferenceClock_GetTime(filter->filter.clock, &now); + + if (now - filter->stream_start - start <= -10000) + { + HANDLE handles[2] = {filter->advise_event, filter->flush_event}; + DWORD ret; + + IReferenceClock_AdviseTime(filter->filter.clock, filter->stream_start, + start, (HEVENT)filter->advise_event, &cookie); + + LeaveCriticalSection(&filter->csRenderLock); + + ret = WaitForMultipleObjects(2, handles, FALSE, INFINITE); + IReferenceClock_Unadvise(filter->filter.clock, cookie); + + if (ret == 1) + { + TRACE("Flush signaled; discarding current sample.\n"); + return S_OK; + } + + EnterCriticalSection(&filter->csRenderLock); + } + } + else + start = stop = -1; + + QualityControlRender_BeginRender(&filter->qc, start, stop); + hr = filter->pFuncsTable->pfnDoRenderSample(filter, sample); + QualityControlRender_EndRender(&filter->qc); + QualityControlRender_DoQOS(&filter->qc); + + LeaveCriticalSection(&filter->csRenderLock); + + return hr; }
static HRESULT sink_connect(struct strmbase_sink *iface, IPin *peer, const AM_MEDIA_TYPE *mt) @@ -267,81 +332,6 @@ void strmbase_renderer_cleanup(struct strmbase_renderer *filter) strmbase_filter_cleanup(&filter->filter); }
-HRESULT WINAPI BaseRendererImpl_Receive(struct strmbase_renderer *This, IMediaSample *pSample) -{ - REFERENCE_TIME start, stop; - AM_MEDIA_TYPE *pmt; - HRESULT hr; - - TRACE("(%p)->%p\n", This, pSample); - - if (This->eos || This->sink.flushing) - return S_FALSE; - - if (This->filter.state == State_Stopped) - return VFW_E_WRONG_STATE; - - if (IMediaSample_GetMediaType(pSample, &pmt) == S_OK) - { - TRACE("Format change.\n"); - strmbase_dump_media_type(pmt); - - if (FAILED(This->pFuncsTable->pfnCheckMediaType(This, pmt))) - { - return VFW_E_TYPE_NOT_ACCEPTED; - } - DeleteMediaType(pmt); - } - - EnterCriticalSection(&This->csRenderLock); - if (This->filter.state == State_Paused) - SetEvent(This->state_event); - - /* Wait for render Time */ - if (This->filter.clock && SUCCEEDED(IMediaSample_GetTime(pSample, &start, &stop))) - { - REFERENCE_TIME now; - DWORD_PTR cookie; - - strmbase_passthrough_update_time(&This->passthrough, start); - - IReferenceClock_GetTime(This->filter.clock, &now); - - if (now - This->stream_start - start <= -10000) - { - HANDLE handles[2] = {This->advise_event, This->flush_event}; - DWORD ret; - - IReferenceClock_AdviseTime(This->filter.clock, This->stream_start, - start, (HEVENT)This->advise_event, &cookie); - - LeaveCriticalSection(&This->csRenderLock); - - ret = WaitForMultipleObjects(2, handles, FALSE, INFINITE); - IReferenceClock_Unadvise(This->filter.clock, cookie); - - if (ret == 1) - { - TRACE("Flush signaled, discarding current sample.\n"); - return S_OK; - } - - EnterCriticalSection(&This->csRenderLock); - } - } - else - start = stop = -1; - - QualityControlRender_BeginRender(&This->qc, start, stop); - hr = This->pFuncsTable->pfnDoRenderSample(This, pSample); - QualityControlRender_EndRender(&This->qc); - QualityControlRender_DoQOS(&This->qc); - - LeaveCriticalSection(&This->csRenderLock); - - return hr; -} - void strmbase_renderer_init(struct strmbase_renderer *filter, IUnknown *outer, const CLSID *clsid, const WCHAR *sink_name, const struct strmbase_renderer_ops *ops) { diff --git a/include/wine/strmbase.h b/include/wine/strmbase.h index 9e0d4e7d479..24bb97702b5 100644 --- a/include/wine/strmbase.h +++ b/include/wine/strmbase.h @@ -334,8 +334,6 @@ struct strmbase_renderer_ops HRESULT (*renderer_pin_query_interface)(struct strmbase_renderer *iface, REFIID iid, void **out); };
-HRESULT WINAPI BaseRendererImpl_Receive(struct strmbase_renderer *filter, IMediaSample *sample); - void strmbase_renderer_init(struct strmbase_renderer *filter, IUnknown *outer, const CLSID *clsid, const WCHAR *sink_name, const struct strmbase_renderer_ops *ops); void strmbase_renderer_cleanup(struct strmbase_renderer *filter);