v4l2: Fix threading issues in orphaning mechanism

The pool orphaning function was calling 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).

Edited by Nicolas Dufresne

Merge request reports