From: Sebastian Dröge Date: Sat, 10 Jan 2015 14:34:57 +0000 (+0100) Subject: gl/cocoa: Disable hack for NSApp iteration with a special #define X-Git-Tag: 1.19.3~507^2~9603 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fa5c433e7e993422df92433feca73d96154d06f0;p=platform%2Fupstream%2Fgstreamer.git gl/cocoa: Disable hack for NSApp iteration with a special #define The hack causes deadlocks and other interesting problems and it really can only be fixed properly inside GLib. We will include a patch for GLib in our builds for now that handles this, and hopefully at some point GLib will also merge a proper solution. A proper solution would first require to refactor the polling in GMainContext to only provide a single fd, e.g. via epoll/kqueue or a thread like the one added by our patch. Then this single fd could be retrieved from the GMainContext and directly integrated into a NSRunLoop. https://bugzilla.gnome.org/show_bug.cgi?id=741450 https://bugzilla.gnome.org/show_bug.cgi?id=704374 --- diff --git a/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m b/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m index a1746d1..43d5a1c 100644 --- a/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m +++ b/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m @@ -40,6 +40,12 @@ static GstGLPlatform gst_gl_context_cocoa_get_gl_platform (GstGLContext * contex G_DEFINE_TYPE (GstGLContextCocoa, gst_gl_context_cocoa, GST_GL_TYPE_CONTEXT); +/* Define this if the GLib patch from + * https://bugzilla.gnome.org/show_bug.cgi?id=741450 + * is used + */ +#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION + static GMutex nsapp_lock; static GCond nsapp_cond; @@ -95,12 +101,15 @@ gst_gl_window_cocoa_nsapp_iteration (gpointer data) return TRUE; } +#endif static void gst_gl_context_cocoa_class_init (GstGLContextCocoaClass * klass) { GstGLContextClass *context_class = (GstGLContextClass *) klass; +#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION NSAutoreleasePool* pool = nil; +#endif g_type_class_add_private (klass, sizeof (GstGLContextCocoaPrivate)); @@ -116,6 +125,7 @@ gst_gl_context_cocoa_class_init (GstGLContextCocoaClass * klass) context_class->get_gl_platform = GST_DEBUG_FUNCPTR (gst_gl_context_cocoa_get_gl_platform); +#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION pool = [[NSAutoreleasePool alloc] init]; /* [NSApplication sharedApplication] will usually be @@ -179,6 +189,7 @@ gst_gl_context_cocoa_class_init (GstGLContextCocoaClass * klass) } [pool release]; +#endif } static void @@ -206,7 +217,9 @@ gst_gl_context_cocoa_create_context (GstGLContext *context, GstGLAPI gl_api, GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window); __block NSOpenGLContext *glContext = nil; +#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION priv->source_id = g_timeout_add (200, gst_gl_window_cocoa_nsapp_iteration, NULL); +#endif priv->gl_context = nil; if (other_context)