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
This commit is contained in:
Guillaume Desmottes 2018-05-24 16:28:21 +02:00
parent 3b92b22554
commit d2f7e21ab9

View file

@ -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);