From 4211e4c29a262f110cb92ddf9c06b403ced233ef Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 24 Oct 2017 12:19:50 +0200 Subject: [PATCH] omx: wait for flush complete and buffers being released when flushing As stated in the existing comment, when flusing we should wait for OMX to send the flush command complete event AND all ports being released. We were stopping as soon as one of those condition was met. Fix a race between FillThisBufferDone/EmptyBufferDone and the flush EventCmdComplete messages. The OMX implementation is supposed to release its buffers before posting the EventCmdComplete event but the ordering isn't guaranteed as the FillThisBufferDone/EmptyBufferDone and EventHandler callbacks can be called from different threads (cf 2.7 'Thread Safety' in the spec). https://bugzilla.gnome.org/show_bug.cgi?id=789475 --- omx/gstomx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omx/gstomx.c b/omx/gstomx.c index 6629d33432..fc17ac8d5e 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -1562,7 +1562,7 @@ gst_omx_port_set_flushing (GstOMXPort * port, GstClockTime timeout, signalled = TRUE; last_error = OMX_ErrorNone; gst_omx_component_handle_messages (comp); - while (!port->flushed && + while (!port->flushed || (port->buffers && port->buffers->len > g_queue_get_length (&port->pending_buffers))) {