libs: robustify decoder objects and surface proxy initialization.
authorXuGuangxin <guangxin.xu@intel.com>
Thu, 29 Aug 2013 06:04:06 +0000 (14:04 +0800)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Thu, 21 Nov 2013 10:08:23 +0000 (11:08 +0100)
Fix GstVaapiPicture, GstVaapiSlice and GstVaapiSurfaceProxy initialization
sequences to have the expected default values set beforehand in case of an
error raising up further during creation. i.e. make it possible to cleanly
destroy those partially initialized objects.

https://bugzilla.gnome.org/show_bug.cgi?id=707108

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
gst-libs/gst/vaapi/gstvaapidecoder_objects.c
gst-libs/gst/vaapi/gstvaapisurfaceproxy.c

index 218b512..225dcfb 100644 (file)
@@ -103,6 +103,8 @@ gst_vaapi_picture_create(
 {
     gboolean success;
 
+    picture->param_id = VA_INVALID_ID;
+
     if (args->flags & GST_VAAPI_CREATE_PICTURE_FLAG_CLONE) {
         GstVaapiPicture * const parent_picture = GST_VAAPI_PICTURE(args->data);
 
@@ -158,7 +160,6 @@ gst_vaapi_picture_create(
     picture->surface    = GST_VAAPI_SURFACE_PROXY_SURFACE(picture->proxy);
     picture->surface_id = GST_VAAPI_SURFACE_PROXY_SURFACE_ID(picture->proxy);
 
-    picture->param_id = VA_INVALID_ID;
     success = vaapi_create_buffer(
         GET_VA_DISPLAY(picture),
         GET_VA_CONTEXT(picture),
@@ -418,7 +419,9 @@ gst_vaapi_slice_create(
     VASliceParameterBufferBase *slice_param;
     gboolean success;
 
+    slice->param_id = VA_INVALID_ID;
     slice->data_id = VA_INVALID_ID;
+
     success = vaapi_create_buffer(
         GET_VA_DISPLAY(slice),
         GET_VA_CONTEXT(slice),
@@ -431,7 +434,6 @@ gst_vaapi_slice_create(
     if (!success)
         return FALSE;
 
-    slice->param_id = VA_INVALID_ID;
     success = vaapi_create_buffer(
         GET_VA_DISPLAY(slice),
         GET_VA_CONTEXT(slice),
index 9a7f2c4..f698103 100644 (file)
@@ -70,13 +70,13 @@ gst_vaapi_surface_proxy_new_from_pool(GstVaapiSurfacePool *pool)
     if (!proxy)
         return NULL;
 
+    proxy->destroy_func = NULL;
     proxy->pool = gst_vaapi_video_pool_ref(pool);
     proxy->surface = gst_vaapi_video_pool_get_object(proxy->pool);
     if (!proxy->surface)
         goto error;
     proxy->timestamp = GST_CLOCK_TIME_NONE;
     proxy->duration = GST_CLOCK_TIME_NONE;
-    proxy->destroy_func = NULL;
     proxy->has_crop_rect = FALSE;
     gst_vaapi_object_ref(proxy->surface);
     return proxy;