From 7c49ce1c217d607e929594d7b9d07e5e812cc51e Mon Sep 17 00:00:00 2001 From: Matthias Fuchs Date: Tue, 17 Oct 2023 15:24:22 +0200 Subject: [PATCH] qmlglsrc: sync on the streaming thread After rendering a QML scene the qmlglsrc 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 qmlglsrc 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. Part-of: --- subprojects/gst-plugins-good/ext/qt/gstqtsrc.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/subprojects/gst-plugins-good/ext/qt/gstqtsrc.cc b/subprojects/gst-plugins-good/ext/qt/gstqtsrc.cc index a405172925..159d6ef747 100644 --- a/subprojects/gst-plugins-good/ext/qt/gstqtsrc.cc +++ b/subprojects/gst-plugins-good/ext/qt/gstqtsrc.cc @@ -434,6 +434,8 @@ static GstFlowReturn gst_qt_src_fill (GstPushSrc * psrc, GstBuffer * buffer) { GstQtSrc *qt_src = GST_QT_SRC (psrc); + GstGLContext* context = qt_src->context; + GstGLSyncMeta *sync_meta; GST_DEBUG_OBJECT (qt_src, "setting buffer %p", buffer); @@ -442,6 +444,10 @@ gst_qt_src_fill (GstPushSrc * psrc, GstBuffer * buffer) return GST_FLOW_ERROR; } + 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 */ -- 2.34.1