diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m b/subprojects/gst-plugins-base/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m index 21ff951f0d..4868069e1a 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m +++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m @@ -170,7 +170,9 @@ gst_gl_context_cocoa_dump_pixel_format (CGLPixelFormatObj fmt) CGLPixelFormatObj gst_gl_context_cocoa_get_pixel_format (GstGLContextCocoa *context) { - return context->priv->pixel_format; + if (context->priv->pixel_format) + return CGLRetainPixelFormat (context->priv->pixel_format); + return NULL; } static GstStructure * @@ -262,6 +264,7 @@ gst_gl_context_cocoa_create_context (GstGLContext *context, GstGLAPI gl_api, gint profile; fmt = CGLGetPixelFormat (priv->external_gl_context); + CGLRetainPixelFormat (fmt); #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 /* core profile is only available in >= 10.7 */ @@ -307,6 +310,7 @@ gst_gl_context_cocoa_create_context (GstGLContext *context, GstGLAPI gl_api, if (ret != kCGLNoError) { g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_CREATE_CONTEXT, "failed to create context: %s", CGLErrorString (ret)); + CGLReleasePixelFormat (fmt); goto error; } @@ -358,6 +362,11 @@ gst_gl_context_cocoa_destroy_context (GstGLContext *context) CGLDestroyContext(context_cocoa->priv->gl_context); context_cocoa->priv->gl_context = NULL; } + + if (context_cocoa->priv->pixel_format) { + CGLReleasePixelFormat(context_cocoa->priv->pixel_format); + context_cocoa->priv->pixel_format = NULL; + } } static guintptr