From 1ebd34e63707e878ac06af2cda6a1a724a6bf61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 12 Mar 2013 20:02:53 +0100 Subject: [PATCH] omxvideodec: Make sure to always get the right buffer --- omx/gstomxvideodec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index 6e21fa2117..b190dbb155 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -487,6 +487,7 @@ gst_omx_buffer_pool_acquire_buffer (GstBufferPool * bpool, if (pool->port->port_def.eDir == OMX_DirOutput) { GstBuffer *buf; GstBufferPoolAcquireParams int_params = *params; + GList *free_buffers = NULL; int_params.flags |= GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT; @@ -500,14 +501,17 @@ gst_omx_buffer_pool_acquire_buffer (GstBufferPool * bpool, GST_BUFFER_POOL_CLASS (gst_omx_buffer_pool_parent_class)->acquire_buffer (bpool, buffer, &int_params)) != GST_FLOW_EOS) { - if (ret != GST_FLOW_OK) + if (ret != GST_FLOW_OK) { + g_list_free_full (free_buffers, (GDestroyNotify) gst_buffer_unref); return ret; + } if (*buffer == buf) break; gst_object_replace ((GstObject **) & (*buffer)->pool, (GstObject *) pool); - gst_buffer_unref (*buffer); + free_buffers = g_list_prepend (free_buffers, *buffer); *buffer = NULL; } + g_list_free_full (free_buffers, (GDestroyNotify) gst_buffer_unref); g_return_val_if_fail (*buffer != NULL, GST_FLOW_ERROR); @@ -543,7 +547,7 @@ gst_omx_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer) omx_buf = gst_mini_object_get_qdata (GST_MINI_OBJECT_CAST (buffer), gst_omx_buffer_data_quark); - if (pool->port->port_def.eDir == OMX_DirOutput) { + if (pool->port->port_def.eDir == OMX_DirOutput && !omx_buf->used) { /* Release back to the port, can be filled again */ err = gst_omx_port_release_buffer (pool->port, omx_buf); if (err != OMX_ErrorNone) { @@ -551,7 +555,7 @@ gst_omx_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer) ("Failed to relase output buffer to component: %s (0x%08x)", gst_omx_error_to_string (err), err)); } - } else { + } else if (!omx_buf->used) { /* TODO: Implement. * * If not used (i.e. was not passed to the component) this should do