From dfccbd52f4b3bc5b7f642b4edf85b5ba139d4afa Mon Sep 17 00:00:00 2001 From: He Junyan Date: Fri, 6 Sep 2024 23:35:59 +0800 Subject: [PATCH] va: vpp: Use gst_caps_replace to operate the filter_caps No need to use lock when we assign value to priv->filter_caps. Part-of: --- .../sys/va/gstvabasetransform.c | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c b/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c index 8ac2f08c30..b249d33be0 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c @@ -881,20 +881,25 @@ bail: GstCaps * gst_va_base_transform_get_filter_caps (GstVaBaseTransform * self) { + GstCaps *ret = NULL; + g_return_val_if_fail (GST_IS_VA_BASE_TRANSFORM (self), NULL); - GST_OBJECT_LOCK (self); - if (self->priv->filter_caps) { - GST_OBJECT_UNLOCK (self); - return self->priv->filter_caps; + gst_caps_replace (&ret, self->priv->filter_caps); + + if (ret) { + /* Release the extra reference. */ + gst_caps_unref (ret); + return ret; } - GST_OBJECT_UNLOCK (self); if (!self->filter) return NULL; - GST_OBJECT_LOCK (self); - self->priv->filter_caps = gst_va_filter_get_caps (self->filter); - GST_OBJECT_UNLOCK (self); - return self->priv->filter_caps; + ret = gst_va_filter_get_caps (self->filter); + /* We do not cmp and assign here, just use our new value. */ + gst_caps_replace (&self->priv->filter_caps, ret); + /* Release the extra got reference. */ + gst_caps_unref (ret); + return ret; }