gl/cocoa: ensure to call NSApplication:sharedApplication in the main thread
authorJulien Isorce <julien.isorce@gmail.com>
Sat, 12 Apr 2014 11:42:40 +0000 (12:42 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:31:36 +0000 (19:31 +0000)
commit08cce2cd5b2bc6e54375121b2d8cab9a37ddbfd8
tree112172e9a0b5616ff8acd4175d9e0c18b2212c39
parente7dc1d787e2986a594ac37843c9e65fc31afbb4d
gl/cocoa: ensure to call NSApplication:sharedApplication in the main thread

"(NSApplication *)sharedApplication This method also makes a connection
to the window server and completes other initialization"
The implicit thing which is not mentioned is that it required
to be called in the main thread.

Fix a regression introduces by 82b7c915bb02a9790d256d599452e5a54afda633
When using with gst-launch, it was not possible to click on the close
cross of the window anymore which is a bit anoying and also because
it's was possible before.

Prior to this commit the GstGLContextCocoaClass was initialized
in the main thread because gst_gl_context_new was called in the
state change function from going from ready to paused.

From this commit this call is done from the streaming thread.
So that the call to [NSApplication sharedApplication];
was not done in the main thread anymore.

We now ensure that by assuming there is a GMainLoop running.
It's for debugging purpose so that's ok to do that. Also
note we already do this assumtion to run app itereations.

The regression had no consequence on the cocoa/videooverlay example
(that should be moved from gst-plugins-gl to -bad) because the
application is responsible for that necessary call.
gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m
gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m