diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2018-05-28 12:20:45 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2018-08-30 10:59:30 +0200 |
commit | 7b6be347a6dc94c0ca16272fa249bc77b68f43ee (patch) | |
tree | f0708dc76d7e0fd04eb0d10b697cbb6c17885841 | |
parent | d2f7e21ab9be7f3d543a50b6cbac6dffca33384a (diff) | |
download | gst-omx-7b6be347a6dc94c0ca16272fa249bc77b68f43ee.tar.gz |
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
-rw-r--r-- | omx/gstomxbufferpool.c | 3 | ||||
-rw-r--r-- | omx/gstomxvideodec.c | 29 |
2 files changed, 19 insertions, 13 deletions
diff --git a/omx/gstomxbufferpool.c b/omx/gstomxbufferpool.c index 4e2033f..995687b 100644 --- a/omx/gstomxbufferpool.c +++ b/omx/gstomxbufferpool.c @@ -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; diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index d2d6428..c699067 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -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; |