summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2018-11-15 11:17:59 +0100
committerGuillaume Desmottes <guillaume.desmottes@collabora.com>2018-12-21 17:16:31 +0100
commit3828d9769c74e3c66342a1f78848397982ac2f6e (patch)
treee0c992252363d9e5293f8ee1716da310b4f9d712
parentf17b12c4f9fc220924fc4daed358575b4613ba3a (diff)
downloadgst-omx-3828d9769c74e3c66342a1f78848397982ac2f6e.tar.gz
omxbufferpool: fix early input buffer release
We used to track the 'allocating' status on the pool. It is used while allocating so output buffers aren't passed right away to OMX and input ones are not re-added to the pending queue. This was causing a bug when exporting buffers to v4l2src. On start v4l2src acquires a buffer, read its stride and release it right away. As no buffer was received by the encoder element at this point, 'allocating' was still on TRUE and so the the buffer wasn't put back to the pending queue and, as result, no longer available to the pool. Fix this by checking the active status of the pool instead of manually tracking it down. The pool is considered as active at the very end of the activation process so we're good when buffers are released during the activation.
-rw-r--r--omx/gstomxbufferpool.c4
-rw-r--r--omx/gstomxbufferpool.h2
-rw-r--r--omx/gstomxvideodec.c3
-rw-r--r--omx/gstomxvideoenc.c3
4 files changed, 1 insertions, 11 deletions
diff --git a/omx/gstomxbufferpool.c b/omx/gstomxbufferpool.c
index 7bb31f5..910f3ff 100644
--- a/omx/gstomxbufferpool.c
+++ b/omx/gstomxbufferpool.c
@@ -405,8 +405,6 @@ gst_omx_buffer_pool_alloc_buffer (GstBufferPool * bpool,
GstBuffer *buf;
GstOMXBuffer *omx_buf;
- g_return_val_if_fail (pool->allocating, GST_FLOW_ERROR);
-
omx_buf = g_ptr_array_index (pool->port->buffers, pool->current_buffer_index);
g_return_val_if_fail (omx_buf != NULL, GST_FLOW_ERROR);
@@ -659,7 +657,7 @@ gst_omx_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer)
g_assert (pool->component && pool->port);
- if (!pool->allocating) {
+ if (gst_buffer_pool_is_active (bpool)) {
omx_buf = gst_omx_buffer_get_omx_buf (buffer);
if (pool->port->port_def.eDir == OMX_DirOutput && !omx_buf->used &&
!pool->deactivated) {
diff --git a/omx/gstomxbufferpool.h b/omx/gstomxbufferpool.h
index 71d1afc..a09c825 100644
--- a/omx/gstomxbufferpool.h
+++ b/omx/gstomxbufferpool.h
@@ -68,8 +68,6 @@ struct _GstOMXBufferPool
GstAllocator *allocator;
/* Set from outside this pool */
- /* TRUE if we're currently allocating all our buffers */
- gboolean allocating;
/* TRUE if the pool is not used anymore */
gboolean deactivated;
diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c
index e1aec3f..f68911e 100644
--- a/omx/gstomxvideodec.c
+++ b/omx/gstomxvideodec.c
@@ -1165,14 +1165,11 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self)
goto done;
}
- GST_OMX_BUFFER_POOL (self->out_port_pool)->allocating = TRUE;
/* This now allocates all the buffers */
if (!gst_buffer_pool_set_active (self->out_port_pool, TRUE)) {
GST_INFO_OBJECT (self, "Failed to activate internal pool");
gst_object_unref (self->out_port_pool);
self->out_port_pool = NULL;
- } else {
- GST_OMX_BUFFER_POOL (self->out_port_pool)->allocating = FALSE;
}
} else if (self->out_port_pool) {
gst_object_unref (self->out_port_pool);
diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c
index abac46d..6fa57fb 100644
--- a/omx/gstomxvideoenc.c
+++ b/omx/gstomxvideoenc.c
@@ -2054,8 +2054,6 @@ gst_omx_video_enc_enable (GstOMXVideoEnc * self, GstBuffer * input)
/* Is downstream using our buffer pool? */
if (buffer_is_from_input_pool (self, input)) {
- /* We're done allocating as we received the first buffer from upstream */
- GST_OMX_BUFFER_POOL (input->pool)->allocating = FALSE;
self->in_pool_used = TRUE;
}
@@ -3059,7 +3057,6 @@ create_input_pool (GstOMXVideoEnc * self, GstCaps * caps, guint num_buffers)
pool =
gst_omx_buffer_pool_new (GST_ELEMENT_CAST (self), self->enc,
self->enc_in_port, GST_OMX_BUFFER_MODE_DMABUF);
- GST_OMX_BUFFER_POOL (pool)->allocating = TRUE;
g_signal_connect_object (pool, "allocate",
G_CALLBACK (pool_request_allocate_cb), self, 0);