qmlglsink: fix another resize case
authorMatthew Waters <matthew@centricular.com>
Mon, 15 Nov 2021 03:39:14 +0000 (14:39 +1100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 17 Nov 2021 03:08:14 +0000 (03:08 +0000)
If qt asks us to redraw before we have both set a buffer and caps we
would attempt to use the new caps with the old buffer which could result
in bad things happening.

Only update caps from new_caps once the buffer has actually been set.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1346>

subprojects/gst-plugins-good/ext/qt/qtitem.cc

index 0bc5896..a5a548f 100644 (file)
@@ -285,19 +285,6 @@ QtGLVideoItem::updatePaintNode(QSGNode * oldNode,
 
   GST_TRACE ("%p updatePaintNode", this);
 
-  if (this->priv->new_caps) {
-    GST_DEBUG ("%p caps change from %" GST_PTR_FORMAT " to %" GST_PTR_FORMAT,
-        this, this->priv->caps, this->priv->new_caps);
-    gst_caps_take (&this->priv->caps, this->priv->new_caps);
-    this->priv->new_caps = NULL;
-    this->priv->v_info = this->priv->new_v_info;
-
-    if (!_calculate_par (this, &this->priv->v_info)) {
-      g_mutex_unlock (&this->priv->lock);
-      return NULL;
-    }
-  }
-
   if (!this->priv->caps) {
     GST_LOG ("%p no caps yet", this);
     g_mutex_unlock (&this->priv->lock);
@@ -580,6 +567,19 @@ QtGLVideoItemInterface::setBuffer (GstBuffer * buffer)
 
   g_mutex_lock (&qt_item->priv->lock);
 
+  if (qt_item->priv->new_caps) {
+    GST_DEBUG ("%p caps change from %" GST_PTR_FORMAT " to %" GST_PTR_FORMAT,
+        this, qt_item->priv->caps, qt_item->priv->new_caps);
+    gst_caps_take (&qt_item->priv->caps, qt_item->priv->new_caps);
+    qt_item->priv->new_caps = NULL;
+    qt_item->priv->v_info = qt_item->priv->new_v_info;
+
+    if (!_calculate_par (qt_item, &qt_item->priv->v_info)) {
+      g_mutex_unlock (&qt_item->priv->lock);
+      return;
+    }
+  }
+
   gst_buffer_replace (&qt_item->priv->buffer, buffer);
 
   QMetaObject::invokeMethod(qt_item, "update", Qt::QueuedConnection);