From a9fbbda429f28ba74de207b1bd2fd1ce32133bfb Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Fri, 17 Jul 2020 14:51:24 -0500 Subject: [PATCH] strmbase: Store the quality control object directly in strmbase_renderer. Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/strmbase/qualitycontrol.c | 22 +++++----------------- dlls/strmbase/renderer.c | 16 +++++++--------- dlls/strmbase/strmbase_private.h | 18 ------------------ include/wine/strmbase.h | 20 +++++++++++++++++--- 4 files changed, 29 insertions(+), 47 deletions(-) diff --git a/dlls/strmbase/qualitycontrol.c b/dlls/strmbase/qualitycontrol.c index c4e055858ef..d0bd070d447 100644 --- a/dlls/strmbase/qualitycontrol.c +++ b/dlls/strmbase/qualitycontrol.c @@ -27,11 +27,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(strmbase_qc); -void QualityControlImpl_Destroy(struct strmbase_qc *This) -{ - HeapFree(GetProcessHeap(),0,This); -} - static inline struct strmbase_qc *impl_from_IQualityControl(IQualityControl *iface) { return CONTAINING_RECORD(iface, struct strmbase_qc, IQualityControl_iface); @@ -313,17 +308,10 @@ void QualityControlRender_EndRender(struct strmbase_qc *This) This->avg_render = UPDATE_RUNNING_AVG (This->avg_render, elapsed); } -HRESULT QualityControlImpl_Create(struct strmbase_pin *pin, struct strmbase_qc **ppv) +void strmbase_qc_init(struct strmbase_qc *qc, struct strmbase_pin *pin) { - struct strmbase_qc *This; - *ppv = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(struct strmbase_qc)); - if (!*ppv) - return E_OUTOFMEMORY; - This = *ppv; - This->pin = pin; - This->tonotify = NULL; - This->current_rstart = This->current_rstop = -1; - This->IQualityControl_iface.lpVtbl = &quality_control_vtbl; - TRACE("-> %p\n", This); - return S_OK; + memset(qc, 0, sizeof(*qc)); + qc->pin = pin; + qc->current_rstart = qc->current_rstop = -1; + qc->IQualityControl_iface.lpVtbl = &quality_control_vtbl; } diff --git a/dlls/strmbase/renderer.c b/dlls/strmbase/renderer.c index 3895cb31194..939811bfa90 100644 --- a/dlls/strmbase/renderer.c +++ b/dlls/strmbase/renderer.c @@ -63,7 +63,7 @@ static HRESULT renderer_query_interface(struct strmbase_filter *iface, REFIID ii else if (IsEqualGUID(iid, &IID_IMediaSeeking)) *out = &filter->passthrough.IMediaSeeking_iface; else if (IsEqualGUID(iid, &IID_IQualityControl)) - *out = &filter->qcimpl->IQualityControl_iface; + *out = &filter->qc.IQualityControl_iface; else return E_NOINTERFACE; @@ -93,7 +93,7 @@ static HRESULT renderer_start_stream(struct strmbase_filter *iface, REFERENCE_TI SetEvent(filter->state_event); if (filter->sink.pin.peer) filter->eos = FALSE; - QualityControlRender_Start(filter->qcimpl, filter->stream_start); + QualityControlRender_Start(&filter->qc, filter->stream_start); if (filter->sink.pin.peer && filter->pFuncsTable->renderer_start_stream) filter->pFuncsTable->renderer_start_stream(filter); @@ -234,7 +234,7 @@ static HRESULT sink_end_flush(struct strmbase_sink *iface) EnterCriticalSection(&filter->csRenderLock); filter->eos = FALSE; - QualityControlRender_Start(filter->qcimpl, filter->stream_start); + QualityControlRender_Start(&filter->qc, filter->stream_start); strmbase_passthrough_invalidate_time(&filter->passthrough); ResetEvent(filter->flush_event); @@ -272,7 +272,6 @@ void strmbase_renderer_cleanup(struct strmbase_renderer *filter) CloseHandle(filter->state_event); CloseHandle(filter->advise_event); CloseHandle(filter->flush_event); - QualityControlImpl_Destroy(filter->qcimpl); strmbase_filter_cleanup(&filter->filter); } @@ -367,12 +366,12 @@ HRESULT WINAPI BaseRendererImpl_Receive(struct strmbase_renderer *This, IMediaSa if (SUCCEEDED(hr)) { - QualityControlRender_BeginRender(This->qcimpl, start, stop); + QualityControlRender_BeginRender(&This->qc, start, stop); hr = This->pFuncsTable->pfnDoRenderSample(This, pSample); - QualityControlRender_EndRender(This->qcimpl); + QualityControlRender_EndRender(&This->qc); } - QualityControlRender_DoQOS(This->qcimpl); + QualityControlRender_DoQOS(&This->qc); LeaveCriticalSection(&This->csRenderLock); @@ -386,6 +385,7 @@ void strmbase_renderer_init(struct strmbase_renderer *filter, IUnknown *outer, strmbase_filter_init(&filter->filter, outer, clsid, &filter_ops); strmbase_passthrough_init(&filter->passthrough, (IUnknown *)&filter->filter.IBaseFilter_iface); ISeekingPassThru_Init(&filter->passthrough.ISeekingPassThru_iface, TRUE, &filter->sink.pin.IPin_iface); + strmbase_qc_init(&filter->qc, &filter->sink.pin); filter->pFuncsTable = ops; @@ -396,6 +396,4 @@ void strmbase_renderer_init(struct strmbase_renderer *filter, IUnknown *outer, filter->state_event = CreateEventW(NULL, TRUE, TRUE, NULL); filter->advise_event = CreateEventW(NULL, FALSE, FALSE, NULL); filter->flush_event = CreateEventW(NULL, TRUE, TRUE, NULL); - - QualityControlImpl_Create(&filter->sink.pin, &filter->qcimpl); } diff --git a/dlls/strmbase/strmbase_private.h b/dlls/strmbase/strmbase_private.h index 15be9498e7d..d589213b713 100644 --- a/dlls/strmbase/strmbase_private.h +++ b/dlls/strmbase/strmbase_private.h @@ -53,24 +53,6 @@ static inline const char *debugstr_time(REFERENCE_TIME time) return wine_dbg_sprintf("%s", rev); } -/* Quality Control */ -struct strmbase_qc -{ - IQualityControl IQualityControl_iface; - struct strmbase_pin *pin; - IQualityControl *tonotify; - - /* Render stuff */ - REFERENCE_TIME last_in_time, last_left, avg_duration, avg_pt, avg_render, start, stop; - REFERENCE_TIME current_jitter, current_rstart, current_rstop, clockstart; - double avg_rate; - LONG64 rendered, dropped; - BOOL qos_handled, is_dropped; -}; - -HRESULT QualityControlImpl_Create(struct strmbase_pin *pin, struct strmbase_qc **out); -void QualityControlImpl_Destroy(struct strmbase_qc *qc); - void QualityControlRender_Start(struct strmbase_qc *This, REFERENCE_TIME tStart); void QualityControlRender_DoQOS(struct strmbase_qc *priv); void QualityControlRender_BeginRender(struct strmbase_qc *This, REFERENCE_TIME start, REFERENCE_TIME stop); diff --git a/include/wine/strmbase.h b/include/wine/strmbase.h index b0fa68ecf10..2e84edb7cdd 100644 --- a/include/wine/strmbase.h +++ b/include/wine/strmbase.h @@ -271,10 +271,27 @@ struct strmbase_passthrough void strmbase_passthrough_init(struct strmbase_passthrough *passthrough, IUnknown *outer); void strmbase_passthrough_cleanup(struct strmbase_passthrough *passthrough); +struct strmbase_qc +{ + IQualityControl IQualityControl_iface; + struct strmbase_pin *pin; + IQualityControl *tonotify; + + /* Render stuff */ + REFERENCE_TIME last_in_time, last_left, avg_duration, avg_pt, avg_render, start, stop; + REFERENCE_TIME current_jitter, current_rstart, current_rstop, clockstart; + double avg_rate; + LONG64 rendered, dropped; + BOOL qos_handled, is_dropped; +}; + +void strmbase_qc_init(struct strmbase_qc *qc, struct strmbase_pin *pin); + struct strmbase_renderer { struct strmbase_filter filter; struct strmbase_passthrough passthrough; + struct strmbase_qc qc; struct strmbase_sink sink; @@ -290,9 +307,6 @@ struct strmbase_renderer HANDLE flush_event; REFERENCE_TIME stream_start; - IQualityControl *pQSink; - struct strmbase_qc *qcimpl; - const struct strmbase_renderer_ops *pFuncsTable; BOOL eos;