mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 05:28:32 +00:00
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
This commit is contained in:
parent
0dd46accf6
commit
81e15d22c0
4 changed files with 22 additions and 3 deletions
|
@ -70,7 +70,9 @@ struct _GstOSXImage;
|
||||||
- (void) addToSuperview: (NSView *)superview;
|
- (void) addToSuperview: (NSView *)superview;
|
||||||
- (void) removeFromSuperview: (id)unused;
|
- (void) removeFromSuperview: (id)unused;
|
||||||
- (void) setNavigation: (GstNavigation *) nav;
|
- (void) setNavigation: (GstNavigation *) nav;
|
||||||
|
#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION
|
||||||
- (void) setMainThread: (NSThread *) thread;
|
- (void) setMainThread: (NSThread *) thread;
|
||||||
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -648,9 +648,11 @@ const gchar* gst_keycode_to_keyname(gint16 keycode)
|
||||||
[self reshape];
|
[self reshape];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION
|
||||||
- (void) setMainThread: (NSThread *) thread {
|
- (void) setMainThread: (NSThread *) thread {
|
||||||
mainThread = thread;
|
mainThread = thread;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
- (void) haveSuperviewReal:(NSMutableArray *)closure {
|
- (void) haveSuperviewReal:(NSMutableArray *)closure {
|
||||||
BOOL haveSuperview = [self superview] != nil;
|
BOOL haveSuperview = [self superview] != nil;
|
||||||
|
|
|
@ -130,8 +130,10 @@ GType gst_osx_video_sink_get_type(void);
|
||||||
-(void) showFrame: (GstBufferObject*) buf;
|
-(void) showFrame: (GstBufferObject*) buf;
|
||||||
-(void) setView: (NSView*) view;
|
-(void) setView: (NSView*) view;
|
||||||
+ (BOOL) isMainThread;
|
+ (BOOL) isMainThread;
|
||||||
|
#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION
|
||||||
-(void) nsAppThread;
|
-(void) nsAppThread;
|
||||||
-(void) checkMainRunLoop;
|
-(void) checkMainRunLoop;
|
||||||
|
#endif
|
||||||
@end
|
@end
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -43,11 +43,11 @@
|
||||||
GST_DEBUG_CATEGORY (gst_debug_osx_video_sink);
|
GST_DEBUG_CATEGORY (gst_debug_osx_video_sink);
|
||||||
#define GST_CAT_DEFAULT gst_debug_osx_video_sink
|
#define GST_CAT_DEFAULT gst_debug_osx_video_sink
|
||||||
|
|
||||||
|
#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
extern void _CFRunLoopSetCurrent (CFRunLoopRef rl);
|
extern void _CFRunLoopSetCurrent (CFRunLoopRef rl);
|
||||||
extern pthread_t _CFMainPThread;
|
extern pthread_t _CFMainPThread;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_osx_video_sink_sink_template_factory =
|
static GstStaticPadTemplate gst_osx_video_sink_sink_template_factory =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
|
@ -72,9 +72,13 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
static void gst_osx_video_sink_osxwindow_destroy (GstOSXVideoSink * osxvideosink);
|
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_check_mutex;
|
||||||
static GMutex _run_loop_mutex;
|
static GMutex _run_loop_mutex;
|
||||||
static GCond _run_loop_cond;
|
static GCond _run_loop_cond;
|
||||||
|
#endif
|
||||||
|
|
||||||
static GstOSXVideoSinkClass *sink_class = NULL;
|
static GstOSXVideoSinkClass *sink_class = NULL;
|
||||||
static GstVideoSinkClass *parent_class = NULL;
|
static GstVideoSinkClass *parent_class = NULL;
|
||||||
|
|
||||||
|
@ -98,6 +102,7 @@ gst_osx_video_sink_call_from_main_thread(GstOSXVideoSink *osxvideosink,
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION
|
||||||
/* Poll for cocoa events */
|
/* Poll for cocoa events */
|
||||||
static void
|
static void
|
||||||
run_ns_app_loop (void) {
|
run_ns_app_loop (void) {
|
||||||
|
@ -215,6 +220,7 @@ static void
|
||||||
gst_osx_video_sink_stop_cocoa_loop (GstOSXVideoSink * osxvideosink)
|
gst_osx_video_sink_stop_cocoa_loop (GstOSXVideoSink * osxvideosink)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This function handles osx window creation */
|
/* This function handles osx window creation */
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -245,9 +251,10 @@ gst_osx_video_sink_osxwindow_create (GstOSXVideoSink * osxvideosink, gint width,
|
||||||
rect.size.height = (float) osxwindow->height;
|
rect.size.height = (float) osxwindow->height;
|
||||||
osxwindow->gstview =[[GstGLView alloc] initWithFrame:rect];
|
osxwindow->gstview =[[GstGLView alloc] initWithFrame:rect];
|
||||||
|
|
||||||
|
#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION
|
||||||
gst_osx_video_sink_run_cocoa_loop (osxvideosink);
|
gst_osx_video_sink_run_cocoa_loop (osxvideosink);
|
||||||
[osxwindow->gstview setMainThread:sink_class->ns_app_thread];
|
[osxwindow->gstview setMainThread:sink_class->ns_app_thread];
|
||||||
|
#endif
|
||||||
|
|
||||||
if (osxvideosink->superview == NULL) {
|
if (osxvideosink->superview == NULL) {
|
||||||
GST_INFO_OBJECT (osxvideosink, "emitting prepare-xwindow-id");
|
GST_INFO_OBJECT (osxvideosink, "emitting prepare-xwindow-id");
|
||||||
|
@ -290,7 +297,9 @@ gst_osx_video_sink_osxwindow_destroy (GstOSXVideoSink * osxvideosink)
|
||||||
osxvideosink->osxvideosinkobject,
|
osxvideosink->osxvideosinkobject,
|
||||||
@selector(destroy), (id) nil, YES);
|
@selector(destroy), (id) nil, YES);
|
||||||
GST_OBJECT_UNLOCK (osxvideosink);
|
GST_OBJECT_UNLOCK (osxvideosink);
|
||||||
|
#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION
|
||||||
gst_osx_video_sink_stop_cocoa_loop (osxvideosink);
|
gst_osx_video_sink_stop_cocoa_loop (osxvideosink);
|
||||||
|
#endif
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -764,6 +773,8 @@ gst_osx_video_sink_get_type (void)
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
|
|
||||||
|
[NSApplication sharedApplication];
|
||||||
|
|
||||||
osxwindow->internal = TRUE;
|
osxwindow->internal = TRUE;
|
||||||
|
|
||||||
mask = NSTitledWindowMask |
|
mask = NSTitledWindowMask |
|
||||||
|
@ -929,6 +940,7 @@ no_texture_buffer:
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION
|
||||||
-(void) nsAppThread
|
-(void) nsAppThread
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool;
|
NSAutoreleasePool *pool;
|
||||||
|
@ -965,6 +977,7 @@ no_texture_buffer:
|
||||||
g_cond_signal (&_run_loop_cond);
|
g_cond_signal (&_run_loop_cond);
|
||||||
g_mutex_unlock (&_run_loop_mutex);
|
g_mutex_unlock (&_run_loop_mutex);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue