summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@igalia.com>2018-11-25 11:31:11 -0300
committerTim-Philipp Müller <tim@centricular.com>2019-05-01 20:47:26 +0100
commit7da0617234a4c323d7586d298835884db7daa8a0 (patch)
treeed4576c2827a66163dff301837fe144d32bb9875
parent2de93aa088b7816936aa55ac5896e7232b041b61 (diff)
downloadgstreamer-plugins-good-7da0617234a4c323d7586d298835884db7daa8a0.tar.gz
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
-rw-r--r--gst/videocrop/gstaspectratiocrop.c34
-rw-r--r--gst/videocrop/gstaspectratiocrop.h2
2 files changed, 31 insertions, 5 deletions
diff --git a/gst/videocrop/gstaspectratiocrop.c b/gst/videocrop/gstaspectratiocrop.c
index 2c1d9d774..c4cffa1c2 100644
--- a/gst/videocrop/gstaspectratiocrop.c
+++ b/gst/videocrop/gstaspectratiocrop.c
@@ -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_caps_replace (&aspect_ratio_crop->renegotiation_caps, NULL);
+ aspect_ratio_crop->renegotiation_caps =
+ gst_pad_get_current_caps (aspect_ratio_crop->sink);
+ GST_OBJECT_UNLOCK (aspect_ratio_crop);
}
}
diff --git a/gst/videocrop/gstaspectratiocrop.h b/gst/videocrop/gstaspectratiocrop.h
index 2caeb5ce9..9cb2ef7f2 100644
--- a/gst/videocrop/gstaspectratiocrop.h
+++ b/gst/videocrop/gstaspectratiocrop.h
@@ -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;
};