From 2bbc2a4c52d2a51c97c47f3c94eab922d0b2a5a6 Mon Sep 17 00:00:00 2001 From: Matthias Fuchs Date: Fri, 20 Oct 2023 08:14:40 +0200 Subject: [PATCH] qml6glsrc: sync on the streaming thread After rendering a QML scene the qml6glsrc element copies the contents of the scene to a GStreamer buffer. This happens on the Qt render thread. Then it attaches a sync point to the destination buffer. This sync point must be awaited by other threads which use the buffer later on. The current implementation relies on the downstream elements to wait for the sync point. However, there are situation where this does not work. The GstBaseTransform e.g. copies the buffer metadata (which overwrites the sync point without waiting for it) *before* waiting for the sync point. This commit waits for the sync point inside the qml6glsrc element before sending it downstream. The wait command is issued on the streaming thread with the pipeline OpenGL context, i.e. it will synchronize with the GStreamer OpenGL thread. This is a port of the original fix for the qmlglsrc element. Part-of: --- subprojects/gst-plugins-good/ext/qt6/gstqml6glsrc.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/subprojects/gst-plugins-good/ext/qt6/gstqml6glsrc.cc b/subprojects/gst-plugins-good/ext/qt6/gstqml6glsrc.cc index 327bec86b2..dbd76844bf 100644 --- a/subprojects/gst-plugins-good/ext/qt6/gstqml6glsrc.cc +++ b/subprojects/gst-plugins-good/ext/qt6/gstqml6glsrc.cc @@ -436,6 +436,8 @@ gst_qml6_gl_src_create (GstPushSrc * psrc, GstBuffer ** buffer) { GstQml6GLSrc *qt_src = GST_QML6_GL_SRC (psrc); GstCaps *updated_caps = NULL; + GstGLContext* context = qt_src->context; + GstGLSyncMeta *sync_meta; *buffer = qt6_gl_window_take_buffer (qt_src->window, &updated_caps); GST_DEBUG_OBJECT (qt_src, "produced buffer %p", *buffer); @@ -448,6 +450,10 @@ gst_qml6_gl_src_create (GstPushSrc * psrc, GstBuffer ** buffer) } gst_clear_caps (&updated_caps); + sync_meta = gst_buffer_get_gl_sync_meta(*buffer); + if (sync_meta) + gst_gl_sync_meta_wait(sync_meta, context); + if (!qt_src->downstream_supports_affine_meta) { if (qt_src->pending_image_orientation) { /* let downstream know the image orientation is vertical filp */