appsrc/appsink: Make setting/replacing callbacks thread-safe
authorSebastian Dröge <sebastian@centricular.com>
Wed, 12 Feb 2020 11:11:43 +0000 (13:11 +0200)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 14 Feb 2020 14:42:19 +0000 (14:42 +0000)
commit9a55945c0bbb43ee8cd336e90c31edeb35614720
tree360343bcdc26c0e2378344bc8544abf06213bf85
parent85e201fe301f2c946cdb209671fcf27750208a66
appsrc/appsink: Make setting/replacing callbacks thread-safe

Previously we would simply use them without any locking at all, while
using the object lock for setting them. Nothing prevented new callbacks
to be set in the meantime, potentially calling a callback with already
freed user_data.

To prevent this move the callbacks into a reference counted struct and
use the appsrc/appsink mutex to protect access to it, which is used in
all functions calling the callbacks already anyway.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/729
gst-libs/gst/app/gstappsink.c
gst-libs/gst/app/gstappsrc.c