GstVaapiObject: initialize the derived object data with init() hook.
authorSreerenj Balachandran <sreerenj.balachandran@intel.com>
Tue, 21 Jan 2014 13:43:57 +0000 (15:43 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Thu, 3 Jul 2014 21:38:25 +0000 (23:38 +0200)
Call the subclass .init() function in gst_vaapi_object_new(), if
needed. The default behaviour is to zero initialize the subclass
object data, then the .init() function can be used to initialize
fields to non-default values, e.g. VA object ids to VA_INVALID_ID.

Also fix the gst_vaapi_object_new() description, which was merely
copied from GstVaapiMiniObject.

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

[changed to always zero initialize the subclass]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
gst-libs/gst/vaapi/gstvaapiobject.c

index 20b2fe5..5069dbf 100644 (file)
@@ -64,11 +64,12 @@ gst_vaapi_object_class_init(GstVaapiObjectClass *klass, guint size)
 
 /**
  * gst_vaapi_object_new:
- * @object_class: The object class
+ * @klass: The object class
+ * @display: The #GstVaapiDisplay
  *
- * Creates a new #GstVaapiObject. If @object_class is NULL, then the
- * size of the allocated object is the same as sizeof(GstVaapiObject).
- * If @object_class is not NULL, typically when a sub-class is implemented,
+ * Creates a new #GstVaapiObject. If @klass is NULL, then the size of
+ * the allocated object is the same as sizeof(GstVaapiObject).
+ * If @klass is not NULL, typically when a sub-class is implemented,
  * that pointer shall reference a statically allocated descriptor.
  *
  * This function zero-initializes the derived object data. Also note
@@ -97,6 +98,9 @@ gst_vaapi_object_new(const GstVaapiObjectClass *klass, GstVaapiDisplay *display)
     sub_size = object_class->size - sizeof(*object);
     if (sub_size > 0)
         memset(((guchar *)object) + sizeof(*object), 0, sub_size);
+
+    if (klass && klass->init)
+        klass->init (object);
     return object;
 }