summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Isorce <julien.isorce@collabora.co.uk>2014-03-17 09:57:11 +0000
committerJulien Isorce <julien.isorce@collabora.co.uk>2014-03-17 18:02:51 +0000
commite8ca74c6f862e5f1e0bdc5057dc836a71902244e (patch)
tree3d44c7961c518b1b1b929fafb36e90d963c16571
parent922d036ae7ea1d6d6b0a193b8930ce5972ee1b68 (diff)
omxbufferpool: fix memory leak if used on output port
When using GstOMXBufferPool on an output port, it internally uses a GPtrArray to manage the GstBuffers instead of the default queue from the GstBufferPool base class. In this case GstBufferPool::default_free_buffer is not called when the pool is stopped. Because the queue is empty. So explicitely call gst_omx_buffer_pool_free_buffer on each buffer contained in the GPtrArray. https://bugzilla.gnome.org/show_bug.cgi?id=726337
-rw-r--r--omx/gstomxbufferpool.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/omx/gstomxbufferpool.c b/omx/gstomxbufferpool.c
index 2bb0db0..80bb83e 100644
--- a/omx/gstomxbufferpool.c
+++ b/omx/gstomxbufferpool.c
@@ -192,6 +192,9 @@ static GQuark gst_omx_buffer_data_quark = 0;
G_DEFINE_TYPE (GstOMXBufferPool, gst_omx_buffer_pool, GST_TYPE_BUFFER_POOL);
+static void gst_omx_buffer_pool_free_buffer (GstBufferPool * bpool,
+ GstBuffer * buffer);
+
static gboolean
gst_omx_buffer_pool_start (GstBufferPool * bpool)
{
@@ -214,6 +217,14 @@ static gboolean
gst_omx_buffer_pool_stop (GstBufferPool * bpool)
{
GstOMXBufferPool *pool = GST_OMX_BUFFER_POOL (bpool);
+ gint i = 0;
+
+ /* When not using the default GstBufferPool::GstAtomicQueue then
+ * GstBufferPool::free_buffer is not called while stopping the pool
+ * (because the queue is empty) */
+ for (i = 0; i < pool->buffers->len; i++)
+ gst_omx_buffer_pool_free_buffer (bpool, g_ptr_array_index (pool->buffers,
+ i));
/* Remove any buffers that are there */
g_ptr_array_set_size (pool->buffers, 0);