From df6a9792435d70d982153e0fc0decfeca0c2110e Mon Sep 17 00:00:00 2001 From: Julien Moutte Date: Mon, 9 Feb 2004 09:11:50 +0000 Subject: [PATCH] gst/gstdata.c: Adding a categorized debug on data_ref because data_unref has one and i prefer the debug to be symetric. Original commit message from CVS: 2004-02-09 Julien MOUTTE * gst/gstdata.c: (gst_data_ref): Adding a categorized debug on data_ref because data_unref has one and i prefer the debug to be symetric. * gst/gstqueue.c: (gst_queue_locked_flush): Fix a huge memleak. Buffers were refed when added to the queue and unrefed only once when the queue was flushed. Now the flush handler unref the buffers two times : first unref for the ref added when pushing in the queue's tail and second unref to destroy the flushed buffer. --- ChangeLog | 10 ++++++++++ gst/gstdata.c | 3 +++ gst/gstqueue.c | 4 ++++ plugins/elements/gstqueue.c | 4 ++++ 4 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index 420333a40d..3d7557454e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-02-09 Julien MOUTTE + + * gst/gstdata.c: (gst_data_ref): Adding a categorized debug on data_ref + because data_unref has one and i prefer the debug to be symetric. + * gst/gstqueue.c: (gst_queue_locked_flush): Fix a huge memleak. Buffers + were refed when added to the queue and unrefed only once when the queue + was flushed. Now the flush handler unref the buffers two times : first + unref for the ref added when pushing in the queue's tail and second + unref to destroy the flushed buffer. + 2004-02-08 Thomas Vander Stichele * docs/pwg/building-boiler.xml: fix cvs checkout documentation diff --git a/gst/gstdata.c b/gst/gstdata.c index bf1f4ae314..3e8de86bba 100644 --- a/gst/gstdata.c +++ b/gst/gstdata.c @@ -187,6 +187,9 @@ gst_data_ref (GstData *data) g_return_val_if_fail (data != NULL, NULL); g_return_val_if_fail (GST_DATA_REFCOUNT_VALUE(data) > 0, NULL); + GST_CAT_LOG (GST_CAT_BUFFER, "ref data %p, count before ref is %d", + data, GST_DATA_REFCOUNT_VALUE (data)); + gst_atomic_int_inc (&data->refcount); return data; diff --git a/gst/gstqueue.c b/gst/gstqueue.c index 343a404711..b9f5e1c625 100644 --- a/gst/gstqueue.c +++ b/gst/gstqueue.c @@ -361,6 +361,10 @@ gst_queue_locked_flush (GstQueue *queue) { while (!g_queue_is_empty (queue->queue)) { GstData *data = g_queue_pop_head (queue->queue); + /* First loose the reference we added when putting that data in the queue */ + gst_data_unref (data); + /* Then loose another reference because we are supposed to destroy that + data when flushing */ gst_data_unref (data); } queue->timeval = NULL; diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index 343a404711..b9f5e1c625 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -361,6 +361,10 @@ gst_queue_locked_flush (GstQueue *queue) { while (!g_queue_is_empty (queue->queue)) { GstData *data = g_queue_pop_head (queue->queue); + /* First loose the reference we added when putting that data in the queue */ + gst_data_unref (data); + /* Then loose another reference because we are supposed to destroy that + data when flushing */ gst_data_unref (data); } queue->timeval = NULL;