summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu@centricular.com>2020-10-28 01:19:37 +0100
committerTim-Philipp Müller <tim@centricular.com>2020-10-29 23:55:32 +0000
commitc9beed35b31f9f8df60ca47bebae0079e3d52c6a (patch)
treec8c47d346b24ea391237917e5f0e002c6e79d20c
parent2a116c0eb58bc8cfbe27da16b6289b5a9deb9782 (diff)
downloadgstreamer-plugins-base-c9beed35b31f9f8df60ca47bebae0079e3d52c6a.tar.gz
videoaggregator: document and fix locking in convert pad
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/904>
-rw-r--r--gst-libs/gst/video/gstvideoaggregator.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gst-libs/gst/video/gstvideoaggregator.c b/gst-libs/gst/video/gstvideoaggregator.c
index 2ce791f77..b334f40e0 100644
--- a/gst-libs/gst/video/gstvideoaggregator.c
+++ b/gst-libs/gst/video/gstvideoaggregator.c
@@ -401,6 +401,9 @@ enum
struct _GstVideoAggregatorConvertPadPrivate
{
+ /* The following fields are only used from the aggregate thread and when
+ * initializing / finalizing */
+
/* Converter, if NULL no conversion is done */
GstVideoConverter *convert;
@@ -408,6 +411,8 @@ struct _GstVideoAggregatorConvertPadPrivate
GstVideoInfo conversion_info;
GstBuffer *converted_buffer;
+ /* The following fields are accessed from the property setters / getters,
+ * and as such are protected with the object lock */
GstStructure *converter_config;
gboolean converter_config_changed;
};
@@ -437,7 +442,9 @@ static void
{
GstVideoAggregatorConvertPad *pad = GST_VIDEO_AGGREGATOR_CONVERT_PAD (vpad);
+ GST_OBJECT_LOCK (pad);
pad->priv->converter_config_changed = TRUE;
+ GST_OBJECT_UNLOCK (pad);
}
static gboolean
@@ -449,6 +456,7 @@ gst_video_aggregator_convert_pad_prepare_frame (GstVideoAggregatorPad * vpad,
GstVideoFrame frame;
/* Update/create converter as needed */
+ GST_OBJECT_LOCK (pad);
if (pad->priv->converter_config_changed) {
GstVideoAggregatorConvertPadClass *klass =
GST_VIDEO_AGGREGATOR_CONVERT_PAD_GET_CLASS (pad);
@@ -484,6 +492,7 @@ gst_video_aggregator_convert_pad_prepare_frame (GstVideoAggregatorPad * vpad,
GST_DEBUG_OBJECT (pad, "This pad will not need conversion");
}
}
+ GST_OBJECT_UNLOCK (pad);
if (!gst_video_frame_map (&frame, &vpad->info, buffer, GST_MAP_READ)) {
GST_WARNING_OBJECT (vagg, "Could not map input buffer");
@@ -696,7 +705,9 @@ void gst_video_aggregator_convert_pad_update_conversion_info
{
g_return_if_fail (GST_IS_VIDEO_AGGREGATOR_CONVERT_PAD (pad));
+ GST_OBJECT_LOCK (pad);
pad->priv->converter_config_changed = TRUE;
+ GST_OBJECT_UNLOCK (pad);
}
/**************************************