qmlglsink: fix another resize case

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>
This commit is contained in:
Matthew Waters 2021-11-15 14:39:14 +11:00 committed by GStreamer Marge Bot
parent a6fd767025
commit 55e04d129f

View 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);