[vlc-commits] directx_va: let the surface deal with releasing its memory

Steve Lhomme git at videolan.org
Tue Jun 13 15:01:20 CEST 2017


vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Mon May 29 16:02:50 2017 +0200| [839722ce9681ae1cd5b95a63581e6b81f9937f82] | committer: Jean-Baptiste Kempf

directx_va: let the surface deal with releasing its memory

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

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

 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 577f3c6eff..d239218fe6 100644
--- a/modules/codec/avcodec/directx_va.c
+++ b/modules/codec/avcodec/directx_va.c
@@ -377,7 +377,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)
@@ -430,7 +430,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)



More information about the vlc-commits mailing list