summaryrefslogtreecommitdiff
path: root/sys/osxvideo
diff options
context:
space:
mode:
authorAndoni Morales Alastruey <ylatuya@gmail.com>2013-07-09 15:34:04 +0200
committerAndoni Morales Alastruey <ylatuya@gmail.com>2013-07-10 17:43:00 +0200
commitd57ef52cadd51643dfc812779dac444bf3d9eaae (patch)
treeb06e227d82e21aeea3d7ada7682c4c747e18a683 /sys/osxvideo
parent34a5b93637c40b782ab7a768c31e84ed1737981c (diff)
osxvideosink: defer the window handle setup to the main thread
Diffstat (limited to 'sys/osxvideo')
-rw-r--r--sys/osxvideo/osxvideosink.h1
-rw-r--r--sys/osxvideo/osxvideosink.m68
2 files changed, 37 insertions, 32 deletions
diff --git a/sys/osxvideo/osxvideosink.h b/sys/osxvideo/osxvideosink.h
index 2517bb37f..da912dfaf 100644
--- a/sys/osxvideo/osxvideosink.h
+++ b/sys/osxvideo/osxvideosink.h
@@ -145,6 +145,7 @@ GType gst_osx_video_sink_get_type(void);
-(void) resize;
-(void) destroy;
-(void) showFrame: (GstBufferObject*) buf;
+-(void) setView: (NSView*) view;
#ifdef RUN_NS_APP_THREAD
+ (BOOL) isMainThread;
-(void) nsAppThread;
diff --git a/sys/osxvideo/osxvideosink.m b/sys/osxvideo/osxvideosink.m
index 3f628e5f4..d2555b952 100644
--- a/sys/osxvideo/osxvideosink.m
+++ b/sys/osxvideo/osxvideosink.m
@@ -680,39 +680,11 @@ static void
gst_osx_video_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle_id)
{
GstOSXVideoSink *osxvideosink = GST_OSX_VIDEO_SINK (overlay);
- gulong window_id = (gulong) handle_id;
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- if (osxvideosink->superview) {
- GST_INFO_OBJECT (osxvideosink, "old xwindow id %p", osxvideosink->superview);
- if (osxvideosink->osxwindow) {
- gst_osx_video_sink_call_from_main_thread(osxvideosink,
- osxvideosink->osxwindow->gstview,
- @selector(removeFromSuperview:), (id)nil, YES);
- }
- [osxvideosink->superview release];
- }
- if (osxvideosink->osxwindow != NULL && window_id != 0) {
- if (osxvideosink->osxwindow->internal) {
- GST_INFO_OBJECT (osxvideosink, "closing internal window");
- osxvideosink->osxwindow->closed = TRUE;
- [osxvideosink->osxwindow->win close];
- [osxvideosink->osxwindow->win release];
- }
- }
-
- GST_INFO_OBJECT (osxvideosink, "set xwindow id 0x%lx", window_id);
- osxvideosink->superview = [((NSView *) window_id) retain];
- if (osxvideosink->osxwindow) {
- gst_osx_video_sink_call_from_main_thread(osxvideosink,
- osxvideosink->osxwindow->gstview,
- @selector(addToSuperview:), osxvideosink->superview, YES);
- if (window_id) {
- osxvideosink->osxwindow->internal = FALSE;
- }
- }
+ NSView *view = (NSView *) handle_id;
- [pool release];
+ gst_osx_video_sink_call_from_main_thread(osxvideosink,
+ osxvideosink->osxvideosinkobject,
+ @selector(setView:), view, YES);
}
static void
@@ -863,6 +835,38 @@ gst_osx_video_sink_get_type (void)
}
#endif
+- (void) setView: (NSView*)view
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ if (osxvideosink->superview) {
+ GST_INFO_OBJECT (osxvideosink, "old xwindow id %p", osxvideosink->superview);
+ if (osxvideosink->osxwindow) {
+ [osxvideosink->osxwindow->gstview removeFromSuperview];
+ }
+ [osxvideosink->superview release];
+ }
+ if (osxvideosink->osxwindow != NULL && view != NULL) {
+ if (osxvideosink->osxwindow->internal) {
+ GST_INFO_OBJECT (osxvideosink, "closing internal window");
+ osxvideosink->osxwindow->closed = TRUE;
+ [osxvideosink->osxwindow->win close];
+ [osxvideosink->osxwindow->win release];
+ }
+ }
+
+ GST_INFO_OBJECT (osxvideosink, "set xwindow id %p", view);
+ osxvideosink->superview = [view retain];
+ if (osxvideosink->osxwindow) {
+ [osxvideosink->osxwindow->gstview addToSuperview: osxvideosink->superview];
+ if (view) {
+ osxvideosink->osxwindow->internal = FALSE;
+ }
+ }
+
+ [pool release];
+}
+
- (void) resize
{
GstOSXWindow *osxwindow = osxvideosink->osxwindow;