omxbufferpool: deallocate OMX buffers when stopping

The pool is stopped when all the buffers have been released. Deallocate
when stopping so we are sure that the buffers aren't still used by
another element.

https://bugzilla.gnome.org/show_bug.cgi?id=796918
This commit is contained in:
Guillaume Desmottes 2018-05-28 12:20:45 +02:00
parent d2f7e21ab9
commit 7b6be347a6
2 changed files with 19 additions and 13 deletions

View file

@ -247,6 +247,9 @@ gst_omx_buffer_pool_stop (GstBufferPool * bpool)
/* Remove any buffers that are there */
g_ptr_array_set_size (pool->buffers, 0);
GST_DEBUG_OBJECT (pool, "deallocate OMX buffers");
gst_omx_port_deallocate_buffers (pool->port);
if (pool->caps)
gst_caps_unref (pool->caps);
pool->caps = NULL;

View file

@ -81,7 +81,7 @@ static GstFlowReturn gst_omx_video_dec_drain (GstVideoDecoder * decoder);
static OMX_ERRORTYPE gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec *
self);
static OMX_ERRORTYPE gst_omx_video_dec_deallocate_output_buffers (GstOMXVideoDec
static gboolean gst_omx_video_dec_deallocate_output_buffers (GstOMXVideoDec
* self);
enum
@ -1135,12 +1135,11 @@ done:
return err;
}
static OMX_ERRORTYPE
static gboolean
gst_omx_video_dec_deallocate_output_buffers (GstOMXVideoDec * self)
{
OMX_ERRORTYPE err;
if (self->out_port_pool) {
/* Pool will free buffers when stopping */
gst_buffer_pool_set_active (self->out_port_pool, FALSE);
#if 0
gst_buffer_pool_wait_released (self->out_port_pool);
@ -1148,16 +1147,21 @@ gst_omx_video_dec_deallocate_output_buffers (GstOMXVideoDec * self)
GST_OMX_BUFFER_POOL (self->out_port_pool)->deactivated = TRUE;
gst_object_unref (self->out_port_pool);
self->out_port_pool = NULL;
}
} else {
OMX_ERRORTYPE err;
#if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_GL)
err =
gst_omx_port_deallocate_buffers (self->eglimage ? self->
egl_out_port : self->dec_out_port);
err =
gst_omx_port_deallocate_buffers (self->eglimage ? self->
egl_out_port : self->dec_out_port);
#else
err = gst_omx_port_deallocate_buffers (self->dec_out_port);
err = gst_omx_port_deallocate_buffers (self->dec_out_port);
#endif
return err;
return err == OMX_ErrorNone;
}
return TRUE;
}
static OMX_ERRORTYPE
@ -1573,8 +1577,7 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
if (err != OMX_ErrorNone)
goto reconfigure_error;
err = gst_omx_video_dec_deallocate_output_buffers (self);
if (err != OMX_ErrorNone)
if (!gst_omx_video_dec_deallocate_output_buffers (self))
goto reconfigure_error;
err = gst_omx_port_wait_enabled (port, 1 * GST_SECOND);
@ -2179,7 +2182,7 @@ gst_omx_video_dec_disable (GstOMXVideoDec * self)
if (gst_omx_port_wait_buffers_released (out_port,
1 * GST_SECOND) != OMX_ErrorNone)
return FALSE;
if (gst_omx_video_dec_deallocate_output_buffers (self) != OMX_ErrorNone)
if (!gst_omx_video_dec_deallocate_output_buffers (self))
return FALSE;
if (gst_omx_port_wait_enabled (out_port, 1 * GST_SECOND) != OMX_ErrorNone)
return FALSE;