evr/presenter: Add presented frames counter.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2021-11-03 18:21:07 +03:00 committed by Alexandre Julliard
parent 460ae3d82c
commit e16c9a8604
2 changed files with 52 additions and 2 deletions

View file

@ -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)

View file

@ -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);