From d2f7e21ab9be7f3d543a50b6cbac6dffca33384a Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 24 May 2018 16:28:21 +0200 Subject: [PATCH] omx: call gst_omx_buffer_unmap() when handling BUFFER_DONE When using a input buffer pool, the buffer may be released to the pool when gst_omx_buffer_unmap() is called. We need to have buf->used unset at this point as the pool may use it to check the status of the pool. {Empty,Fill}BufferDone is called from OMX internal threads while messages are handled from gst elements' thread. Best to do all this when handling the message so we don't mess with OMX threads and keep the original thread/logic split. https://bugzilla.gnome.org/show_bug.cgi?id=796918 --- omx/gstomx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/omx/gstomx.c b/omx/gstomx.c index f7a548fc54..0acf413194 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -247,6 +247,8 @@ gst_omx_buffer_reset (GstOMXBuffer * buf) GST_OMX_SET_TICKS (buf->omx_buf->nTimeStamp, G_GUINT64_CONSTANT (0)); } +static void gst_omx_buffer_unmap (GstOMXBuffer * buffer); + /* NOTE: Call with comp->lock, comp->messages_lock will be used */ static void gst_omx_component_handle_messages (GstOMXComponent * comp) @@ -388,6 +390,8 @@ gst_omx_component_handle_messages (GstOMXComponent * comp) port = buf->port; + buf->used = FALSE; + if (msg->content.buffer_done.empty) { /* Input buffer is empty again and can be used to contain new input */ GST_LOG_OBJECT (port->comp->parent, @@ -399,6 +403,9 @@ gst_omx_component_handle_messages (GstOMXComponent * comp) * valid anymore after the buffer was consumed */ gst_omx_buffer_reset (buf); + + /* Release and unmap the parent buffer, if any */ + gst_omx_buffer_unmap (buf); } else { /* Output buffer contains output now or * the port was flushed */ @@ -411,8 +418,6 @@ gst_omx_component_handle_messages (GstOMXComponent * comp) port->eos = TRUE; } - buf->used = FALSE; - g_queue_push_tail (&port->pending_buffers, buf); break; @@ -710,9 +715,6 @@ EmptyBufferDone (OMX_HANDLETYPE hComponent, OMX_PTR pAppData, return OMX_ErrorBadParameter; } - /* Release and unmap the parent buffer, if any */ - gst_omx_buffer_unmap (buf); - comp = buf->port->comp; msg = g_slice_new (GstOMXMessage);