From a47f52bb962299244537bb0ca8b7c09ecf829785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 22 Feb 2013 13:07:07 +0100 Subject: [PATCH] egl: Mark memory as not mappable if it isn't --- ext/eglgles/gsteglglessink.c | 27 ++++++++++++++++++--------- gst-libs/gst/egl/egl.c | 6 ++++-- gst-libs/gst/egl/egl.h | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/ext/eglgles/gsteglglessink.c b/ext/eglgles/gsteglglessink.c index 77b419cd33..74f535fa09 100644 --- a/ext/eglgles/gsteglglessink.c +++ b/ext/eglgles/gsteglglessink.c @@ -1540,7 +1540,8 @@ gst_eglglessink_init_egl_display (GstEglGlesSink * eglglessink) #ifdef USE_EGL_RPI /* See https://github.com/raspberrypi/firmware/issues/99 */ - if (!eglMakeCurrent ((EGLDisplay) 1, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) { + if (!eglMakeCurrent ((EGLDisplay) 1, EGL_NO_SURFACE, EGL_NO_SURFACE, + EGL_NO_CONTEXT)) { got_egl_error ("eglMakeCurrent"); GST_ERROR_OBJECT (eglglessink, "Couldn't unbind context"); return FALSE; @@ -3048,8 +3049,9 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, mem[0] = gst_egl_image_allocator_wrap (GST_EGL_IMAGE_BUFFER_POOL (eglglessink->pool)->allocator, eglglessink->eglglesctx.display, - image, GST_EGL_IMAGE_MEMORY_TYPE_RGB, size, data, - (GDestroyNotify) gst_egl_gles_image_data_free); + image, GST_EGL_IMAGE_MEMORY_TYPE_RGB, + (gst_egl_image_memory_can_map ()? 0 : GST_MEMORY_FLAG_NOT_MAPPABLE), + size, data, (GDestroyNotify) gst_egl_gles_image_data_free); n_mem = 1; } break; @@ -3111,8 +3113,9 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, mem[0] = gst_egl_image_allocator_wrap (GST_EGL_IMAGE_BUFFER_POOL (eglglessink->pool)->allocator, eglglessink->eglglesctx.display, - image, GST_EGL_IMAGE_MEMORY_TYPE_RGB, size, data, - (GDestroyNotify) gst_egl_gles_image_data_free); + image, GST_EGL_IMAGE_MEMORY_TYPE_RGB, + (gst_egl_image_memory_can_map ()? 0 : GST_MEMORY_FLAG_NOT_MAPPABLE), + size, data, (GDestroyNotify) gst_egl_gles_image_data_free); n_mem = 1; } break; @@ -3203,7 +3206,9 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, image, (i == 0 ? GST_EGL_IMAGE_MEMORY_TYPE_LUMINANCE : - GST_EGL_IMAGE_MEMORY_TYPE_LUMINANCE_ALPHA), size[i], data, + GST_EGL_IMAGE_MEMORY_TYPE_LUMINANCE_ALPHA), + (gst_egl_image_memory_can_map ()? 0 : + GST_MEMORY_FLAG_NOT_MAPPABLE), size[i], data, (GDestroyNotify) gst_egl_gles_image_data_free); } @@ -3303,7 +3308,9 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, mem[i] = gst_egl_image_allocator_wrap (GST_EGL_IMAGE_BUFFER_POOL (eglglessink->pool)->allocator, eglglessink->eglglesctx.display, - image, GST_EGL_IMAGE_MEMORY_TYPE_LUMINANCE, size[i], data, + image, GST_EGL_IMAGE_MEMORY_TYPE_LUMINANCE, + (gst_egl_image_memory_can_map ()? 0 : + GST_MEMORY_FLAG_NOT_MAPPABLE), size[i], data, (GDestroyNotify) gst_egl_gles_image_data_free); } @@ -3375,8 +3382,10 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, mem[0] = gst_egl_image_allocator_wrap (GST_EGL_IMAGE_BUFFER_POOL (eglglessink->pool)->allocator, eglglessink->eglglesctx.display, - image, GST_EGL_IMAGE_MEMORY_TYPE_RGBA, size, data, - (GDestroyNotify) gst_egl_gles_image_data_free); + image, GST_EGL_IMAGE_MEMORY_TYPE_RGBA, + (gst_egl_image_memory_can_map ()? 0 : GST_MEMORY_FLAG_NOT_MAPPABLE), + size, data, (GDestroyNotify) gst_egl_gles_image_data_free); + n_mem = 1; } break; diff --git a/gst-libs/gst/egl/egl.c b/gst-libs/gst/egl/egl.c index 82e1f14719..f6f13b9ceb 100644 --- a/gst-libs/gst/egl/egl.c +++ b/gst-libs/gst/egl/egl.c @@ -237,7 +237,8 @@ gst_egl_image_allocator_alloc (GstAllocator * allocator, GstMemory * gst_egl_image_allocator_wrap (GstAllocator * allocator, GstEGLDisplay * display, EGLImageKHR image, GstEGLImageType type, - gsize size, gpointer user_data, GDestroyNotify user_data_destroy) + GstMemoryFlags flags, gsize size, gpointer user_data, + GDestroyNotify user_data_destroy) { GstEGLImageMemory *mem; @@ -250,7 +251,8 @@ gst_egl_image_allocator_wrap (GstAllocator * allocator, } mem = g_slice_new (GstEGLImageMemory); - gst_memory_init (GST_MEMORY_CAST (mem), 0, allocator, NULL, size, 0, 0, size); + gst_memory_init (GST_MEMORY_CAST (mem), flags, + allocator, NULL, size, 0, 0, size); mem->display = gst_egl_display_ref (display); mem->image = image; diff --git a/gst-libs/gst/egl/egl.h b/gst-libs/gst/egl/egl.h index ac5dfe285e..a174950ae7 100644 --- a/gst-libs/gst/egl/egl.h +++ b/gst-libs/gst/egl/egl.h @@ -54,7 +54,7 @@ GstEGLImageType gst_egl_image_memory_get_type (GstMemory * mem); /* Generic EGLImage allocator that doesn't support mapping, copying or anything */ GstAllocator * gst_egl_image_allocator_obtain (void); GstMemory * gst_egl_image_allocator_alloc (GstAllocator * allocator, GstEGLDisplay * display, GstEGLImageType type, gint width, gint height, gsize * size); -GstMemory * gst_egl_image_allocator_wrap (GstAllocator * allocator, GstEGLDisplay * display, EGLImageKHR image, GstEGLImageType type, gsize size, gpointer user_data, GDestroyNotify user_data_destroy); +GstMemory * gst_egl_image_allocator_wrap (GstAllocator * allocator, GstEGLDisplay * display, EGLImageKHR image, GstEGLImageType type, GstMemoryFlags flags, gsize size, gpointer user_data, GDestroyNotify user_data_destroy); /* EGLDisplay wrapper with refcount, connection is closed after last ref is gone */ GstEGLDisplay * gst_egl_display_new (EGLDisplay display);