gstreamer: Defer the sync

Don't sync right when we receive the buffer,
pass it along with the texture to be executed
later in the renderer.
This commit is contained in:
Matthias Clasen 2023-04-25 11:44:21 +02:00 committed by Benjamin Otte
parent bec0afa61b
commit b9a7e5fa85

View File

@ -290,18 +290,21 @@ gtk_gst_sink_texture_from_buffer (GtkGstSink *self,
GdkGLTextureBuilder *builder;
sync_meta = gst_buffer_get_gl_sync_meta (buffer);
if (sync_meta) {
if (sync_meta)
gst_gl_sync_meta_set_sync_point (sync_meta, self->gst_context);
gst_gl_context_activate (self->gst_gdk_context, TRUE);
gst_gl_sync_meta_wait (sync_meta, self->gst_gdk_context);
gst_gl_context_activate (self->gst_gdk_context, FALSE);
}
/* Note: using the gdk_context here is a (harmless) lie,
* since the texture really originates in the gst_context.
* But that is not a GdkGLContext. It is harmless, because
* we are never using the texture in the gdk_context, so we
* never make the (erroneous) decision to ignore the sync.
*/
builder = gdk_gl_texture_builder_new ();
gdk_gl_texture_builder_set_context (builder, self->gdk_context);
gdk_gl_texture_builder_set_id (builder, *(guint *) frame->data[0]);
gdk_gl_texture_builder_set_width (builder, frame->info.width);
gdk_gl_texture_builder_set_height (builder, frame->info.height);
gdk_gl_texture_builder_set_sync (builder, sync_meta ? sync_meta->data : NULL);
texture = gdk_gl_texture_builder_build (builder,
(GDestroyNotify) video_frame_free,