From 603b00fe55139115c6ba4c302bae0d0c6f3150e2 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Tue, 10 Nov 2020 13:07:18 +0300 Subject: [PATCH] evr/presenter: Create sample allocator on object creation. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/evr/presenter.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/dlls/evr/presenter.c b/dlls/evr/presenter.c index 335e5df2459..2102882e084 100644 --- a/dlls/evr/presenter.c +++ b/dlls/evr/presenter.c @@ -70,6 +70,7 @@ struct video_presenter IMediaEventSink *event_sink; IDirect3DDeviceManager9 *device_manager; + IMFVideoSampleAllocator *allocator; struct streaming_thread thread; IMFMediaType *media_type; UINT reset_token; @@ -175,12 +176,13 @@ static void video_presenter_reset_media_type(struct video_presenter *presenter) IMFMediaType_Release(presenter->media_type); presenter->media_type = NULL; - /* FIXME: release samples pool */ + IMFVideoSampleAllocator_UninitializeSampleAllocator(presenter->allocator); } static HRESULT video_presenter_set_media_type(struct video_presenter *presenter, IMFMediaType *media_type) { unsigned int flags; + HRESULT hr; if (!media_type) { @@ -193,12 +195,15 @@ static HRESULT video_presenter_set_media_type(struct video_presenter *presenter, video_presenter_reset_media_type(presenter); - /* FIXME: allocate samples pool */ + if (SUCCEEDED(hr = IMFVideoSampleAllocator_InitializeSampleAllocator(presenter->allocator, 3, media_type))) + { + presenter->media_type = media_type; + IMFMediaType_AddRef(presenter->media_type); + } + else + WARN("Failed to initialize sample allocator, hr %#x.\n", hr); - presenter->media_type = media_type; - IMFMediaType_AddRef(presenter->media_type); - - return S_OK; + return hr; } static HRESULT video_presenter_invalidate_media_type(struct video_presenter *presenter) @@ -220,7 +225,9 @@ static HRESULT video_presenter_invalidate_media_type(struct video_presenter *pre if (SUCCEEDED(hr)) hr = video_presenter_set_media_type(presenter, media_type); - hr = IMFTransform_SetOutputType(presenter->mixer, 0, media_type, 0); + if (SUCCEEDED(hr)) + hr = IMFTransform_SetOutputType(presenter->mixer, 0, media_type, 0); + IMFMediaType_Release(media_type); if (SUCCEEDED(hr)) @@ -388,9 +395,12 @@ static ULONG WINAPI video_presenter_inner_Release(IUnknown *iface) { video_presenter_end_streaming(presenter); video_presenter_clear_container(presenter); + video_presenter_reset_media_type(presenter); DeleteCriticalSection(&presenter->cs); if (presenter->device_manager) IDirect3DDeviceManager9_Release(presenter->device_manager); + if (presenter->allocator) + IMFVideoSampleAllocator_Release(presenter->allocator); heap_free(presenter); } @@ -1179,6 +1189,11 @@ static HRESULT video_presenter_init_d3d(struct video_presenter *presenter) if (FAILED(hr)) WARN("Failed to set new device for the manager, hr %#x.\n", hr); + if (SUCCEEDED(hr = MFCreateVideoSampleAllocator(&IID_IMFVideoSampleAllocator, (void **)&presenter->allocator))) + { + hr = IMFVideoSampleAllocator_SetDirectXManager(presenter->allocator, (IUnknown *)presenter->device_manager); + } + return hr; }