[vlc-commits] d3d9: add a d3d9_device_t in the decoder device

Steve Lhomme git at videolan.org
Thu Nov 21 13:51:18 CET 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Nov 21 10:05:17 2019 +0100| [f457637dea962c66e6b7b9302e9fd00530b343b5] | committer: Steve Lhomme

d3d9: add a d3d9_device_t in the decoder device

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f457637dea962c66e6b7b9302e9fd00530b343b5
---

 modules/hw/d3d9/d3d9_device.c   | 25 +++++++++++++------------
 modules/video_chroma/d3d9_fmt.h |  1 +
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/modules/hw/d3d9/d3d9_device.c b/modules/hw/d3d9/d3d9_device.c
index 89bbce3984..5bc8e2373d 100644
--- a/modules/hw/d3d9/d3d9_device.c
+++ b/modules/hw/d3d9/d3d9_device.c
@@ -50,6 +50,7 @@ static void D3D9CloseDecoderDevice(vlc_decoder_device *device)
 {
     d3d9_decoder_device *sys = device->sys;
 
+    D3D9_ReleaseDevice( &sys->dec_device.d3ddev );
     D3D9_Destroy( &sys->dec_device.hd3d );
 
     if ( sys->cleanupDeviceCb )
@@ -67,6 +68,7 @@ int D3D9OpenDecoderDevice(vlc_decoder_device *device, vout_window_t *wnd)
     if (unlikely(sys==NULL))
         return VLC_ENOMEM;
 
+    int adapter;
     sys->cleanupDeviceCb = NULL;
     libvlc_video_direct3d_device_setup_cb setupDeviceCb = var_InheritAddress( device, "vout-cb-setup" );
     if ( setupDeviceCb )
@@ -86,7 +88,7 @@ int D3D9OpenDecoderDevice(vlc_decoder_device *device, vout_window_t *wnd)
         }
 
         D3D9_CloneExternal( &sys->dec_device.hd3d, (IDirect3D9*) out.device_context );
-        sys->dec_device.adapter = out.adapter;
+        adapter = out.adapter;
     }
     else
     {
@@ -96,20 +98,19 @@ int D3D9OpenDecoderDevice(vlc_decoder_device *device, vout_window_t *wnd)
             msg_Err( device, "Direct3D9 could not be initialized" );
             goto error;
         }
-
-        d3d9_device_t tmp_d3ddev;
         /* find the best adapter to use, not based on the HWND used */
-        HRESULT hr = D3D9_CreateDevice( device, &sys->dec_device.hd3d, -1, &tmp_d3ddev );
-        if ( FAILED(hr) )
-        {
-            D3D9_Destroy( &sys->dec_device.hd3d );
-            goto error;
-        }
-
-        sys->dec_device.adapter = tmp_d3ddev.adapterId;
+        adapter = -1;
+    }
 
-        D3D9_ReleaseDevice(&tmp_d3ddev);
+    HRESULT hr = D3D9_CreateDevice( device, &sys->dec_device.hd3d, adapter, &sys->dec_device.d3ddev );
+    if ( FAILED(hr) )
+    {
+        if ( sys->cleanupDeviceCb )
+            sys->cleanupDeviceCb( sys->opaque );
+        D3D9_Destroy( &sys->dec_device.hd3d );
+        goto error;
     }
+    sys->dec_device.adapter = sys->dec_device.d3ddev.adapterId;
 
     device->ops = &d3d9_dev_ops;
     device->opaque = &sys->dec_device;
diff --git a/modules/video_chroma/d3d9_fmt.h b/modules/video_chroma/d3d9_fmt.h
index bfcec0993f..35edc37114 100644
--- a/modules/video_chroma/d3d9_fmt.h
+++ b/modules/video_chroma/d3d9_fmt.h
@@ -73,6 +73,7 @@ typedef struct
 typedef struct
 {
     d3d9_handle_t  hd3d;
+    d3d9_device_t  d3ddev;
     int            adapter;
 } d3d9_decoder_device_t;
 



More information about the vlc-commits mailing list