Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/evr.c | 55 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 18 deletions(-)
diff --git a/dlls/mf/evr.c b/dlls/mf/evr.c index 3479bade251..6c71741436b 100644 --- a/dlls/mf/evr.c +++ b/dlls/mf/evr.c @@ -169,18 +169,31 @@ static struct video_stream *impl_from_stream_IMFAttributes(IMFAttributes *iface) return CONTAINING_RECORD(iface, struct video_stream, IMFAttributes_iface); }
-static void video_renderer_release_services(struct video_renderer *renderer) +static HRESULT video_renderer_init_presenter_services(struct video_renderer *renderer) { IMFTopologyServiceLookupClient *lookup_client; + HRESULT hr;
- if (renderer->flags & EVR_MIXER_INITED_SERVICES && SUCCEEDED(IMFTransform_QueryInterface(renderer->mixer, - &IID_IMFTopologyServiceLookupClient, (void **)&lookup_client))) + if (SUCCEEDED(hr = IMFVideoPresenter_QueryInterface(renderer->presenter, &IID_IMFTopologyServiceLookupClient, + (void **)&lookup_client))) { - IMFTopologyServiceLookupClient_ReleaseServicePointers(lookup_client); + renderer->flags |= EVR_INIT_SERVICES; + if (SUCCEEDED(hr = IMFTopologyServiceLookupClient_InitServicePointers(lookup_client, + &renderer->IMFTopologyServiceLookup_iface))) + { + renderer->flags |= EVR_PRESENTER_INITED_SERVICES; + } + renderer->flags &= ~EVR_INIT_SERVICES; IMFTopologyServiceLookupClient_Release(lookup_client); - renderer->flags &= ~EVR_MIXER_INITED_SERVICES; }
+ return hr; +} + +static void video_renderer_release_presenter_services(struct video_renderer *renderer) +{ + IMFTopologyServiceLookupClient *lookup_client; + if (renderer->flags & EVR_PRESENTER_INITED_SERVICES && SUCCEEDED(IMFVideoPresenter_QueryInterface(renderer->presenter, &IID_IMFTopologyServiceLookupClient, (void **)&lookup_client))) { @@ -190,6 +203,21 @@ static void video_renderer_release_services(struct video_renderer *renderer) } }
+static void video_renderer_release_services(struct video_renderer *renderer) +{ + IMFTopologyServiceLookupClient *lookup_client; + + if (renderer->flags & EVR_MIXER_INITED_SERVICES && SUCCEEDED(IMFTransform_QueryInterface(renderer->mixer, + &IID_IMFTopologyServiceLookupClient, (void **)&lookup_client))) + { + IMFTopologyServiceLookupClient_ReleaseServicePointers(lookup_client); + IMFTopologyServiceLookupClient_Release(lookup_client); + renderer->flags &= ~EVR_MIXER_INITED_SERVICES; + } + + video_renderer_release_presenter_services(renderer); +} + static HRESULT WINAPI video_stream_sink_QueryInterface(IMFStreamSink *iface, REFIID riid, void **obj) { struct video_stream *stream = impl_from_IMFStreamSink(iface); @@ -1280,12 +1308,15 @@ static void video_renderer_set_presentation_clock(struct video_renderer *rendere IMFPresentationClock_RemoveClockStateSink(renderer->clock, &renderer->IMFClockStateSink_iface); IMFPresentationClock_Release(renderer->clock); } + video_renderer_release_presenter_services(renderer); + renderer->clock = clock; if (renderer->clock) { IMFPresentationClock_AddRef(renderer->clock); IMFPresentationClock_AddClockStateSink(renderer->clock, &renderer->IMFClockStateSink_iface); } + video_renderer_init_presenter_services(renderer); }
static HRESULT WINAPI video_renderer_sink_SetPresentationClock(IMFMediaSink *iface, IMFPresentationClock *clock) @@ -1579,7 +1610,6 @@ static HRESULT video_renderer_configure_mixer(struct video_renderer *renderer)
static HRESULT video_renderer_configure_presenter(struct video_renderer *renderer) { - IMFTopologyServiceLookupClient *lookup_client; IMFVideoDisplayControl *control; HRESULT hr;
@@ -1589,18 +1619,7 @@ static HRESULT video_renderer_configure_presenter(struct video_renderer *rendere IMFVideoDisplayControl_Release(control); }
- if (SUCCEEDED(hr = IMFVideoPresenter_QueryInterface(renderer->presenter, &IID_IMFTopologyServiceLookupClient, - (void **)&lookup_client))) - { - renderer->flags |= EVR_INIT_SERVICES; - if (SUCCEEDED(hr = IMFTopologyServiceLookupClient_InitServicePointers(lookup_client, - &renderer->IMFTopologyServiceLookup_iface))) - { - renderer->flags |= EVR_PRESENTER_INITED_SERVICES; - } - renderer->flags &= ~EVR_INIT_SERVICES; - IMFTopologyServiceLookupClient_Release(lookup_client); - } + hr = video_renderer_init_presenter_services(renderer);
if (FAILED(MFGetService((IUnknown *)renderer->presenter, &MR_VIDEO_ACCELERATION_SERVICE, &IID_IUnknown, (void **)&renderer->device_manager)))
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/evr.c | 7 +++++++ dlls/mf/tests/mf.c | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/dlls/mf/evr.c b/dlls/mf/evr.c index 6c71741436b..9cb6763da4e 100644 --- a/dlls/mf/evr.c +++ b/dlls/mf/evr.c @@ -2068,6 +2068,13 @@ static HRESULT WINAPI video_renderer_service_lookup_LookupService(IMFTopologySer *objects = &renderer->IMediaEventSink_iface; IUnknown_AddRef((IUnknown *)*objects); } + else if (IsEqualIID(riid, &IID_IMFClock)) + { + *objects = renderer->clock; + if (*objects) + IUnknown_AddRef((IUnknown *)*objects); + hr = *objects ? S_OK : E_NOINTERFACE; + } else { FIXME("Unsupported interface %s for render service.\n", debugstr_guid(riid)); diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index a5c306a93a0..bf482ae4c71 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -4212,9 +4212,11 @@ static void test_evr(void) IMFStreamSink *stream_sink, *stream_sink2; IMFVideoDisplayControl *display_control; IMFMediaType *media_type, *media_type2; + IMFPresentationTimeSource *time_source; IMFVideoSampleAllocator *allocator; IMFMediaTypeHandler *type_handler; IMFVideoRenderer *video_renderer; + IMFPresentationClock *clock; IMFMediaSink *sink, *sink2; IMFAttributes *attributes; DWORD flags, count, value; @@ -4228,8 +4230,8 @@ static void test_evr(void) HRESULT hr; GUID guid;
- hr = CoInitialize(NULL); - ok(hr == S_OK, "Failed to initialize, hr %#x.\n", hr); + hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); + ok(hr == S_OK, "Startup failure, hr %#x.\n", hr);
hr = MFCreateVideoRenderer(&IID_IMFVideoRenderer, (void **)&video_renderer); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); @@ -4481,7 +4483,35 @@ todo_wine
IMFActivate_Release(activate);
- CoUninitialize(); + /* Set clock. */ + window = create_window(); + + hr = MFCreateVideoRendererActivate(window, &activate); + ok(hr == S_OK, "Failed to create activate object, hr %#x.\n", hr); + + hr = IMFActivate_ActivateObject(activate, &IID_IMFMediaSink, (void **)&sink); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = MFCreateSystemTimeSource(&time_source); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = MFCreatePresentationClock(&clock); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMFPresentationClock_SetTimeSource(clock, time_source); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + IMFPresentationTimeSource_Release(time_source); + + hr = IMFMediaSink_SetPresentationClock(sink, clock); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + IMFPresentationClock_Release(clock); + + IMFActivate_Release(activate); + DestroyWindow(window); + + hr = MFShutdown(); + ok(hr == S_OK, "Shutdown failure, hr %#x.\n", hr); }
static void test_MFCreateSimpleTypeHandler(void)