Nikolay Sivov : evr/presenter: Validate mixer's device id.

Alexandre Julliard julliard at winehq.org
Mon Oct 5 15:54:59 CDT 2020


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Oct  5 15:26:40 2020 +0300

evr/presenter: Validate mixer's device id.

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

---

 dlls/evr/presenter.c | 55 ++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 43 insertions(+), 12 deletions(-)

diff --git a/dlls/evr/presenter.c b/dlls/evr/presenter.c
index 04e9a55684..4a7a4021c2 100644
--- a/dlls/evr/presenter.c
+++ b/dlls/evr/presenter.c
@@ -357,6 +357,41 @@ static ULONG WINAPI video_presenter_service_client_Release(IMFTopologyServiceLoo
     return IMFVideoPresenter_Release(&presenter->IMFVideoPresenter_iface);
 }
 
+static HRESULT video_presenter_attach_mixer(struct video_presenter *presenter, IMFTopologyServiceLookup *service_lookup)
+{
+    IMFVideoDeviceID *device_id;
+    unsigned int count;
+    GUID id = { 0 };
+    HRESULT hr;
+
+    count = 1;
+    if (FAILED(hr = IMFTopologyServiceLookup_LookupService(service_lookup, MF_SERVICE_LOOKUP_GLOBAL, 0,
+            &MR_VIDEO_MIXER_SERVICE, &IID_IMFTransform, (void **)&presenter->mixer, &count)))
+    {
+        WARN("Failed to get mixer interface, hr %#x.\n", hr);
+        return hr;
+    }
+
+    if (SUCCEEDED(hr = IMFTransform_QueryInterface(presenter->mixer, &IID_IMFVideoDeviceID, (void **)&device_id)))
+    {
+        if (SUCCEEDED(hr = IMFVideoDeviceID_GetDeviceID(device_id, &id)))
+        {
+            if (!IsEqualGUID(&id, &IID_IDirect3DDevice9))
+                hr = MF_E_INVALIDREQUEST;
+        }
+
+        IMFVideoDeviceID_Release(device_id);
+    }
+
+    if (FAILED(hr))
+    {
+        IMFTransform_Release(presenter->mixer);
+        presenter->mixer = NULL;
+    }
+
+    return hr;
+}
+
 static HRESULT WINAPI video_presenter_service_client_InitServicePointers(IMFTopologyServiceLookupClient *iface,
         IMFTopologyServiceLookup *service_lookup)
 {
@@ -384,20 +419,16 @@ static HRESULT WINAPI video_presenter_service_client_InitServicePointers(IMFTopo
         IMFTopologyServiceLookup_LookupService(service_lookup, MF_SERVICE_LOOKUP_GLOBAL, 0,
                 &MR_VIDEO_RENDER_SERVICE, &IID_IMFClock, (void **)&presenter->clock, &count);
 
-        count = 1;
-        if (SUCCEEDED(hr = IMFTopologyServiceLookup_LookupService(service_lookup, MF_SERVICE_LOOKUP_GLOBAL, 0,
-                &MR_VIDEO_MIXER_SERVICE, &IID_IMFTransform, (void **)&presenter->mixer, &count)))
-        {
-            /* FIXME: presumably should validate mixer's device id. */
-        }
-        else
-            WARN("Failed to get mixer interface, hr %#x.\n", hr);
+        hr = video_presenter_attach_mixer(presenter, service_lookup);
 
-        count = 1;
-        if (FAILED(hr = IMFTopologyServiceLookup_LookupService(service_lookup, MF_SERVICE_LOOKUP_GLOBAL, 0,
-                &MR_VIDEO_RENDER_SERVICE, &IID_IMediaEventSink, (void **)&presenter->event_sink, &count)))
+        if (SUCCEEDED(hr))
         {
-            WARN("Failed to get renderer event sink, hr %#x.\n", hr);
+            count = 1;
+            if (FAILED(hr = IMFTopologyServiceLookup_LookupService(service_lookup, MF_SERVICE_LOOKUP_GLOBAL, 0,
+                    &MR_VIDEO_RENDER_SERVICE, &IID_IMediaEventSink, (void **)&presenter->event_sink, &count)))
+            {
+                WARN("Failed to get renderer event sink, hr %#x.\n", hr);
+            }
         }
 
         if (SUCCEEDED(hr))




More information about the wine-cvs mailing list