mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 09:40:37 +00:00
osxvideosink: defer the window handle setup to the main thread
This commit is contained in:
parent
34a5b93637
commit
d57ef52cad
2 changed files with 37 additions and 32 deletions
|
@ -145,6 +145,7 @@ GType gst_osx_video_sink_get_type(void);
|
||||||
-(void) resize;
|
-(void) resize;
|
||||||
-(void) destroy;
|
-(void) destroy;
|
||||||
-(void) showFrame: (GstBufferObject*) buf;
|
-(void) showFrame: (GstBufferObject*) buf;
|
||||||
|
-(void) setView: (NSView*) view;
|
||||||
#ifdef RUN_NS_APP_THREAD
|
#ifdef RUN_NS_APP_THREAD
|
||||||
+ (BOOL) isMainThread;
|
+ (BOOL) isMainThread;
|
||||||
-(void) nsAppThread;
|
-(void) nsAppThread;
|
||||||
|
|
|
@ -680,39 +680,11 @@ static void
|
||||||
gst_osx_video_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle_id)
|
gst_osx_video_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle_id)
|
||||||
{
|
{
|
||||||
GstOSXVideoSink *osxvideosink = GST_OSX_VIDEO_SINK (overlay);
|
GstOSXVideoSink *osxvideosink = GST_OSX_VIDEO_SINK (overlay);
|
||||||
gulong window_id = (gulong) handle_id;
|
NSView *view = (NSView *) handle_id;
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
|
|
||||||
if (osxvideosink->superview) {
|
gst_osx_video_sink_call_from_main_thread(osxvideosink,
|
||||||
GST_INFO_OBJECT (osxvideosink, "old xwindow id %p", osxvideosink->superview);
|
osxvideosink->osxvideosinkobject,
|
||||||
if (osxvideosink->osxwindow) {
|
@selector(setView:), view, YES);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[pool release];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -863,6 +835,38 @@ gst_osx_video_sink_get_type (void)
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
- (void) resize
|
||||||
{
|
{
|
||||||
GstOSXWindow *osxwindow = osxvideosink->osxwindow;
|
GstOSXWindow *osxwindow = osxvideosink->osxwindow;
|
||||||
|
|
Loading…
Reference in a new issue