diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.com> | 2019-01-07 13:29:37 +0100 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.com> | 2019-01-08 16:04:31 +0100 |
commit | 9dc359d0c1bd2811ef3f635de0812b5217444b61 (patch) | |
tree | ec7b3d877317fa52c95a0d7d602b37bb09b4ceeb | |
parent | 3828d9769c74e3c66342a1f78848397982ac2f6e (diff) | |
download | gst-omx-9dc359d0c1bd2811ef3f635de0812b5217444b61.tar.gz |
omxbufferpool: fix race when releasing input buffers
If buffers were released from the pool while
gst_omx_video_enc_handle_frame() was waiting for new buffers,
gst_omx_port_acquire_buffer() was never awaken as the buffers weren't
released through OMX's messaging system.
GQueue isn't thread safe so also protect it with the lock mutex.
-rw-r--r-- | omx/gstomx.c | 11 | ||||
-rw-r--r-- | omx/gstomx.h | 1 | ||||
-rw-r--r-- | omx/gstomxbufferpool.c | 2 |
3 files changed, 13 insertions, 1 deletions
diff --git a/omx/gstomx.c b/omx/gstomx.c index 3c0953b..121e97c 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -2554,6 +2554,17 @@ gst_omx_port_wait_buffers_released (GstOMXPort * port, GstClockTime timeout) return err; } +void +gst_omx_port_requeue_buffer (GstOMXPort * port, GstOMXBuffer * buf) +{ + g_mutex_lock (&port->comp->lock); + g_queue_push_tail (&port->pending_buffers, buf); + g_mutex_unlock (&port->comp->lock); + + /* awake gst_omx_port_acquire_buffer() */ + gst_omx_component_send_message (port->comp, NULL); +} + /* NOTE: Uses comp->lock and comp->messages_lock */ OMX_ERRORTYPE gst_omx_port_set_enabled (GstOMXPort * port, gboolean enabled) diff --git a/omx/gstomx.h b/omx/gstomx.h index d61303c..4b61343 100644 --- a/omx/gstomx.h +++ b/omx/gstomx.h @@ -461,6 +461,7 @@ OMX_ERRORTYPE gst_omx_port_use_eglimages (GstOMXPort *port, const GList *ima OMX_ERRORTYPE gst_omx_port_deallocate_buffers (GstOMXPort *port); OMX_ERRORTYPE gst_omx_port_populate (GstOMXPort *port); OMX_ERRORTYPE gst_omx_port_wait_buffers_released (GstOMXPort * port, GstClockTime timeout); +void gst_omx_port_requeue_buffer (GstOMXPort * port, GstOMXBuffer * buf); OMX_ERRORTYPE gst_omx_port_mark_reconfigured (GstOMXPort * port); diff --git a/omx/gstomxbufferpool.c b/omx/gstomxbufferpool.c index 910f3ff..9700cd6 100644 --- a/omx/gstomxbufferpool.c +++ b/omx/gstomxbufferpool.c @@ -669,7 +669,7 @@ gst_omx_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer) gst_omx_error_to_string (err), err)); } } else if (pool->port->port_def.eDir == OMX_DirInput) { - g_queue_push_tail (&pool->port->pending_buffers, omx_buf); + gst_omx_port_requeue_buffer (pool->port, omx_buf); } } } |