From: Sreerenj Balachandran Date: Tue, 21 Jan 2014 13:43:57 +0000 (+0200) Subject: GstVaapiObject: initialize the derived object data with init() hook. X-Git-Tag: 0.5.9~35 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fgstreamer-vaapi.git;a=commitdiff_plain;h=502952d080f8608cca54cae7f5497cb39354da4a 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 --- diff --git a/gst-libs/gst/vaapi/gstvaapiobject.c b/gst-libs/gst/vaapi/gstvaapiobject.c index 20b2fe5..5069dbf 100644 --- a/gst-libs/gst/vaapi/gstvaapiobject.c +++ b/gst-libs/gst/vaapi/gstvaapiobject.c @@ -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; }