While it's certainly possible to use one event for both purposes, it's a little less clear, and it makes it a little more difficult to do other waits that need to be interrupted by flushing. For example, the video renderer should block in Receive() after rendering the sample until the filter is run.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/dsoundrender.c | 2 +- dlls/quartz/videorenderer.c | 2 +- dlls/strmbase/renderer.c | 20 ++++++++++++-------- include/wine/strmbase.h | 27 ++++++++++++++++----------- 4 files changed, 30 insertions(+), 21 deletions(-)
diff --git a/dlls/quartz/dsoundrender.c b/dlls/quartz/dsoundrender.c index a8068da61cd..f9fef51b562 100644 --- a/dlls/quartz/dsoundrender.c +++ b/dlls/quartz/dsoundrender.c @@ -735,7 +735,7 @@ static HRESULT WINAPI DSoundRender_Pause(IBaseFilter * iface) This->renderer.filter.state = State_Paused;
ResetEvent(This->blocked); - ResetEvent(This->renderer.RenderEvent); + ResetEvent(This->renderer.flush_event); } LeaveCriticalSection(&This->renderer.csRenderLock);
diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index e905be516e0..9a10fd275a0 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -679,7 +679,7 @@ static HRESULT WINAPI VideoRenderer_Pause(IBaseFilter * iface) VideoRenderer_AutoShowWindow(This); }
- ResetEvent(This->renderer.RenderEvent); + ResetEvent(This->renderer.flush_event); This->renderer.filter.state = State_Paused; } LeaveCriticalSection(&This->renderer.csRenderLock); diff --git a/dlls/strmbase/renderer.c b/dlls/strmbase/renderer.c index e5c3a1bbda8..11bfacb9dd4 100644 --- a/dlls/strmbase/renderer.c +++ b/dlls/strmbase/renderer.c @@ -281,7 +281,8 @@ HRESULT WINAPI strmbase_renderer_init(BaseRenderer *filter, const IBaseFilterVtb InitializeCriticalSection(&filter->csRenderLock); filter->csRenderLock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__": BaseRenderer.csRenderLock"); filter->state_event = CreateEventW(NULL, TRUE, TRUE, NULL); - filter->RenderEvent = CreateEventW(NULL, FALSE, FALSE, NULL); + filter->advise_event = CreateEventW(NULL, FALSE, FALSE, NULL); + filter->flush_event = CreateEventW(NULL, TRUE, TRUE, NULL); filter->pMediaSample = NULL;
QualityControlImpl_Create(&filter->sink.pin.IPin_iface, &filter->filter.IBaseFilter_iface, &filter->qcimpl); @@ -305,7 +306,8 @@ void strmbase_renderer_cleanup(BaseRenderer *filter)
BaseRendererImpl_ClearPendingSample(filter); CloseHandle(filter->state_event); - CloseHandle(filter->RenderEvent); + CloseHandle(filter->advise_event); + CloseHandle(filter->flush_event); QualityControlImpl_Destroy(filter->qcimpl); strmbase_filter_cleanup(&filter->filter); } @@ -380,12 +382,14 @@ HRESULT WINAPI BaseRendererImpl_Receive(BaseRenderer *This, IMediaSample * pSamp
if (now - This->filter.rtStreamStart - start <= -10000) { + HANDLE handles[2] = {This->advise_event, This->flush_event}; + IReferenceClock_AdviseTime(This->filter.pClock, This->filter.rtStreamStart, - start, (HEVENT)This->RenderEvent, &cookie); + start, (HEVENT)This->advise_event, &cookie);
LeaveCriticalSection(&This->csRenderLock);
- WaitForSingleObject(This->RenderEvent, INFINITE); + WaitForMultipleObjects(2, handles, FALSE, INFINITE); IReferenceClock_Unadvise(This->filter.pClock, cookie);
EnterCriticalSection(&This->csRenderLock); @@ -432,7 +436,7 @@ HRESULT WINAPI BaseRendererImpl_Stop(IBaseFilter * iface) This->pFuncsTable->pfnOnStopStreaming(This); This->filter.state = State_Stopped; SetEvent(This->state_event); - SetEvent(This->RenderEvent); + SetEvent(This->flush_event); } LeaveCriticalSection(&This->csRenderLock);
@@ -503,7 +507,7 @@ HRESULT WINAPI BaseRendererImpl_Pause(IBaseFilter * iface)
if (This->filter.state == State_Stopped) BaseRendererImpl_ClearPendingSample(This); - ResetEvent(This->RenderEvent); + ResetEvent(This->flush_event); This->filter.state = State_Paused; } } @@ -569,7 +573,7 @@ HRESULT WINAPI BaseRendererImpl_BeginFlush(BaseRenderer* iface) { TRACE("(%p)\n", iface); BaseRendererImpl_ClearPendingSample(iface); - SetEvent(iface->RenderEvent); + SetEvent(iface->flush_event); return S_OK; }
@@ -578,7 +582,7 @@ HRESULT WINAPI BaseRendererImpl_EndFlush(BaseRenderer* iface) TRACE("(%p)\n", iface); QualityControlRender_Start(iface->qcimpl, iface->filter.rtStreamStart); RendererPosPassThru_ResetMediaTime(iface->pPosition); - ResetEvent(iface->RenderEvent); + ResetEvent(iface->flush_event); return S_OK; }
diff --git a/include/wine/strmbase.h b/include/wine/strmbase.h index 28a973da1ff..a1cfb1f7b16 100644 --- a/include/wine/strmbase.h +++ b/include/wine/strmbase.h @@ -535,21 +535,26 @@ HRESULT WINAPI BaseControlVideo_Destroy(BaseControlVideo *pControlVideo); /* BaseRenderer Filter */ typedef struct BaseRendererTag { - BaseFilter filter; + BaseFilter filter;
- BaseInputPin sink; - IUnknown *pPosition; - CRITICAL_SECTION csRenderLock; + BaseInputPin sink; + IUnknown *pPosition; + CRITICAL_SECTION csRenderLock; /* Signaled when the filter has completed a state change. The filter waits * for this event in IBaseFilter::GetState(). */ - HANDLE state_event; - HANDLE RenderEvent; - IMediaSample *pMediaSample; - - IQualityControl *pQSink; - struct QualityControlImpl *qcimpl; + HANDLE state_event; + /* Signaled when the sample presentation time occurs. The streaming thread + * waits for this event in Receive() if applicable. */ + HANDLE advise_event; + /* Signaled when a flush or state change occurs, i.e. anything that needs + * to immediately unblock the streaming thread. */ + HANDLE flush_event; + IMediaSample *pMediaSample; + + IQualityControl *pQSink; + struct QualityControlImpl *qcimpl;
- const struct BaseRendererFuncTable * pFuncsTable; + const struct BaseRendererFuncTable *pFuncsTable; } BaseRenderer;
typedef HRESULT (WINAPI *BaseRenderer_CheckMediaType)(BaseRenderer *This, const AM_MEDIA_TYPE *pmt);