mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
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.
This commit is contained in:
parent
f17b12c4f9
commit
3828d9769c
4 changed files with 1 additions and 11 deletions
|
@ -405,8 +405,6 @@ gst_omx_buffer_pool_alloc_buffer (GstBufferPool * bpool,
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
GstOMXBuffer *omx_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);
|
omx_buf = g_ptr_array_index (pool->port->buffers, pool->current_buffer_index);
|
||||||
g_return_val_if_fail (omx_buf != NULL, GST_FLOW_ERROR);
|
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);
|
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);
|
omx_buf = gst_omx_buffer_get_omx_buf (buffer);
|
||||||
if (pool->port->port_def.eDir == OMX_DirOutput && !omx_buf->used &&
|
if (pool->port->port_def.eDir == OMX_DirOutput && !omx_buf->used &&
|
||||||
!pool->deactivated) {
|
!pool->deactivated) {
|
||||||
|
|
|
@ -68,8 +68,6 @@ struct _GstOMXBufferPool
|
||||||
GstAllocator *allocator;
|
GstAllocator *allocator;
|
||||||
|
|
||||||
/* Set from outside this pool */
|
/* Set from outside this pool */
|
||||||
/* TRUE if we're currently allocating all our buffers */
|
|
||||||
gboolean allocating;
|
|
||||||
/* TRUE if the pool is not used anymore */
|
/* TRUE if the pool is not used anymore */
|
||||||
gboolean deactivated;
|
gboolean deactivated;
|
||||||
|
|
||||||
|
|
|
@ -1165,14 +1165,11 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_OMX_BUFFER_POOL (self->out_port_pool)->allocating = TRUE;
|
|
||||||
/* This now allocates all the buffers */
|
/* This now allocates all the buffers */
|
||||||
if (!gst_buffer_pool_set_active (self->out_port_pool, TRUE)) {
|
if (!gst_buffer_pool_set_active (self->out_port_pool, TRUE)) {
|
||||||
GST_INFO_OBJECT (self, "Failed to activate internal pool");
|
GST_INFO_OBJECT (self, "Failed to activate internal pool");
|
||||||
gst_object_unref (self->out_port_pool);
|
gst_object_unref (self->out_port_pool);
|
||||||
self->out_port_pool = NULL;
|
self->out_port_pool = NULL;
|
||||||
} else {
|
|
||||||
GST_OMX_BUFFER_POOL (self->out_port_pool)->allocating = FALSE;
|
|
||||||
}
|
}
|
||||||
} else if (self->out_port_pool) {
|
} else if (self->out_port_pool) {
|
||||||
gst_object_unref (self->out_port_pool);
|
gst_object_unref (self->out_port_pool);
|
||||||
|
|
|
@ -2054,8 +2054,6 @@ gst_omx_video_enc_enable (GstOMXVideoEnc * self, GstBuffer * input)
|
||||||
|
|
||||||
/* Is downstream using our buffer pool? */
|
/* Is downstream using our buffer pool? */
|
||||||
if (buffer_is_from_input_pool (self, input)) {
|
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;
|
self->in_pool_used = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3059,7 +3057,6 @@ create_input_pool (GstOMXVideoEnc * self, GstCaps * caps, guint num_buffers)
|
||||||
pool =
|
pool =
|
||||||
gst_omx_buffer_pool_new (GST_ELEMENT_CAST (self), self->enc,
|
gst_omx_buffer_pool_new (GST_ELEMENT_CAST (self), self->enc,
|
||||||
self->enc_in_port, GST_OMX_BUFFER_MODE_DMABUF);
|
self->enc_in_port, GST_OMX_BUFFER_MODE_DMABUF);
|
||||||
GST_OMX_BUFFER_POOL (pool)->allocating = TRUE;
|
|
||||||
|
|
||||||
g_signal_connect_object (pool, "allocate",
|
g_signal_connect_object (pool, "allocate",
|
||||||
G_CALLBACK (pool_request_allocate_cb), self, 0);
|
G_CALLBACK (pool_request_allocate_cb), self, 0);
|
||||||
|
|
Loading…
Reference in a new issue