Nikolay Sivov : evr/presenter: Create sample allocator on object creation.

Alexandre Julliard julliard at winehq.org
Tue Nov 10 15:30:24 CST 2020


Module: wine
Branch: master
Commit: 603b00fe55139115c6ba4c302bae0d0c6f3150e2
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=603b00fe55139115c6ba4c302bae0d0c6f3150e2

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Tue Nov 10 13:07:18 2020 +0300

evr/presenter: Create sample allocator on object creation.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 */
-
-    presenter->media_type = media_type;
-    IMFMediaType_AddRef(presenter->media_type);
+    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);
 
-    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;
 }
 




More information about the wine-cvs mailing list