diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2018-08-16 10:02:42 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2018-08-16 10:03:19 +0300 |
commit | dad8f75f87647d5da5e5c9bbad22445bee00a378 (patch) | |
tree | 4e6f6ab4f4bfc50894451c34e867aa1f4aa18bc5 | |
parent | 546dd512e8e321bcfa12fb19aaa98050c9ffddf8 (diff) |
videoaggregator: Make sure to hold object lock while iterating sink pads
They might otherwise just change while we iterate.
-rw-r--r-- | gst-libs/gst/video/gstvideoaggregator.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/gst-libs/gst/video/gstvideoaggregator.c b/gst-libs/gst/video/gstvideoaggregator.c index dafd59d93..2ade7da9f 100644 --- a/gst-libs/gst/video/gstvideoaggregator.c +++ b/gst-libs/gst/video/gstvideoaggregator.c @@ -950,6 +950,20 @@ gst_video_aggregator_default_update_src_caps (GstAggregator * agg, } static gboolean +_update_conversion_info (GstElement * element, GstPad * pad, gpointer user_data) +{ + GstVideoAggregatorPad *vaggpad = GST_VIDEO_AGGREGATOR_PAD (pad); + GstVideoAggregatorPadClass *vaggpad_klass = + GST_VIDEO_AGGREGATOR_PAD_GET_CLASS (vaggpad); + + if (vaggpad_klass->update_conversion_info) { + vaggpad_klass->update_conversion_info (vaggpad); + } + + return TRUE; +} + +static gboolean gst_video_aggregator_default_negotiated_src_caps (GstAggregator * agg, GstCaps * caps) { @@ -1001,15 +1015,8 @@ gst_video_aggregator_default_negotiated_src_caps (GstAggregator * agg, } /* Then browse the sinks once more, setting or unsetting conversion if needed */ - for (l = GST_ELEMENT (vagg)->sinkpads; l; l = l->next) { - GstVideoAggregatorPad *pad = GST_VIDEO_AGGREGATOR_PAD (l->data); - GstVideoAggregatorPadClass *vaggpad_klass = - GST_VIDEO_AGGREGATOR_PAD_GET_CLASS (pad); - - if (vaggpad_klass->update_conversion_info) { - vaggpad_klass->update_conversion_info (pad); - } - } + gst_element_foreach_sink_pad (GST_ELEMENT_CAST (vagg), + _update_conversion_info, NULL); if (vagg->priv->current_caps == NULL || gst_caps_is_equal (caps, vagg->priv->current_caps) == FALSE) { @@ -1032,6 +1039,7 @@ gst_video_aggregator_get_sinkpads_interlace_mode (GstVideoAggregator * vagg, { GList *walk; + GST_OBJECT_LOCK (vagg); for (walk = GST_ELEMENT (vagg)->sinkpads; walk; walk = g_list_next (walk)) { GstVideoAggregatorPad *vaggpad = walk->data; @@ -1040,9 +1048,11 @@ gst_video_aggregator_get_sinkpads_interlace_mode (GstVideoAggregator * vagg, if (vaggpad->info.finfo && GST_VIDEO_INFO_FORMAT (&vaggpad->info) != GST_VIDEO_FORMAT_UNKNOWN) { *mode = GST_VIDEO_INFO_INTERLACE_MODE (&vaggpad->info); + GST_OBJECT_UNLOCK (vagg); return TRUE; } } + GST_OBJECT_UNLOCK (vagg); return FALSE; } |