[gst-devel] Destructor of an element

LRN lrn1986 at gmail.com
Thu Oct 29 17:10:55 CET 2009


Tiago Katcipis wrote:
> I'm building an element that uses an external lib, and when my element is
> freed (it ref count reaches zero), i want to free some stuff of the external
> lib i use. I didn't find anything about a generic destructor function that i
> can override, so when my element is being freed i can free the resources
> that i was using on my plugin. Can anyone help me?
>
> best regards,
> Katcipis
>
>   
In the *_class_init() function of your class, do something like this:

void gst_my_element_class_init (GstMyElementClass * klass) {
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);

...

  gobject_class->finalize = gst_my_element_finalize;


...
}

void
gst_my_element_finalize (GObject * object) {
/* Free your stuff here */
}





More information about the gstreamer-devel mailing list