Commit e4ebf09f authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

strmbase: Get rid of BaseRendererImpl_Receive().

parent db11d6dc
...@@ -169,7 +169,72 @@ static HRESULT sink_query_interface(struct strmbase_pin *iface, REFIID iid, void ...@@ -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) static HRESULT WINAPI BaseRenderer_Receive(struct strmbase_sink *pin, IMediaSample *sample)
{ {
struct strmbase_renderer *filter = impl_from_IPin(&pin->pin.IPin_iface); 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) 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) ...@@ -267,81 +332,6 @@ void strmbase_renderer_cleanup(struct strmbase_renderer *filter)
strmbase_filter_cleanup(&filter->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, void strmbase_renderer_init(struct strmbase_renderer *filter, IUnknown *outer,
const CLSID *clsid, const WCHAR *sink_name, const struct strmbase_renderer_ops *ops) const CLSID *clsid, const WCHAR *sink_name, const struct strmbase_renderer_ops *ops)
{ {
......
...@@ -334,8 +334,6 @@ struct strmbase_renderer_ops ...@@ -334,8 +334,6 @@ struct strmbase_renderer_ops
HRESULT (*renderer_pin_query_interface)(struct strmbase_renderer *iface, REFIID iid, void **out); 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, void strmbase_renderer_init(struct strmbase_renderer *filter, IUnknown *outer,
const CLSID *clsid, const WCHAR *sink_name, const struct strmbase_renderer_ops *ops); const CLSID *clsid, const WCHAR *sink_name, const struct strmbase_renderer_ops *ops);
void strmbase_renderer_cleanup(struct strmbase_renderer *filter); void strmbase_renderer_cleanup(struct strmbase_renderer *filter);
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