diff --git a/ext/gtk/gtkgstglwidget.c b/ext/gtk/gtkgstglwidget.c index c4d53a2b09..c9ad0b63fb 100644 --- a/ext/gtk/gtkgstglwidget.c +++ b/ext/gtk/gtkgstglwidget.c @@ -260,6 +260,7 @@ gtk_gst_gl_widget_render (GtkGLArea * widget, GdkGLContext * context) sync_meta = gst_buffer_get_gl_sync_meta (buffer); if (sync_meta) { + /* XXX: the set_sync() seems to be needed for resizing */ gst_gl_sync_meta_set_sync_point (sync_meta, priv->context); gst_gl_sync_meta_wait (sync_meta, priv->other_context); } diff --git a/gst-libs/gst/gl/gstglsyncmeta.c b/gst-libs/gst/gl/gstglsyncmeta.c index 60b1ee493a..ab0e8c28a0 100644 --- a/gst-libs/gst/gl/gstglsyncmeta.c +++ b/gst-libs/gst/gl/gstglsyncmeta.c @@ -56,12 +56,25 @@ _default_set_sync_gl (GstGLSyncMeta * sync_meta, GstGLContext * context) gl->Flush (); GST_LOG ("setting sync object %p", sync_meta->data); } else { + /* XXX: this a little over the top if the CPU is never going to + * access the data, however this is the legacy path, so... */ gl->Finish (); } } static void _default_wait_gl (GstGLSyncMeta * sync_meta, GstGLContext * context) +{ + const GstGLFuncs *gl = context->gl_vtable; + + if (sync_meta->data && gl->WaitSync) { + GST_LOG ("waiting on sync object %p", sync_meta->data); + gl->WaitSync ((GLsync) sync_meta->data, 0, GL_TIMEOUT_IGNORED); + } +} + +static void +_default_wait_cpu_gl (GstGLSyncMeta * sync_meta, GstGLContext * context) { const GstGLFuncs *gl = context->gl_vtable; GLenum res; @@ -129,6 +142,7 @@ gst_buffer_add_gl_sync_meta (GstGLContext * context, GstBuffer * buffer) ret->set_sync_gl = _default_set_sync_gl; ret->wait_gl = _default_wait_gl; + ret->wait_cpu_gl = _default_wait_cpu_gl; ret->copy = _default_copy; ret->free_gl = _default_free_gl; @@ -174,6 +188,25 @@ gst_gl_sync_meta_wait (GstGLSyncMeta * sync_meta, GstGLContext * context) (GstGLContextThreadFunc) _wait, sync_meta); } +static void +_wait_cpu (GstGLContext * context, GstGLSyncMeta * sync_meta) +{ + g_assert (sync_meta->wait_cpu_gl != NULL); + + GST_LOG ("waiting %p", sync_meta); + sync_meta->wait_cpu_gl (sync_meta, context); +} + +void +gst_gl_sync_meta_wait_cpu (GstGLSyncMeta * sync_meta, GstGLContext * context) +{ + if (sync_meta->wait_cpu) + sync_meta->wait_cpu (sync_meta, context); + else + gst_gl_context_thread_add (context, + (GstGLContextThreadFunc) _wait_cpu, sync_meta); +} + static gboolean _gst_gl_sync_meta_transform (GstBuffer * dest, GstMeta * meta, GstBuffer * buffer, GQuark type, gpointer data) @@ -197,6 +230,8 @@ _gst_gl_sync_meta_transform (GstBuffer * dest, GstMeta * meta, dmeta->set_sync_gl = smeta->set_sync_gl; dmeta->wait = smeta->wait; dmeta->wait_gl = smeta->wait_gl; + dmeta->wait_cpu = smeta->wait_cpu; + dmeta->wait_cpu_gl = smeta->wait_cpu_gl; dmeta->copy = smeta->copy; dmeta->free = smeta->free; dmeta->free_gl = smeta->free_gl; @@ -251,6 +286,8 @@ _gst_gl_sync_meta_init (GstGLSyncMeta * sync_meta, gpointer params, sync_meta->set_sync_gl = NULL; sync_meta->wait = NULL; sync_meta->wait_gl = NULL; + sync_meta->wait_cpu = NULL; + sync_meta->wait_cpu_gl = NULL; sync_meta->copy = NULL; sync_meta->free = NULL; sync_meta->free_gl = NULL; diff --git a/gst-libs/gst/gl/gstglsyncmeta.h b/gst-libs/gst/gl/gstglsyncmeta.h index 8620ccdfcc..e5eb17b30b 100644 --- a/gst-libs/gst/gl/gstglsyncmeta.h +++ b/gst-libs/gst/gl/gstglsyncmeta.h @@ -42,6 +42,8 @@ struct _GstGLSyncMeta { void (*set_sync_gl) (GstGLSyncMeta * sync, GstGLContext * context); void (*wait) (GstGLSyncMeta * sync, GstGLContext * context); void (*wait_gl) (GstGLSyncMeta * sync, GstGLContext * context); + void (*wait_cpu) (GstGLSyncMeta * sync, GstGLContext * context); + void (*wait_cpu_gl) (GstGLSyncMeta * sync, GstGLContext * context); void (*copy) (GstGLSyncMeta * src, GstBuffer * sbuffer, GstGLSyncMeta * dest, GstBuffer * dbuffer); void (*free) (GstGLSyncMeta * sync, GstGLContext * context); void (*free_gl) (GstGLSyncMeta * sync, GstGLContext * context); @@ -57,6 +59,7 @@ GstGLSyncMeta * gst_buffer_add_gl_sync_meta_full (GstGLContext * context, gpointer data); void gst_gl_sync_meta_set_sync_point (GstGLSyncMeta * sync, GstGLContext * context); void gst_gl_sync_meta_wait (GstGLSyncMeta * sync, GstGLContext * context); +void gst_gl_sync_meta_wait_cpu (GstGLSyncMeta * sync, GstGLContext * context); G_END_DECLS diff --git a/sys/androidmedia/gstamcvideodec.c b/sys/androidmedia/gstamcvideodec.c index 9d6c6f70a8..f024b4cf1b 100644 --- a/sys/androidmedia/gstamcvideodec.c +++ b/sys/androidmedia/gstamcvideodec.c @@ -490,7 +490,7 @@ gst_amc_video_dec_close (GstVideoDecoder * decoder) GError *err = NULL; if (!gst_amc_jni_call_void_method (env, &err, self->listener, - self->set_context_id, GST_AMC_VIDEO_DEC_TO_JLONG (NULL))) { + self->set_context_id, GST_AMC_VIDEO_DEC_TO_JLONG (NULL))) { GST_ERROR_OBJECT (self, "Failed to unset back pointer on the listener. " "crashes/hangs may ensue: %s", err ? err->message : "Unknown"); GST_ELEMENT_ERROR_FROM_ERROR (self, err); @@ -1010,8 +1010,8 @@ _gl_sync_render_unlocked (struct gl_sync *sync) if (!af_meta) { GST_WARNING ("Failed to retreive the transformation meta from the " "gl_sync %p buffer %p", sync, sync->buffer); - } else if (gst_amc_surface_texture_get_transform_matrix (sync->surface-> - texture, matrix, &error)) { + } else if (gst_amc_surface_texture_get_transform_matrix (sync-> + surface->texture, matrix, &error)) { gst_video_affine_transformation_meta_apply_matrix (af_meta, matrix); gst_video_affine_transformation_meta_apply_matrix (af_meta, yflip_matrix); @@ -1370,6 +1370,7 @@ retry: sync); sync_meta->set_sync = _amc_gl_set_sync; sync_meta->wait = _amc_gl_wait; + sync_meta->wait_cpu = _amc_gl_wait; sync_meta->copy = _amc_gl_copy; sync_meta->free = _amc_gl_free; @@ -1974,7 +1975,7 @@ gst_amc_video_dec_set_format (GstVideoDecoder * decoder, if (self->listener) { if (!gst_amc_jni_call_void_method (env, &err, self->listener, - self->set_context_id, GST_AMC_VIDEO_DEC_TO_JLONG (NULL))) { + self->set_context_id, GST_AMC_VIDEO_DEC_TO_JLONG (NULL))) { ret = FALSE; goto done; }