buffers to unref in finalize function

Stefan Sauer ensonic at hora-obscura.de
Tue Nov 29 12:06:48 PST 2011


On 11/29/2011 09:02 AM, chandu wrote:
> Hi Stefan,
>
> I have my own plugin as follows.
>
> /**************** code starts ********************/
> static void gst_plugin_template_class_init (GstPluginTemplateClass * klass)
> {
>
>   g_print("INC : in the gst_plugin_template_class_init \n");
>
>   GObjectClass *gobject_class;
>   GstElementClass *gstelement_class;
>
>   gobject_class = (GObjectClass *) klass;
>   gstelement_class = (GstElementClass *) klass;
>   gobject_class->dispose = gst_plugin_template_dispose;
>   gobject_class->finalize =  gst_plugin_template_finalize;
> }
>
> static void gst_plugin_template_init (GstPluginTemplate * filter,
>     GstPluginTemplateClass * gclass)
> {
>   
>   code[..]
>
>   filter->adapter = gst_adapter_new();		//create adaptor
>   g_object_ref(filter->adapter);
don't ref it. _new returns it with one ref already.
> }
>
> static void gst_plugin_template_finalize(GObject * object)
> {
>   g_print("INC : in finalize....\n");
>   GstPluginTemplate *filter = GST_PLUGIN_TEMPLATE(object);
>      
>      filter->adapter = NULL;
>   g_print("INC : Reset all buffers\n");
here you need to chain up to the super class.
> }
>
> static void gst_plugin_template_dispose(GObject * object)
> {
>   g_print("INC : in the dispose.....\n");
>   GstPluginTemplate *filter = GST_PLUGIN_TEMPLATE(object);
>   gst_adapter_clear(filter->adapter);
>   g_object_unref(filter->adapter);
>   g_object_unref(filter);
don't unref the filter. and also chainup here.

Stefan
> }
> static GstFlowReturn gst_plugin_template_chain (GstPad * pad, GstBuffer *
> buf)
> {
>   g_print("INC : in the gst_plugin_template_chain\n");
>   GstPluginTemplate *filter;
>   GstFlowReturn ret=GST_FLOW_OK;
>   filter = GST_PLUGIN_TEMPLATE (GST_OBJECT_PARENT (pad));
>   if (filter->silent == FALSE)
>   {
>      g_print ("INC: I'm plugged, therefore I'm in (chain)\n");
>   }
>    ret = gst_pad_push(filter->srcpad,buf);
>   if(ret != GST_FLOW_OK) g_print("INC : buffer push Failed......\n");
>
>   return ret;
> }
>   /*****************code ends here ***************/
>
> I have allocated memory to adapter in gst_plugin_template_init function.
> freed the same using dispose and finalize functions. My problem is, these 2
> functions are never called. how can i ensure that the memory given to
> adapter is freed.
>
> regards,
> Chandrakala
>
>
>
>
>
>
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/buffers-to-unref-in-finalize-function-tp4114177p4118339.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



More information about the gstreamer-devel mailing list