From: Andoni Morales Alastruey Date: Sun, 7 Jul 2013 20:16:05 +0000 (+0200) Subject: osxvideosink: close the internal window correctly X-Git-Tag: 1.19.3~509^2~5635 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0e321b87d4df4f86176cb71ff87f68a8a802f015;p=platform%2Fupstream%2Fgstreamer.git osxvideosink: close the internal window correctly --- diff --git a/sys/osxvideo/osxvideosink.m b/sys/osxvideo/osxvideosink.m index 8c172e5..6d4e9f3 100644 --- a/sys/osxvideo/osxvideosink.m +++ b/sys/osxvideo/osxvideosink.m @@ -674,6 +674,7 @@ gst_osx_video_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle { 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); @@ -684,6 +685,14 @@ gst_osx_video_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle } [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]; @@ -696,6 +705,7 @@ gst_osx_video_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle } } + [pool release]; } static void @@ -770,6 +780,9 @@ gst_osx_video_sink_get_type (void) - (void)windowWillClose:(NSNotification *)notification { /* Only handle close events if the window was closed manually by the user * and not becuase of a state change state to READY */ + if (osxvideosink->osxwindow == NULL) { + return; + } if (!osxvideosink->osxwindow->closed) { osxvideosink->osxwindow->closed = TRUE; GST_ELEMENT_ERROR (osxvideosink, RESOURCE, NOT_FOUND, ("Output window was closed"), (NULL)); @@ -821,12 +834,12 @@ gst_osx_video_sink_get_type (void) SetFrontProcess(&psn); } - osxwindow->win =[[GstOSXVideoSinkWindow alloc] + osxwindow->win =[[[GstOSXVideoSinkWindow alloc] initWithContentNSRect: rect styleMask: mask backing: NSBackingStoreBuffered defer: NO - screen: nil]; + screen: nil] retain]; GST_DEBUG("VideoSinkWindow created, %p", osxwindow->win); [osxwindow->win makeKeyAndOrderFront:NSApp]; osxwindow->gstview =[osxwindow->win gstView]; @@ -907,6 +920,7 @@ gst_osx_video_sink_get_type (void) if (osxwindow->internal) { if (!osxwindow->closed) { osxwindow->closed = TRUE; + [osxwindow->win close]; [osxwindow->win release]; } }