buffers to unref in finalize function

chandu chandrakala.madhira at incubesol.com
Tue Nov 29 00:02:48 PST 2011


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);

}

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");
}

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);
}
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.


More information about the gstreamer-devel mailing list