gldownload: Wait on sync meta if any
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Sat, 3 Aug 2019 17:14:53 +0000 (13:14 -0400)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Mon, 11 Nov 2019 22:01:18 +0000 (17:01 -0500)
This is possibly not strictly needed when pixels are being downloaded to
CPU memory, but would cause issue when exporting DMABuf, as the data may
not be yet ready when the DMABuf reaches the consumer.

ext/gl/gstgldownloadelement.c

index 7541ae6..b7cf474 100644 (file)
@@ -414,7 +414,15 @@ gst_gl_download_element_prepare_output_buffer (GstBaseTransform * bt,
 #if GST_GL_HAVE_PLATFORM_EGL && GST_GL_HAVE_DMABUF
   else if (dl->dmabuf_allocator) {
     GstBuffer *buffer = _try_export_dmabuf (dl, inbuf);
+
     if (buffer) {
+      GstGLContext *context = GST_GL_BASE_FILTER (bt)->context;
+      GstGLSyncMeta *in_sync_meta;
+
+      in_sync_meta = gst_buffer_get_gl_sync_meta (inbuf);
+      if (in_sync_meta)
+        gst_gl_sync_meta_wait (in_sync_meta, context);
+
       if (GST_BASE_TRANSFORM_GET_CLASS (bt)->copy_metadata)
         if (!GST_BASE_TRANSFORM_GET_CLASS (bt)->copy_metadata (bt, inbuf,
                 buffer)) {