Commit eb2b58cc authored by Thibault Saunier's avatar Thibault Saunier

aspectcropratio: Set caps from the streaming thread on property changes

Otherwise it might lead to deadlocks

See https://gitlab.gnome.org/GNOME/pitivi/issues/2259

Closes #518
parent 21378d83
Pipeline #9913 passed with stages
in 6 minutes and 10 seconds
......@@ -205,10 +205,32 @@ gst_aspect_ratio_crop_finalize (GObject * object)
aspect_ratio_crop = GST_ASPECT_RATIO_CROP (object);
g_mutex_clear (&aspect_ratio_crop->crop_lock);
gst_caps_unref (aspect_ratio_crop->renegotiation_caps);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static GstFlowReturn
gst_aspect_ratio_crop_sink_chain (GstPad * pad, GstObject * parent,
GstBuffer * buffer)
{
GstCaps *caps = NULL;
GstAspectRatioCrop *aspect_ratio_crop = GST_ASPECT_RATIO_CROP (parent);
GST_OBJECT_LOCK (parent);
caps = aspect_ratio_crop->renegotiation_caps;
aspect_ratio_crop->renegotiation_caps = NULL;
GST_OBJECT_UNLOCK (parent);
if (caps) {
gst_aspect_ratio_crop_set_caps (GST_ASPECT_RATIO_CROP (parent), caps);
gst_caps_unref (caps);
}
return gst_proxy_pad_chain_default (pad, parent, buffer);
}
static void
gst_aspect_ratio_crop_init (GstAspectRatioCrop * aspect_ratio_crop)
{
......@@ -247,6 +269,8 @@ gst_aspect_ratio_crop_init (GstAspectRatioCrop * aspect_ratio_crop)
gst_pad_set_event_function (aspect_ratio_crop->sink,
GST_DEBUG_FUNCPTR (gst_aspect_ratio_crop_sink_event));
gst_pad_set_chain_function (aspect_ratio_crop->sink,
GST_DEBUG_FUNCPTR (gst_aspect_ratio_crop_sink_chain));
}
static void
......@@ -461,11 +485,11 @@ gst_aspect_ratio_crop_set_property (GObject * object, guint prop_id,
GST_OBJECT_UNLOCK (aspect_ratio_crop);
if (recheck) {
GstCaps *caps = gst_pad_get_current_caps (aspect_ratio_crop->sink);
if (caps != NULL) {
gst_aspect_ratio_crop_set_caps (aspect_ratio_crop, caps);
gst_caps_unref (caps);
}
GST_OBJECT_LOCK (aspect_ratio_crop);
gst_clear_caps (&aspect_ratio_crop->renegotiation_caps);
aspect_ratio_crop->renegotiation_caps =
gst_pad_get_current_caps (aspect_ratio_crop->sink);
GST_OBJECT_UNLOCK (aspect_ratio_crop);
}
}
......
......@@ -51,6 +51,8 @@ struct _GstAspectRatioCrop
gint ar_num; /* if < 1 then don't change ar */
gint ar_denom;
GstCaps *renegotiation_caps;
GMutex crop_lock;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment