[vlc-commits] directx_va: destroy the decoder at the same time as its surfaces

Steve Lhomme git at videolan.org
Tue Jun 13 15:02:18 CEST 2017


vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Fri Jun  2 11:00:12 2017 +0200| [bcaca1091f5a5aee840ef9d0077d0253c73ff59d] | committer: Jean-Baptiste Kempf

directx_va: destroy the decoder at the same time as its surfaces

The interface release is also strongly typed

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/codec/avcodec/d3d11va.c    | 5 +++++
 modules/codec/avcodec/directx_va.c | 4 ----
 modules/codec/avcodec/directx_va.h | 2 +-
 modules/codec/avcodec/dxva2.c      | 7 ++++++-
 4 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index d876db46cd..d2c6b52be9 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -1001,4 +1001,9 @@ static void DxDestroySurfaces(vlc_va_t *va)
                 ID3D11ShaderResourceView_Release(va->sys->resourceView[i*D3D11_MAX_SHADER_VIEW + j]);
         }
     }
+    if (dx_sys->decoder)
+    {
+        ID3D11VideoDecoder_Release(dx_sys->decoder);
+        dx_sys->decoder = NULL;
+    }
 }
diff --git a/modules/codec/avcodec/directx_va.c b/modules/codec/avcodec/directx_va.c
index 16700fbcd3..49112f6bdf 100644
--- a/modules/codec/avcodec/directx_va.c
+++ b/modules/codec/avcodec/directx_va.c
@@ -376,10 +376,6 @@ void DestroyVideoDecoder(vlc_va_t *va, directx_sys_t *dx_sys)
         directx_va_Release(dx_sys->surface[i]);
     }
 
-    if (dx_sys->decoder)
-        IUnknown_Release( dx_sys->decoder );
-
-    dx_sys->decoder = NULL;
     dx_sys->surface_count = 0;
 }
 
diff --git a/modules/codec/avcodec/directx_va.h b/modules/codec/avcodec/directx_va.h
index 73e3068f2c..65e53c78f7 100644
--- a/modules/codec/avcodec/directx_va.h
+++ b/modules/codec/avcodec/directx_va.h
@@ -113,7 +113,7 @@ typedef struct
     int (*pf_create_decoder_surfaces)(vlc_va_t *, int codec_id,
                                       const video_format_t *fmt);
     /**
-     * Destroy resources allocated with the surfaces except from hw_surface objects
+     * Destroy resources allocated with the surfaces and the associated decoder
      */
     void (*pf_destroy_surfaces)(vlc_va_t *);
     /**
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 4b2828ab0d..216eca9e0e 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -782,7 +782,12 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id, const video_format_t
 
 static void DxDestroyVideoDecoder(vlc_va_t *va)
 {
-    VLC_UNUSED(va);
+    directx_sys_t *dx_sys = &va->sys->dx_sys;
+    if (dx_sys->decoder)
+    {
+        IDirectXVideoDecoder_Release(dx_sys->decoder);
+        dx_sys->decoder = NULL;
+    }
 }
 
 static int DxResetVideoDecoder(vlc_va_t *va)



More information about the vlc-commits mailing list