diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2015-01-10 15:51:16 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-01-10 15:54:22 +0100 |
commit | 81e15d22c02b14b2a58436b0dd8d9d58048ff94f (patch) | |
tree | 7ceab2d34129c5977bea41137a36d7fa2e004495 /sys | |
parent | 0dd46accf6d282ff07065852bd91c85c78af3394 (diff) |
osxvideosink: 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
Diffstat (limited to 'sys')
-rw-r--r-- | sys/osxvideo/cocoawindow.h | 2 | ||||
-rw-r--r-- | sys/osxvideo/cocoawindow.m | 2 | ||||
-rw-r--r-- | sys/osxvideo/osxvideosink.h | 2 | ||||
-rw-r--r-- | sys/osxvideo/osxvideosink.m | 19 |
4 files changed, 22 insertions, 3 deletions
diff --git a/sys/osxvideo/cocoawindow.h b/sys/osxvideo/cocoawindow.h index a7e7f9804..9355d3c87 100644 --- a/sys/osxvideo/cocoawindow.h +++ b/sys/osxvideo/cocoawindow.h @@ -70,7 +70,9 @@ struct _GstOSXImage; - (void) addToSuperview: (NSView *)superview; - (void) removeFromSuperview: (id)unused; - (void) setNavigation: (GstNavigation *) nav; +#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION - (void) setMainThread: (NSThread *) thread; +#endif @end diff --git a/sys/osxvideo/cocoawindow.m b/sys/osxvideo/cocoawindow.m index 03bd4c15b..57d19a9bf 100644 --- a/sys/osxvideo/cocoawindow.m +++ b/sys/osxvideo/cocoawindow.m @@ -648,9 +648,11 @@ const gchar* gst_keycode_to_keyname(gint16 keycode) [self reshape]; } +#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION - (void) setMainThread: (NSThread *) thread { mainThread = thread; } +#endif - (void) haveSuperviewReal:(NSMutableArray *)closure { BOOL haveSuperview = [self superview] != nil; diff --git a/sys/osxvideo/osxvideosink.h b/sys/osxvideo/osxvideosink.h index 8f6bbd0fc..2bf5d25cb 100644 --- a/sys/osxvideo/osxvideosink.h +++ b/sys/osxvideo/osxvideosink.h @@ -130,8 +130,10 @@ GType gst_osx_video_sink_get_type(void); -(void) showFrame: (GstBufferObject*) buf; -(void) setView: (NSView*) view; + (BOOL) isMainThread; +#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION -(void) nsAppThread; -(void) checkMainRunLoop; +#endif @end G_END_DECLS diff --git a/sys/osxvideo/osxvideosink.m b/sys/osxvideo/osxvideosink.m index aa428f0a9..486ae7ab3 100644 --- a/sys/osxvideo/osxvideosink.m +++ b/sys/osxvideo/osxvideosink.m @@ -43,11 +43,11 @@ GST_DEBUG_CATEGORY (gst_debug_osx_video_sink); #define GST_CAT_DEFAULT gst_debug_osx_video_sink +#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION #include <pthread.h> extern void _CFRunLoopSetCurrent (CFRunLoopRef rl); extern pthread_t _CFMainPThread; - - +#endif static GstStaticPadTemplate gst_osx_video_sink_sink_template_factory = GST_STATIC_PAD_TEMPLATE ("sink", @@ -72,9 +72,13 @@ enum }; static void gst_osx_video_sink_osxwindow_destroy (GstOSXVideoSink * osxvideosink); + +#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION static GMutex _run_loop_check_mutex; static GMutex _run_loop_mutex; static GCond _run_loop_cond; +#endif + static GstOSXVideoSinkClass *sink_class = NULL; static GstVideoSinkClass *parent_class = NULL; @@ -98,6 +102,7 @@ gst_osx_video_sink_call_from_main_thread(GstOSXVideoSink *osxvideosink, [pool release]; } +#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION /* Poll for cocoa events */ static void run_ns_app_loop (void) { @@ -215,6 +220,7 @@ static void gst_osx_video_sink_stop_cocoa_loop (GstOSXVideoSink * osxvideosink) { } +#endif /* This function handles osx window creation */ static gboolean @@ -245,9 +251,10 @@ gst_osx_video_sink_osxwindow_create (GstOSXVideoSink * osxvideosink, gint width, rect.size.height = (float) osxwindow->height; osxwindow->gstview =[[GstGLView alloc] initWithFrame:rect]; - +#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION gst_osx_video_sink_run_cocoa_loop (osxvideosink); [osxwindow->gstview setMainThread:sink_class->ns_app_thread]; +#endif if (osxvideosink->superview == NULL) { GST_INFO_OBJECT (osxvideosink, "emitting prepare-xwindow-id"); @@ -290,7 +297,9 @@ gst_osx_video_sink_osxwindow_destroy (GstOSXVideoSink * osxvideosink) osxvideosink->osxvideosinkobject, @selector(destroy), (id) nil, YES); GST_OBJECT_UNLOCK (osxvideosink); +#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION gst_osx_video_sink_stop_cocoa_loop (osxvideosink); +#endif [pool release]; } @@ -764,6 +773,8 @@ gst_osx_video_sink_get_type (void) NSRect rect; unsigned int mask; + [NSApplication sharedApplication]; + osxwindow->internal = TRUE; mask = NSTitledWindowMask | @@ -929,6 +940,7 @@ no_texture_buffer: [pool release]; } +#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION -(void) nsAppThread { NSAutoreleasePool *pool; @@ -965,6 +977,7 @@ no_texture_buffer: g_cond_signal (&_run_loop_cond); g_mutex_unlock (&_run_loop_mutex); } +#endif @end |