v4l2: Fix threading issues in orphaning mechanism
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Thu, 25 Jun 2020 18:15:51 +0000 (14:15 -0400)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Sun, 28 Jun 2020 15:12:07 +0000 (15:12 +0000)
commitca61a76987e566555a2f7bc0f4c1bcf3a8ad6dcd
tree0475709227c35daba1b2818fd46eeee08c361df7
parent71204f2c3b113a47eba63a600ef36f9e29ced38e
v4l2: Fix threading issues in orphaning mechanism

The pool orphaning function was colling internal _stop() virtual function
implementation. This is not thread safe, as a private lock inside the buffer
pool is supposed to be held. Fix this by keeping delayed _stop() and orphaning
the GstV4L2Allocator instead (REQBUFS(0)).

Then, protect the orphaned boolean with the object lock for the case a buffer
is being released after we have orphaned the buffer. That would otherwise
cause a QBUF to happen while the queue is no longer owned by the buffer pool.
This boolean is otherwise used and set from the streaming lock, or after
threads have been stopped (final cleanup).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/648>
sys/v4l2/gstv4l2bufferpool.c