osxvideo: unifdef -DRUN_NS_APP_THREAD
This commit is contained in:
parent
6fe2115d77
commit
2bc631bcd0
@ -3,9 +3,9 @@ plugin_LTLIBRARIES = libgstosxvideosink.la
|
|||||||
|
|
||||||
libgstosxvideosink_la_SOURCES = osxvideosink.m cocoawindow.m
|
libgstosxvideosink_la_SOURCES = osxvideosink.m cocoawindow.m
|
||||||
libgstosxvideosink_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) \
|
libgstosxvideosink_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) \
|
||||||
$(GST_PLUGINS_BASE_CFLAGS) -DRUN_NS_APP_THREAD
|
$(GST_PLUGINS_BASE_CFLAGS)
|
||||||
libgstosxvideosink_la_OBJCFLAGS = $(GST_OBJCFLAGS) $(GST_BASE_CFLAGS) \
|
libgstosxvideosink_la_OBJCFLAGS = $(GST_OBJCFLAGS) $(GST_BASE_CFLAGS) \
|
||||||
$(GST_PLUGINS_BASE_CFLAGS) -DRUN_NS_APP_THREAD
|
$(GST_PLUGINS_BASE_CFLAGS)
|
||||||
libgstosxvideosink_la_LIBADD = \
|
libgstosxvideosink_la_LIBADD = \
|
||||||
$(GST_LIBS) \
|
$(GST_LIBS) \
|
||||||
$(GST_BASE_LIBS) \
|
$(GST_BASE_LIBS) \
|
||||||
|
@ -89,11 +89,7 @@ struct _GstOSXVideoSinkClass {
|
|||||||
GstVideoSinkClass parent_class;
|
GstVideoSinkClass parent_class;
|
||||||
|
|
||||||
GstOSXVideoSinkRunLoopState run_loop_state;
|
GstOSXVideoSinkRunLoopState run_loop_state;
|
||||||
#ifdef RUN_NS_APP_THREAD
|
|
||||||
NSThread *ns_app_thread;
|
NSThread *ns_app_thread;
|
||||||
#else
|
|
||||||
guint cocoa_timeout;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gst_osx_video_sink_get_type(void);
|
GType gst_osx_video_sink_get_type(void);
|
||||||
@ -132,11 +128,9 @@ GType gst_osx_video_sink_get_type(void);
|
|||||||
-(void) destroy;
|
-(void) destroy;
|
||||||
-(void) showFrame: (GstBufferObject*) buf;
|
-(void) showFrame: (GstBufferObject*) buf;
|
||||||
-(void) setView: (NSView*) view;
|
-(void) setView: (NSView*) view;
|
||||||
#ifdef RUN_NS_APP_THREAD
|
|
||||||
+ (BOOL) isMainThread;
|
+ (BOOL) isMainThread;
|
||||||
-(void) nsAppThread;
|
-(void) nsAppThread;
|
||||||
-(void) checkMainRunLoop;
|
-(void) checkMainRunLoop;
|
||||||
#endif
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
@ -48,11 +48,9 @@
|
|||||||
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
|
||||||
|
|
||||||
#ifdef RUN_NS_APP_THREAD
|
|
||||||
#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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -112,12 +110,8 @@ run_ns_app_loop (void) {
|
|||||||
NSAutoreleasePool *pool =[[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool *pool =[[NSAutoreleasePool alloc] init];
|
||||||
NSDate *pollTime = nil;
|
NSDate *pollTime = nil;
|
||||||
|
|
||||||
#ifdef RUN_NS_APP_THREAD
|
|
||||||
/* when running the loop in a thread we want to sleep as long as possible */
|
/* when running the loop in a thread we want to sleep as long as possible */
|
||||||
pollTime = [NSDate distantFuture];
|
pollTime = [NSDate distantFuture];
|
||||||
#else
|
|
||||||
pollTime = [NSDate distantPast];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:pollTime
|
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:pollTime
|
||||||
@ -197,7 +191,6 @@ gst_osx_video_sink_run_cocoa_loop (GstOSXVideoSink * sink )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sink_class->ns_app_thread == NULL) {
|
if (sink_class->ns_app_thread == NULL) {
|
||||||
#ifdef RUN_NS_APP_THREAD
|
|
||||||
/* run the main runloop in a separate thread */
|
/* run the main runloop in a separate thread */
|
||||||
|
|
||||||
/* override [NSThread isMainThread] with our own implementation so that we can
|
/* override [NSThread isMainThread] with our own implementation so that we can
|
||||||
@ -218,12 +211,6 @@ gst_osx_video_sink_run_cocoa_loop (GstOSXVideoSink * sink )
|
|||||||
g_mutex_lock (&_run_loop_mutex);
|
g_mutex_lock (&_run_loop_mutex);
|
||||||
g_cond_wait (&_run_loop_cond, &_run_loop_mutex);
|
g_cond_wait (&_run_loop_cond, &_run_loop_mutex);
|
||||||
g_mutex_unlock (&_run_loop_mutex);
|
g_mutex_unlock (&_run_loop_mutex);
|
||||||
#else
|
|
||||||
/* assume that there is a GMainLoop and iterate the main runloop from there
|
|
||||||
*/
|
|
||||||
sink_class->cocoa_timeout = g_timeout_add (10,
|
|
||||||
(GSourceFunc) run_ns_app_loop, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_unlock (&_run_loop_check_mutex);
|
g_mutex_unlock (&_run_loop_check_mutex);
|
||||||
@ -232,10 +219,6 @@ gst_osx_video_sink_run_cocoa_loop (GstOSXVideoSink * sink )
|
|||||||
static void
|
static void
|
||||||
gst_osx_video_sink_stop_cocoa_loop (GstOSXVideoSink * osxvideosink)
|
gst_osx_video_sink_stop_cocoa_loop (GstOSXVideoSink * osxvideosink)
|
||||||
{
|
{
|
||||||
#ifndef RUN_NS_APP_THREAD
|
|
||||||
if (sink_class->cocoa_timeout)
|
|
||||||
g_source_remove(sink_klass->cocoa_timeout);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function handles osx window creation */
|
/* This function handles osx window creation */
|
||||||
@ -811,13 +794,6 @@ gst_osx_video_sink_get_type (void)
|
|||||||
rect.size.width = (float) osxwindow->width;
|
rect.size.width = (float) osxwindow->width;
|
||||||
rect.size.height = (float) osxwindow->height;
|
rect.size.height = (float) osxwindow->height;
|
||||||
|
|
||||||
#ifndef RUN_NS_APP_THREAD
|
|
||||||
if (!osxvideosink->app_started) {
|
|
||||||
[NSApplication sharedApplication];
|
|
||||||
[NSApp finishLaunching];
|
|
||||||
osxvideosink->app_started = TRUE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!GetCurrentProcess(&psn)) {
|
if (!GetCurrentProcess(&psn)) {
|
||||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||||
@ -838,13 +814,11 @@ gst_osx_video_sink_get_type (void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RUN_NS_APP_THREAD
|
|
||||||
+ (BOOL) isMainThread
|
+ (BOOL) isMainThread
|
||||||
{
|
{
|
||||||
/* FIXME: ideally we should return YES only for ->ns_app_thread here */
|
/* FIXME: ideally we should return YES only for ->ns_app_thread here */
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
- (void) setView: (NSView*)view
|
- (void) setView: (NSView*)view
|
||||||
{
|
{
|
||||||
@ -973,7 +947,6 @@ no_texture_buffer:
|
|||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RUN_NS_APP_THREAD
|
|
||||||
-(void) nsAppThread
|
-(void) nsAppThread
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool;
|
NSAutoreleasePool *pool;
|
||||||
@ -1003,7 +976,6 @@ no_texture_buffer:
|
|||||||
|
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
-(void) checkMainRunLoop
|
-(void) checkMainRunLoop
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user