qmlglsrc: Unmap buffer before adding sync meta
authorJan Schmidt <jan@centricular.com>
Tue, 20 Dec 2022 15:32:41 +0000 (02:32 +1100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 21 Dec 2022 12:21:32 +0000 (12:21 +0000)
Adding a sync meta to a GstBuffer requires that it
be writable. Mapping the buffer with the video frame API
holds an extra ref on the buffer, so unmap before
trying to modify it.

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

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

index f67f286..ec8f85d 100644 (file)
@@ -236,6 +236,9 @@ QtGLWindow::afterRendering()
     gl->CopyTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, width, height, 0);
   }
 
+  gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
+  gst_video_frame_unmap (&gl_frame);
+
   if (this->priv->context) {
     sync_meta = gst_buffer_get_gl_sync_meta (this->priv->buffer);
     if (!sync_meta) {
@@ -246,16 +249,19 @@ QtGLWindow::afterRendering()
 
   GST_DEBUG ("rendering finished");
 
-errors:
-  gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
-  gst_video_frame_unmap (&gl_frame);
-
+done:
   gst_gl_context_activate (context, FALSE);
 
   this->priv->result = ret;
   this->priv->updated = TRUE;
   g_cond_signal (&this->priv->update_cond);
   g_mutex_unlock (&this->priv->lock);
+  return;
+
+errors:
+  gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
+  gst_video_frame_unmap (&gl_frame);
+  goto done;
 }
 
 void