omx: wait for flush complete and buffers being released when flushing
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 22 Aug 2018 13:56:18 +0000 (15:56 +0200)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 29 Aug 2018 16:18:39 +0000 (12:18 -0400)
commit40ae47df5e6668231ce6d48c8ba83c2eb1790521
tree82a1222514b319a3f9db55a2a1c872ca45c1c955
parent3d55051da3deacc382dd889c2304835e1d51be6c
omx: wait for flush complete and buffers being released when flushing

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).

Only wait for buffers currently used by OMX as some buffers may not be
in the pending queue because they are held downstream.

https://bugzilla.gnome.org/show_bug.cgi?id=789475
omx/gstomx.c