[Libva] [PATCH 2/9] Fix thread issue with AVC private surafce

yakui.zhao at intel.com yakui.zhao at intel.com
Wed Oct 31 01:47:52 PDT 2012


From: Gautam <manamgautam at gmail.com>

https://bugs.freedesktop.org/show_bug.cgi?id=55282

Signed-off-by: Gautam <manamgautam at gmail.com>
Signed-off-by: Xiang, Haihao <haihao.xiang at intel.com>
---
 src/i965_decoder.h | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/i965_decoder.h b/src/i965_decoder.h
index 5e66118..5de8085 100644
--- a/src/i965_decoder.h
+++ b/src/i965_decoder.h
@@ -47,6 +47,8 @@ struct gen_buffer {
 
 #if HAVE_GEN_AVC_SURFACE
 
+static pthread_mutex_t free_avc_surface_lock = PTHREAD_MUTEX_INITIALIZER;
+
 typedef struct gen_avc_surface GenAvcSurface;
 struct gen_avc_surface
 {
@@ -58,10 +60,17 @@ struct gen_avc_surface
 static void 
 gen_free_avc_surface(void **data)
 {
-    GenAvcSurface *avc_surface = *data;
+    GenAvcSurface *avc_surface;
+
+    pthread_mutex_lock(&free_avc_surface_lock);
+
+    avc_surface = *data;
 
-    if (!avc_surface)
+    if (!avc_surface) {
+        pthread_mutex_unlock(&free_avc_surface_lock);
         return;
+    }
+
 
     dri_bo_unreference(avc_surface->dmv_top);
     avc_surface->dmv_top = NULL;
@@ -70,6 +79,8 @@ gen_free_avc_surface(void **data)
 
     free(avc_surface);
     *data = NULL;
+
+    pthread_mutex_unlock(&free_avc_surface_lock);
 }
 
 #endif
-- 
1.7.12-rc1



More information about the Libva mailing list