<p>I am developing a muxer plugin,where I use the request_new_pad/release_pad from GstElementClass. But i never saw the release_pad callback function was called in my codes thought I did see the finalize(GObjectClass) was called in the end. I am not quite sure why release_pad was no called. Will it cause the memory leakage ?<br>
<br>The following are the request_new_pad and finalize functions. <br> <br>Regards,<br> <br>Yihe<br>/******************************************************************<br>* gst_tidmaireiszer_request_new_pad<br>* request a new pad<br>
******************************************************************/<br>static GstPad *gst_tidmairesizer_request_new_pad(GstElement * element,<br> GstPadTemplate *templ,const gchar *req_name)<br>{<br>GstTIDmaiResizer *dmairesizer;<br>
GstPad *newpad;<br>GstElementClass *klass = GST_ELEMENT_GET_CLASS(element);<br>gchar *name;<br> if(templ != gst_element_class_get_pad_template(klass,"decimage_%d"))<br> goto wrong_template;<br> dmairesizer = GST_TIDMAIRESIZER(element); <br>
//create new pad<br> name = g_strdup_printf("decimage_%02d",dmairesizer->numpads);<br> newpad = gst_pad_new_from_template(templ,name);<br> g_free(name);<br> GstResizerPad *resizerpad;<br> if(dmairesizer->numpads >= MAX_INPUT_SUPPORT)<br>
{<br> GST_ERROR("Over the max input hardware can support\n");<br> gst_object_unref(newpad);<br> return NULL;<br> }<br> resizerpad = (GstResizerPad *) gst_collect_pads_add_pad(dmairesizer->collect,newpad,sizeof(GstResizerPad));<br>
resizerpad->x_start = dmairesizer->x_start[dmairesizer->numpads];<br> resizerpad->y_start = dmairesizer->y_start[dmairesizer->numpads]; <br> resizerpad->rsFormat = dmairesizer->rsFormat[dmairesizer->numpads];<br>
//save a pointer to our data in the pad<br>// gst_pad_set_element_private(newpad,resizerpad); <br> dmairesizer->numpads++; <br> GST_LOG("request new pad %d\n",dmairesizer->numpads); <br> //set sink pad caps<br>
gst_pad_set_setcaps_function (newpad,GST_DEBUG_FUNCPTR (gst_tidmairesizer_set_sink_caps));<br> //add pad to element<br> gst_element_add_pad(element,newpad);<br> return newpad;<br>wrong_template:<br> {<br> GST_ERROR("this is not our template pad!\n");<br>
return NULL;<br> } <br>}<br> <br> <br> <br>static void gst_tidmairesizer_finalize(GObject *object)<br>{<br>GstTIDmaiResizer *dmairesizer = GST_TIDMAIRESIZER(object);</p>
<p> GST_LOG("finalizer being\n");<br> //clean up everything<br> gst_tidmairesizer_exit_video(dmairesizer); <br> GST_LOG("finalizer begin\n");<br> if(dmairesizer->collect)<br> {<br> gst_object_unref(dmairesizer->collect);<br>
dmairesizer->collect=NULL;<br> }<br> G_OBJECT_CLASS(parent_class)->finalize(object);<br> GST_LOG("finalizer Finish\n"); <br>}</p>