diff options
author | Andy Wingo <wingo@pobox.com> | 2008-03-18 11:50:08 +0000 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2008-03-18 11:50:08 +0000 |
commit | a6267f383e20e88ac28fd8686b86a13c4dd2429c (patch) | |
tree | bfac42afca64100e843619193de4f0871226f817 /sys/osxvideo | |
parent | a6019fc0bf8854e2c062ebc69dee3e4f2c886115 (diff) |
sys/osxvideo/osxvideosink.m (gst_osx_video_sink_osxwindow_destroy)
Original commit message from CVS:
2008-03-18 Andy Wingo <wingo@pobox.com>
* sys/osxvideo/osxvideosink.m (gst_osx_video_sink_osxwindow_destroy)
(gst_osx_video_sink_osxwindow_new, cocoa_event_loop):
* sys/osxvideo/osxvideosink.h (struct _GstOSXVideoSink): If we
need to run an event loop, do so in a task instead of assuming
that there will be a GMainLoop. Fixes #523134.
Diffstat (limited to 'sys/osxvideo')
-rw-r--r-- | sys/osxvideo/osxvideosink.h | 2 | ||||
-rw-r--r-- | sys/osxvideo/osxvideosink.m | 28 |
2 files changed, 19 insertions, 11 deletions
diff --git a/sys/osxvideo/osxvideosink.h b/sys/osxvideo/osxvideosink.h index 1612a44c..bb16a425 100644 --- a/sys/osxvideo/osxvideosink.h +++ b/sys/osxvideo/osxvideosink.h @@ -76,6 +76,8 @@ struct _GstOSXVideoSink { gint fps_n; gint fps_d; + GstTask *event_task; + /* Unused */ gint pixel_width, pixel_height; diff --git a/sys/osxvideo/osxvideosink.m b/sys/osxvideo/osxvideosink.m index 2bb0447b..5ed1541c 100644 --- a/sys/osxvideo/osxvideosink.m +++ b/sys/osxvideo/osxvideosink.m @@ -111,34 +111,33 @@ static GstVideoSinkClass *parent_class = NULL; /* cocoa event loop - needed if not run in own app */ -gint +static void cocoa_event_loop (GstOSXVideoSink * vsink) { NSAutoreleasePool *pool; - gboolean ret = TRUE; GST_DEBUG_OBJECT (vsink, "Entering event loop"); pool = [[NSAutoreleasePool alloc] init]; - if ([NSApp isRunning]) { + while ([NSApp isRunning]) { NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ]; - if ( event != nil ) { + if ( event == nil ) { + g_usleep (100); + break; + } else { switch ([event type]) { default: //XXX Feed me please [NSApp sendEvent:event]; - break; + break; } + /* loop */ } } [pool release]; - - GST_DEBUG_OBJECT (vsink, "Leaving event loop with ret : %d", ret); - - return ret; } static NSString * @@ -281,8 +280,9 @@ gst_osx_video_sink_osxwindow_new (GstOSXVideoSink * osxvideosink, gint width, [NSApp setDelegate:[[GstAppDelegate alloc] init]]; [NSApp setRunning]; - // insert event dispatch in the glib main loop - g_idle_add ((GSourceFunc) cocoa_event_loop, osxvideosink); + osxvideosink->event_task = gst_task_create ((GstTaskFunction)cocoa_event_loop, + osxvideosink); + gst_task_start (osxvideosink->event_task); } else { GstStructure *s; GstMessage *msg; @@ -323,6 +323,12 @@ gst_osx_video_sink_osxwindow_destroy (GstOSXVideoSink * osxvideosink, [osxwindow->pool release]; + if (osxvideosink->event_task) { + gst_task_join (osxvideosink->event_task); + gst_object_unref (osxvideosink->event_task); + osxvideosink->event_task = NULL; + } + g_free (osxwindow); } |