From a50700404ad05f4537665a9667ba0b9d0df3a21d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 6 Mar 2013 10:53:59 +0100 Subject: [PATCH] eglglessink: Make sure to set the NO_SHARE flag on the EGLImage memories See https://bugzilla.gnome.org/show_bug.cgi?id=695203 --- ext/eglgles/gsteglglessink.c | 50 ++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/ext/eglgles/gsteglglessink.c b/ext/eglgles/gsteglglessink.c index 44289af57a..f956ae6e2c 100644 --- a/ext/eglgles/gsteglglessink.c +++ b/ext/eglgles/gsteglglessink.c @@ -302,15 +302,15 @@ static const char *frag_NV12_NV21_prog = { }; /* *INDENT-ON* */ - static const EGLint eglglessink_RGBA8888_attribs[] = { - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, 8, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_NONE - }; +static const EGLint eglglessink_RGBA8888_attribs[] = { + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_NONE +}; /* Input capabilities. */ static GstStaticPadTemplate gst_eglglessink_sink_template_factory = @@ -2889,10 +2889,16 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, gsize offset[3]; GstMemory *mem[3] = { NULL, NULL, NULL }; guint n_mem; + GstMemoryFlags flags = 0; memset (stride, 0, sizeof (stride)); memset (offset, 0, sizeof (offset)); + if (!gst_egl_image_memory_is_mappable ()) + flags |= GST_MEMORY_FLAG_NOT_MAPPABLE; + /* See https://bugzilla.gnome.org/show_bug.cgi?id=695203 */ + flags |= GST_MEMORY_FLAG_NO_SHARE; + gst_video_info_set_format (&info, format, width, height); switch (format) { @@ -2909,6 +2915,7 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, if (mem[0]) { stride[0] = size / GST_VIDEO_INFO_HEIGHT (&info); n_mem = 1; + GST_MINI_OBJECT_FLAG_SET (mem[0], GST_MEMORY_FLAG_NO_SHARE); } else { data = g_slice_new0 (GstEGLGLESImageData); @@ -2954,9 +2961,7 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, gst_egl_image_allocator_wrap (GST_EGL_IMAGE_BUFFER_POOL (eglglessink->pool)->allocator, eglglessink->eglglesctx.display, image, GST_EGL_IMAGE_MEMORY_TYPE_RGB, - (gst_egl_image_memory_is_mappable ()? 0 : - GST_MEMORY_FLAG_NOT_MAPPABLE), size, data, - (GDestroyNotify) gst_egl_gles_image_data_free); + flags, size, data, (GDestroyNotify) gst_egl_gles_image_data_free); n_mem = 1; } break; @@ -2973,6 +2978,7 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, if (mem[0]) { stride[0] = size / GST_VIDEO_INFO_HEIGHT (&info); n_mem = 1; + GST_MINI_OBJECT_FLAG_SET (mem[0], GST_MEMORY_FLAG_NO_SHARE); } else { data = g_slice_new0 (GstEGLGLESImageData); @@ -3019,9 +3025,7 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, gst_egl_image_allocator_wrap (GST_EGL_IMAGE_BUFFER_POOL (eglglessink->pool)->allocator, eglglessink->eglglesctx.display, image, GST_EGL_IMAGE_MEMORY_TYPE_RGB, - (gst_egl_image_memory_is_mappable ()? 0 : - GST_MEMORY_FLAG_NOT_MAPPABLE), size, data, - (GDestroyNotify) gst_egl_gles_image_data_free); + flags, size, data, (GDestroyNotify) gst_egl_gles_image_data_free); n_mem = 1; } break; @@ -3048,6 +3052,8 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, offset[1] = size[0]; stride[1] = size[1] / GST_VIDEO_INFO_HEIGHT (&info); n_mem = 2; + GST_MINI_OBJECT_FLAG_SET (mem[0], GST_MEMORY_FLAG_NO_SHARE); + GST_MINI_OBJECT_FLAG_SET (mem[1], GST_MEMORY_FLAG_NO_SHARE); } else { if (mem[0]) gst_memory_unref (mem[0]); @@ -3113,8 +3119,7 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, (i == 0 ? GST_EGL_IMAGE_MEMORY_TYPE_LUMINANCE : GST_EGL_IMAGE_MEMORY_TYPE_LUMINANCE_ALPHA), - (gst_egl_image_memory_is_mappable ()? 0 : - GST_MEMORY_FLAG_NOT_MAPPABLE), size[i], data, + flags, size[i], data, (GDestroyNotify) gst_egl_gles_image_data_free); } @@ -3153,6 +3158,9 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, offset[2] = size[1]; stride[2] = size[2] / GST_VIDEO_INFO_HEIGHT (&info); n_mem = 3; + GST_MINI_OBJECT_FLAG_SET (mem[0], GST_MEMORY_FLAG_NO_SHARE); + GST_MINI_OBJECT_FLAG_SET (mem[1], GST_MEMORY_FLAG_NO_SHARE); + GST_MINI_OBJECT_FLAG_SET (mem[2], GST_MEMORY_FLAG_NO_SHARE); } else { if (mem[0]) gst_memory_unref (mem[0]); @@ -3215,8 +3223,7 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, gst_egl_image_allocator_wrap (GST_EGL_IMAGE_BUFFER_POOL (eglglessink->pool)->allocator, eglglessink->eglglesctx.display, image, GST_EGL_IMAGE_MEMORY_TYPE_LUMINANCE, - (gst_egl_image_memory_is_mappable ()? 0 : - GST_MEMORY_FLAG_NOT_MAPPABLE), size[i], data, + flags, size[i], data, (GDestroyNotify) gst_egl_gles_image_data_free); } @@ -3244,6 +3251,7 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, if (mem[0]) { stride[0] = size / GST_VIDEO_INFO_HEIGHT (&info); n_mem = 1; + GST_MINI_OBJECT_FLAG_SET (mem[0], GST_MEMORY_FLAG_NO_SHARE); } else { data = g_slice_new0 (GstEGLGLESImageData); @@ -3289,9 +3297,7 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, gst_egl_image_allocator_wrap (GST_EGL_IMAGE_BUFFER_POOL (eglglessink->pool)->allocator, eglglessink->eglglesctx.display, image, GST_EGL_IMAGE_MEMORY_TYPE_RGBA, - (gst_egl_image_memory_is_mappable ()? 0 : - GST_MEMORY_FLAG_NOT_MAPPABLE), size, data, - (GDestroyNotify) gst_egl_gles_image_data_free); + flags, size, data, (GDestroyNotify) gst_egl_gles_image_data_free); n_mem = 1; } -- 2.34.1