[vlc-devel] [PATCH 09/23] dxva2: move the device check in dxva since it's the only one that supports it

Steve Lhomme robux4 at videolabs.io
Wed Jun 21 14:14:54 CEST 2017


---
 modules/codec/avcodec/d3d11va.c             | 19 ------------------
 modules/codec/avcodec/dxva2.c               | 31 ++++++++++++-----------------
 modules/codec/avcodec/va_surface.c          |  4 ----
 modules/codec/avcodec/va_surface_internal.h |  5 -----
 4 files changed, 13 insertions(+), 46 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 5389584bc2..1623cfb331 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -183,24 +183,6 @@ static int Extract(vlc_va_t *va, picture_t *output, uint8_t *data)
     return VLC_SUCCESS;
 }
 
-static int CheckDevice(vlc_va_t *va)
-{
-    VLC_UNUSED(va);
-#ifdef TODO
-    /* Check the device */
-    /* see MFCreateDXGIDeviceManager in mfplat.dll, not avail in Win7 */
-    HRESULT hr = IDirect3DDeviceManager9_TestDevice(sys->devmng, sys->device);
-    if (hr == DXVA2_E_NEW_VIDEO_DEVICE) {
-        if (DxResetVideoDecoder(va))
-            return VLC_EGENERIC;
-    } else if (FAILED(hr)) {
-        msg_Err(va, "IDirect3DDeviceManager9_TestDevice %u", (unsigned)hr);
-        return VLC_EGENERIC;
-    }
-#endif
-    return VLC_SUCCESS;
-}
-
 static void d3d11_pic_context_destroy(struct picture_context_t *opaque)
 {
     struct va_pic_context *pic_ctx = (struct va_pic_context*)opaque;
@@ -383,7 +365,6 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
 
     dx_sys = &sys->dx_sys;
 
-    dx_sys->va_pool.pf_check_device            = CheckDevice;
     dx_sys->va_pool.pf_create_device           = D3dCreateDevice;
     dx_sys->va_pool.pf_destroy_device          = D3dDestroyDevice;
     dx_sys->va_pool.pf_create_video_service    = DxCreateVideoService;
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 6b431a924a..7795ec5f41 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -182,22 +182,6 @@ static int Extract(vlc_va_t *va, picture_t *picture, uint8_t *data)
     return VLC_SUCCESS;
 }
 
-static int CheckDevice(vlc_va_t *va)
-{
-    vlc_va_sys_t *sys = va->sys;
-
-    /* Check the device */
-    HRESULT hr = IDirect3DDeviceManager9_TestDevice(sys->devmng, sys->device);
-    if (hr == DXVA2_E_NEW_VIDEO_DEVICE) {
-        if (DxResetVideoDecoder(va))
-            return VLC_EGENERIC;
-    } else if (FAILED(hr)) {
-        msg_Err(va, "IDirect3DDeviceManager9_TestDevice %u", (unsigned)hr);
-        return VLC_EGENERIC;
-    }
-    return VLC_SUCCESS;
-}
-
 static void d3d9_pic_context_destroy(struct picture_context_t *opaque)
 {
     struct va_pic_context *pic_ctx = (struct va_pic_context*)opaque;
@@ -233,7 +217,19 @@ static struct picture_context_t *CreatePicContext(vlc_va_surface_t *va_surface)
 
 static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
 {
-    vlc_va_surface_t *va_surface = va_pool_Get(va, &va->sys->dx_sys.va_pool);
+    vlc_va_sys_t *sys = va->sys;
+
+    /* Check the device */
+    HRESULT hr = IDirect3DDeviceManager9_TestDevice(sys->devmng, sys->device);
+    if (hr == DXVA2_E_NEW_VIDEO_DEVICE) {
+        if (DxResetVideoDecoder(va))
+            return VLC_EGENERIC;
+    } else if (FAILED(hr)) {
+        msg_Err(va, "IDirect3DDeviceManager9_TestDevice %u", (unsigned)hr);
+        return VLC_EGENERIC;
+    }
+
+    vlc_va_surface_t *va_surface = va_pool_Get(va, &sys->dx_sys.va_pool);
     if (unlikely(va_surface==NULL))
         return VLC_EGENERIC;
     pic->context = CreatePicContext(va_surface);
@@ -304,7 +300,6 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
 
     dx_sys = &sys->dx_sys;
 
-    dx_sys->va_pool.pf_check_device            = CheckDevice;
     dx_sys->va_pool.pf_create_device           = D3dCreateDevice;
     dx_sys->va_pool.pf_destroy_device          = D3dDestroyDevice;
     dx_sys->va_pool.pf_create_device_manager   = D3dCreateDeviceManager;
diff --git a/modules/codec/avcodec/va_surface.c b/modules/codec/avcodec/va_surface.c
index 795f9690e0..ae893defbd 100644
--- a/modules/codec/avcodec/va_surface.c
+++ b/modules/codec/avcodec/va_surface.c
@@ -128,10 +128,6 @@ static vlc_va_surface_t *GetSurface(va_pool_t *va_pool)
 
 vlc_va_surface_t *va_pool_Get(vlc_va_t *va, va_pool_t *va_pool)
 {
-    /* Check the device */
-    if (va_pool->pf_check_device(va)!=VLC_SUCCESS)
-        return NULL;
-
     unsigned tries = (CLOCK_FREQ + VOUT_OUTMEM_SLEEP) / VOUT_OUTMEM_SLEEP;
     vlc_va_surface_t *field;
 
diff --git a/modules/codec/avcodec/va_surface_internal.h b/modules/codec/avcodec/va_surface_internal.h
index 0f41406df2..7ae3f36e7b 100644
--- a/modules/codec/avcodec/va_surface_internal.h
+++ b/modules/codec/avcodec/va_surface_internal.h
@@ -47,11 +47,6 @@ typedef struct
     vlc_va_surface_t    *surface[MAX_SURFACE_COUNT];
     D3D_DecoderSurface  *hw_surface[MAX_SURFACE_COUNT];
 
-    /**
-     * Check that the decoder device is still available
-     */
-    int (*pf_check_device)(vlc_va_t *);
-
     int (*pf_create_device)(vlc_va_t *);
     void (*pf_destroy_device)(vlc_va_t *);
 
-- 
2.12.1



More information about the vlc-devel mailing list