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
This commit is contained in:
Guillaume Desmottes 2017-10-24 12:19:50 +02:00 committed by Olivier Crête
parent 4c0a8a6d90
commit 4211e4c29a

View file

@ -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))) {