Nikolay Sivov : evr/presenter: Add presented frames counter.
Alexandre Julliard
julliard at winehq.org
Wed Nov 3 16:42:02 CDT 2021
Module: wine
Branch: master
Commit: e16c9a86045adc1ede675d250e56bf13ad6893d0
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e16c9a86045adc1ede675d250e56bf13ad6893d0
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Wed Nov 3 18:21:07 2021 +0300
evr/presenter: Add presented frames counter.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/evr/presenter.c | 29 +++++++++++++++++++++++++++--
dlls/evr/tests/evr.c | 25 +++++++++++++++++++++++++
2 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/dlls/evr/presenter.c b/dlls/evr/presenter.c
index 9aef960dbb8..0381cb3e593 100644
--- a/dlls/evr/presenter.c
+++ b/dlls/evr/presenter.c
@@ -116,6 +116,12 @@ struct video_presenter
unsigned int ar_mode;
unsigned int state;
unsigned int flags;
+
+ struct
+ {
+ int presented;
+ } frame_stats;
+
CRITICAL_SECTION cs;
};
@@ -532,6 +538,7 @@ static void video_presenter_sample_present(struct video_presenter *presenter, IM
}
IDirect3DSwapChain9_Present(presenter->swapchain, &src, &dst, NULL, NULL, 0);
+ presenter->frame_stats.presented++;
IDirect3DDevice9_Release(device);
IDirect3DSurface9_Release(backbuffer);
@@ -934,6 +941,7 @@ static HRESULT WINAPI video_presenter_OnClockStop(IMFVideoPresenter *iface, MFTI
EnterCriticalSection(&presenter->cs);
presenter->state = PRESENTER_STATE_STOPPED;
+ presenter->frame_stats.presented = 0;
LeaveCriticalSection(&presenter->cs);
return S_OK;
@@ -1766,9 +1774,26 @@ static HRESULT WINAPI video_presenter_qualprop_get_FramesDroppedInRenderer(IQual
static HRESULT WINAPI video_presenter_qualprop_get_FramesDrawn(IQualProp *iface, int *frames)
{
- FIXME("%p, %p stub.\n", iface, frames);
+ struct video_presenter *presenter = impl_from_IQualProp(iface);
+ HRESULT hr = S_OK;
- return E_NOTIMPL;
+ TRACE("%p, %p.\n", iface, frames);
+
+ EnterCriticalSection(&presenter->cs);
+
+ switch (presenter->state)
+ {
+ case PRESENTER_STATE_STARTED:
+ case PRESENTER_STATE_PAUSED:
+ if (frames) *frames = presenter->frame_stats.presented;
+ else hr = E_POINTER;
+ default:
+ hr = E_NOTIMPL;
+ }
+
+ LeaveCriticalSection(&presenter->cs);
+
+ return hr;
}
static HRESULT WINAPI video_presenter_qualprop_get_AvgFrameRate(IQualProp *iface, int *avg_frame_rate)
diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c
index 48115388993..57b64937b79 100644
--- a/dlls/evr/tests/evr.c
+++ b/dlls/evr/tests/evr.c
@@ -2240,6 +2240,8 @@ static void test_presenter_quality_control(void)
MF_QUALITY_DROP_MODE mode;
IMFQualityAdvise *advise;
MF_QUALITY_LEVEL level;
+ IQualProp *qual_prop;
+ int frame_count;
HRESULT hr;
hr = MFCreateVideoPresenter(NULL, &IID_IDirect3DDevice9, &IID_IMFVideoPresenter, (void **)&presenter);
@@ -2293,6 +2295,17 @@ todo_wine {
IMFQualityAdvise_Release(advise);
+ hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IQualProp, (void **)&qual_prop);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IQualProp_get_FramesDrawn(qual_prop, NULL);
+ ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
+
+ hr = IQualProp_get_FramesDrawn(qual_prop, &frame_count);
+ ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
+
+ IQualProp_Release(qual_prop);
+
IMFVideoPresenter_Release(presenter);
}
@@ -2432,6 +2445,8 @@ static void test_presenter_shutdown(void)
IMFVideoPresenter *presenter;
IMFVideoDeviceID *deviceid;
HWND window, window2;
+ IQualProp *qual_prop;
+ int frame_count;
HRESULT hr;
DWORD mode;
RECT rect;
@@ -2453,6 +2468,9 @@ static void test_presenter_shutdown(void)
hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFVideoDisplayControl, (void **)&display_control);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IQualProp, (void **)&qual_prop);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
hr = IMFTopologyServiceLookupClient_ReleaseServicePointers(lookup_client);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
@@ -2505,9 +2523,16 @@ static void test_presenter_shutdown(void)
hr = IMFVideoDisplayControl_RepaintVideo(display_control);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
+ hr = IQualProp_get_FramesDrawn(qual_prop, NULL);
+ ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
+
+ hr = IQualProp_get_FramesDrawn(qual_prop, &frame_count);
+ ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
+
hr = IMFTopologyServiceLookupClient_ReleaseServicePointers(lookup_client);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ IQualProp_Release(qual_prop);
IMFVideoDeviceID_Release(deviceid);
IMFVideoDisplayControl_Release(display_control);
IMFTopologyServiceLookupClient_Release(lookup_client);
More information about the wine-cvs
mailing list