surface: factor out release of surface buffer storage.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 14 May 2014 11:42:51 +0000 (13:42 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Mon, 2 Jun 2014 17:30:43 +0000 (19:30 +0200)
Introduce a new i965_destroy_surface_storage() helper function to
unreference the underlying GEM buffer object, and any associated
private data, if any.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
src/i965_decoder_utils.c
src/i965_drv_video.c
src/i965_drv_video.h
src/i965_output_dri.c

index f579f91..7ebc3fa 100644 (file)
@@ -387,14 +387,10 @@ intel_update_avc_frame_store_index(VADriverContextP ctx,
             obj_surface->flags &= ~SURFACE_REFERENCED;
 
             if ((obj_surface->flags & SURFACE_ALL_MASK) == SURFACE_DISPLAYED) {
-                dri_bo_unreference(obj_surface->bo);
-                obj_surface->bo = NULL;
                 obj_surface->flags &= ~SURFACE_REF_DIS_MASK;
+                i965_destroy_surface_storage(obj_surface);
             }
 
-            if (obj_surface->free_private_data)
-                obj_surface->free_private_data(&obj_surface->private_data);
-
             frame_store[i].surface_id = VA_INVALID_ID;
             frame_store[i].frame_store_id = -1;
             frame_store[i].obj_surface = NULL;
index 7a0320b..eb67f53 100755 (executable)
@@ -603,10 +603,11 @@ VAStatus i965_QueryConfigAttributes(VADriverContextP ctx,
     return vaStatus;
 }
 
-static void 
-i965_destroy_surface(struct object_heap *heap, struct object_base *obj)
+void
+i965_destroy_surface_storage(struct object_surface *obj_surface)
 {
-    struct object_surface *obj_surface = (struct object_surface *)obj;
+    if (!obj_surface)
+        return;
 
     dri_bo_unreference(obj_surface->bo);
     obj_surface->bo = NULL;
@@ -615,7 +616,14 @@ i965_destroy_surface(struct object_heap *heap, struct object_base *obj)
         obj_surface->free_private_data(&obj_surface->private_data);
         obj_surface->private_data = NULL;
     }
+}
+
+static void 
+i965_destroy_surface(struct object_heap *heap, struct object_base *obj)
+{
+    struct object_surface *obj_surface = (struct object_surface *)obj;
 
+    i965_destroy_surface_storage(obj_surface);
     object_heap_free(heap, obj);
 }
 
index 900aed9..44f61bf 100644 (file)
@@ -428,4 +428,7 @@ extern VAStatus i965_DestroySurfaces(VADriverContextP ctx,
 #define I965_SURFACE_MEM_GEM_FLINK          1
 #define I965_SURFACE_MEM_DRM_PRIME          2
 
+void
+i965_destroy_surface_storage(struct object_surface *obj_surface);
+
 #endif /* _I965_DRV_VIDEO_H_ */
index 717ee9a..fdd69ce 100644 (file)
@@ -209,12 +209,8 @@ i965_put_surface_dri(
     obj_surface->flags |= SURFACE_DISPLAYED;
 
     if ((obj_surface->flags & SURFACE_ALL_MASK) == SURFACE_DISPLAYED) {
-        dri_bo_unreference(obj_surface->bo);
-        obj_surface->bo = NULL;
         obj_surface->flags &= ~SURFACE_REF_DIS_MASK;
-
-        if (obj_surface->free_private_data)
-            obj_surface->free_private_data(&obj_surface->private_data);
+        i965_destroy_surface_storage(obj_surface);
     }
 
     _i965UnlockMutex(&i965->render_mutex);