# HG changeset patch # User rosfran # Date 1164915862 0 # Node ID a0e5b7d75f251bce05c53c2c2552e3b3e75ec480 # Parent 22db2f4b6f86b4605b9162dfb5958f2ad273d9f1 [svn r154] Fixed memory leaks when sending duration (TIME and BYTES) queries to the sink pad (peer pad). diff -r 22db2f4b6f86 -r a0e5b7d75f25 gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c Thu Nov 30 19:41:27 2006 +0000 +++ b/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c Thu Nov 30 19:44:22 2006 +0000 @@ -1078,14 +1078,12 @@ return GST_FLOW_ERROR_NO_DATA; if (move) { - guint8 *data = NULL; - data = (guint8 *) gst_adapter_take (nuv->priv->adapter, size); - *buffer = gst_buffer_new (); + guint8 *data = (guint8 *) gst_adapter_take (nuv->priv->adapter, size); + *buffer = gst_buffer_new_and_alloc ( size ); gst_buffer_set_data (*buffer, data, size); } else { - guint8 *data = NULL; - data = (guint8 *) gst_adapter_peek (nuv->priv->adapter, size); - *buffer = gst_buffer_new (); + guint8 *data = (guint8 *) gst_adapter_peek (nuv->priv->adapter, size); + *buffer = gst_buffer_new_and_alloc ( size ); gst_buffer_set_data (*buffer, data, size); } } @@ -1325,7 +1323,6 @@ interval = current_timestamp - nuv->priv->last_update; if (interval > (10 * GST_SECOND)) { - GstMessage* msg = NULL; gint64 average = 0; gint64 duration_bytes = gst_nuv_demux_get_bytes_duration (nuv); @@ -1341,8 +1338,9 @@ nuv->priv->duration_average = gst_util_uint64_scale (GST_SECOND, duration_bytes, average); } nuv->priv->last_update = current_timestamp; - msg = gst_message_new_duration (GST_OBJECT (nuv), GST_FORMAT_TIME, nuv->priv->duration_average); - gst_element_post_message (GST_ELEMENT (nuv), msg); + gst_element_post_message (GST_ELEMENT (nuv), + gst_message_new_duration (GST_OBJECT (nuv), GST_FORMAT_TIME, + nuv->priv->duration_average) ); GST_DEBUG_OBJECT (nuv, "New Duration Average %"G_GUINT64_FORMAT, nuv->priv->duration_average); } } @@ -1352,16 +1350,11 @@ gst_nuv_demux_get_bytes_duration (GstNuvDemux *nuv) { if (nuv->priv->duration_bytes == GST_CLOCK_TIME_NONE) { - GstPad *peer = gst_pad_get_peer (nuv->priv->sinkpad); - GstQuery *query = gst_query_new_duration (GST_FORMAT_BYTES); - if (gst_pad_query (peer, query)) { - gint64 duration; - - gst_query_parse_duration (query, NULL, &duration); + GstFormat format = GST_FORMAT_BYTES; + gint64 duration = 0; + if (gst_pad_query_peer_duration (nuv->priv->sinkpad, &format, &duration)) { nuv->priv->duration_bytes = duration; } - gst_object_unref (peer); - gst_query_unref (query); } return nuv->priv->duration_bytes; } @@ -1370,15 +1363,11 @@ gst_nuv_demux_get_time_duration (GstNuvDemux *nuv) { if (nuv->priv->duration_time == GST_CLOCK_TIME_NONE) { - GstPad *peer = gst_pad_get_peer (nuv->priv->sinkpad); - GstQuery *query = gst_query_new_duration (GST_FORMAT_TIME); - if (gst_pad_query (peer, query)) { - gint64 duration; - gst_query_parse_duration (query, NULL, &duration); + GstFormat format = GST_FORMAT_TIME; + gint64 duration = 0; + if (gst_pad_query_peer_duration (nuv->priv->sinkpad, &format, &duration)) { nuv->priv->duration_time = duration; } - gst_object_unref (peer); - gst_query_unref (query); } return nuv->priv->duration_time; }