Fix the issue of vaGetImage()/vaPutImage() in multi-threads
authorXiang, Haihao <haihao.xiang@intel.com>
Thu, 1 Mar 2012 05:17:54 +0000 (13:17 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Thu, 1 Mar 2012 05:19:14 +0000 (13:19 +0800)
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
src/i965_drv_video.c
src/i965_drv_video.h
src/i965_post_processing.c

index 3d8a932..ad6b790 100644 (file)
@@ -1909,6 +1909,7 @@ i965_Init(VADriverContextP ctx)
         return VA_STATUS_ERROR_UNKNOWN;
 
     _i965InitMutex(&i965->render_mutex);
+    _i965InitMutex(&i965->pp_mutex);
 
     return VA_STATUS_SUCCESS;
 }
@@ -3124,6 +3125,7 @@ i965_Terminate(VADriverContextP ctx)
     if (i965->batch)
         intel_batchbuffer_free(i965->batch);
 
+    _i965DestroyMutex(&i965->pp_mutex);
     _i965DestroyMutex(&i965->render_mutex);
 
     if (i965_render_terminate(ctx) == False)
index a6ec3ed..508b9a8 100644 (file)
@@ -264,6 +264,7 @@ struct i965_driver_data
     struct hw_codec_info *codec_info;
 
     _I965Mutex render_mutex;
+    _I965Mutex pp_mutex;
     struct intel_batchbuffer *batch;
     struct i965_render_state render_state;
     void *pp_context;
index ab063e9..8d4e623 100644 (file)
@@ -3546,6 +3546,8 @@ i965_post_processing(
         if (obj_surface->fourcc != VA_FOURCC('N', 'V', '1', '2'))
             return out_surface_id;
 
+        _i965LockMutex(&i965->pp_mutex);
+
         if (flags & I965_PP_FLAG_DEINTERLACING) {
             status = i965_CreateSurfaces(ctx,
                                          obj_surface->orig_width,
@@ -3611,6 +3613,8 @@ i965_post_processing(
                 
             *has_done_scaling = 1;
         }
+
+        _i965UnlockMutex(&i965->pp_mutex);
     }
 
     return out_surface_id;
@@ -3697,6 +3701,8 @@ i965_image_processing(VADriverContextP ctx,
     if (HAS_PP(i965)) {
         int fourcc = pp_get_surface_fourcc(ctx, src_surface);
 
+        _i965LockMutex(&i965->pp_mutex);
+
         switch (fourcc) {
         case VA_FOURCC('Y', 'V', '1', '2'):
         case VA_FOURCC('I', '4', '2', '0'):
@@ -3721,6 +3727,8 @@ i965_image_processing(VADriverContextP ctx,
             status = VA_STATUS_ERROR_UNIMPLEMENTED;
             break;
         }
+        
+        _i965UnlockMutex(&i965->pp_mutex);
     }
 
     return status;