[vlc-devel] [PATCH 32/39] directx_va: let the surface deal with releasing its memory

Steve Lhomme robux4 at videolabs.io
Fri Jun 2 16:46:35 CEST 2017


---
 modules/codec/avcodec/directx_va.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/modules/codec/avcodec/directx_va.c b/modules/codec/avcodec/directx_va.c
index cacc45fc6c..69de6cf296 100644
--- a/modules/codec/avcodec/directx_va.c
+++ b/modules/codec/avcodec/directx_va.c
@@ -371,7 +371,7 @@ void DestroyVideoDecoder(vlc_va_t *va, directx_sys_t *dx_sys)
     {
         if (dx_sys->surface[i]->p_pic)
             picture_Release(dx_sys->surface[i]->p_pic);
-        free(dx_sys->surface[i]);
+        directx_va_Release(dx_sys->surface[i]);
     }
 
     if (dx_sys->decoder)
@@ -424,7 +424,9 @@ void directx_va_AddRef(vlc_va_surface_t *surface)
 
 void directx_va_Release(vlc_va_surface_t *surface)
 {
-    atomic_fetch_sub(&surface->refcount, 1);
+    if (atomic_fetch_sub(&surface->refcount, 1) != 1)
+        return;
+    free(surface);
 }
 
 void directx_va_Close(vlc_va_t *va, directx_sys_t *dx_sys)
-- 
2.12.1



More information about the vlc-devel mailing list