GstVaapiObject: initialize the derived object data with init() hook.

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>
This commit is contained in:
Sreerenj Balachandran 2014-01-21 15:43:57 +02:00 committed by Gwenole Beauchesne
parent 334a0ca8bd
commit 502952d080

View 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;
}