This should ensure thread safety. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1088>