mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
[363/906] Cocoa backend: fix crash when closing
- All gstglwindow members are now modified only in the gl thread to avoid thread concurrency - OpenGL context is now properly clean - fix a couple of things in implementation of xoverlay interface
This commit is contained in:
parent
b7162375a3
commit
54ba5bccf5
1 changed files with 61 additions and 29 deletions
|
@ -42,7 +42,10 @@
|
||||||
backing: (NSBackingStoreType) bufferingType
|
backing: (NSBackingStoreType) bufferingType
|
||||||
defer: (BOOL) flag screen: (NSScreen *) aScreen
|
defer: (BOOL) flag screen: (NSScreen *) aScreen
|
||||||
gstWin: (GstGLWindowPrivate *) priv;
|
gstWin: (GstGLWindowPrivate *) priv;
|
||||||
|
- (void) setClosed;
|
||||||
- (BOOL) isClosed;
|
- (BOOL) isClosed;
|
||||||
|
- (BOOL) canBecomeMainWindow;
|
||||||
|
- (BOOL) canBecomeKeyWindow;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/* =============================================================*/
|
/* =============================================================*/
|
||||||
|
@ -83,6 +86,7 @@
|
||||||
- (void) sendToApp;
|
- (void) sendToApp;
|
||||||
- (void) setWindow;
|
- (void) setWindow;
|
||||||
- (void) stopApp;
|
- (void) stopApp;
|
||||||
|
- (void) closeWindow;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/* =============================================================*/
|
/* =============================================================*/
|
||||||
|
@ -218,7 +222,7 @@ gst_gl_window_new (gint width, gint height, gulong external_gl_context)
|
||||||
|
|
||||||
priv->internal_win_id =[[GstGLNSWindow alloc] initWithContentRect:rect styleMask:
|
priv->internal_win_id =[[GstGLNSWindow alloc] initWithContentRect:rect styleMask:
|
||||||
(NSTitledWindowMask | NSClosableWindowMask |
|
(NSTitledWindowMask | NSClosableWindowMask |
|
||||||
NSResizableWindowMask |NSMiniaturizableWindowMask)
|
NSResizableWindowMask | NSMiniaturizableWindowMask)
|
||||||
backing: NSBackingStoreBuffered defer: NO screen: nil gstWin: priv];
|
backing: NSBackingStoreBuffered defer: NO screen: nil gstWin: priv];
|
||||||
|
|
||||||
if (priv->internal_win_id) {
|
if (priv->internal_win_id) {
|
||||||
|
@ -324,6 +328,13 @@ gst_gl_window_draw (GstGLWindow * window)
|
||||||
[app_thread_performer performSelector:@selector(updateWindow)
|
[app_thread_performer performSelector:@selector(updateWindow)
|
||||||
onThread:priv->thread withObject:nil waitUntilDone:YES];
|
onThread:priv->thread withObject:nil waitUntilDone:YES];
|
||||||
|
|
||||||
|
if (!priv->parent && !priv->visible) {
|
||||||
|
g_debug ("make the window available");
|
||||||
|
[priv->internal_win_id makeMainWindow];
|
||||||
|
[priv->internal_win_id orderFront:priv->internal_win_id];
|
||||||
|
priv->visible = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
[pool release];
|
[pool release];
|
||||||
|
|
||||||
GSUnregisterCurrentThread();
|
GSUnregisterCurrentThread();
|
||||||
|
@ -364,21 +375,12 @@ gst_gl_window_run_loop (GstGLWindow * window)
|
||||||
if (priv->internal_win_id != nil) {
|
if (priv->internal_win_id != nil) {
|
||||||
while(priv->running) {
|
while(priv->running) {
|
||||||
|
|
||||||
if (!priv->parent) {
|
|
||||||
|
|
||||||
[run_loop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]];
|
[run_loop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]];
|
||||||
|
|
||||||
if (!priv->visible) {
|
if (!priv->parent)
|
||||||
g_debug ("make the window available");
|
|
||||||
[priv->internal_win_id orderFront:priv->internal_win_id];
|
|
||||||
priv->visible = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_idle_add (gst_gl_window_nsapp_iteration, priv->internal_win_id);
|
g_idle_add (gst_gl_window_nsapp_iteration, priv->internal_win_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
[priv->internal_win_id release];
|
[priv->internal_win_id release];
|
||||||
priv->internal_win_id = nil;
|
priv->internal_win_id = nil;
|
||||||
}
|
}
|
||||||
|
@ -519,24 +521,39 @@ gst_gl_window_send_message (GstGLWindow * window, GstGLWindowCB callback,
|
||||||
|
|
||||||
[self setBackgroundColor:[NSColor clearColor]];
|
[self setBackgroundColor:[NSColor clearColor]];
|
||||||
|
|
||||||
|
[self orderOut:m_priv->internal_win_id];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setClosed {
|
||||||
|
m_isClosed = YES;
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) isClosed {
|
- (BOOL) isClosed {
|
||||||
return m_isClosed;
|
return m_isClosed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) canBecomeMainWindow {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) canBecomeKeyWindow {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Called in the main thread which is never the gl thread */
|
||||||
- (BOOL) windowShouldClose:(id)sender {
|
- (BOOL) windowShouldClose:(id)sender {
|
||||||
g_debug ("user clicked the close button");
|
|
||||||
m_isClosed = YES;
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
if (m_priv->close_cb)
|
AppThreadPerformer* app_thread_performer = [[AppThreadPerformer alloc]
|
||||||
m_priv->close_cb (m_priv->close_data);
|
initWithPrivate:m_priv];
|
||||||
m_priv->draw_cb = NULL;
|
|
||||||
m_priv->draw_data = NULL;
|
[app_thread_performer performSelector:@selector(closeWindow) onThread:m_priv->thread
|
||||||
m_priv->resize_cb = NULL;
|
withObject:nil waitUntilDone:YES];
|
||||||
m_priv->resize_data = NULL;
|
|
||||||
m_priv->close_cb = NULL;
|
[pool release];
|
||||||
m_priv->close_data = NULL;
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,12 +680,13 @@ gst_gl_window_send_message (GstGLWindow * window, GstGLWindowCB callback,
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) resizeWindow {
|
- (void) resizeWindow {
|
||||||
if (m_priv->running)
|
if (m_priv->running && ![m_priv->internal_win_id isClosed]) {
|
||||||
m_callback2 (m_data, m_width, m_height);
|
m_callback2 (m_data, m_width, m_height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) sendToApp {
|
- (void) sendToApp {
|
||||||
if (m_priv->running)
|
if (m_priv->running && ![m_priv->internal_win_id isClosed])
|
||||||
m_callback (m_data);
|
m_callback (m_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,15 +694,29 @@ gst_gl_window_send_message (GstGLWindow * window, GstGLWindowCB callback,
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSWindow *window = m_priv->parent;
|
NSWindow *window = m_priv->parent;
|
||||||
|
|
||||||
[window setContentView: [m_priv->internal_win_id contentView]];
|
|
||||||
|
|
||||||
[m_priv->internal_win_id orderOut:m_priv->internal_win_id];
|
[m_priv->internal_win_id orderOut:m_priv->internal_win_id];
|
||||||
|
|
||||||
|
[window setContentView: [m_priv->internal_win_id contentView]];
|
||||||
|
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) stopApp {
|
- (void) stopApp {
|
||||||
m_priv->running = FALSE;
|
m_priv->running = FALSE;
|
||||||
|
m_callback (m_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) closeWindow {
|
||||||
|
[m_priv->internal_win_id setClosed];
|
||||||
|
if (m_priv->close_cb) {
|
||||||
|
m_priv->close_cb (m_priv->close_data);
|
||||||
|
}
|
||||||
|
m_priv->draw_cb = NULL;
|
||||||
|
m_priv->draw_data = NULL;
|
||||||
|
m_priv->resize_cb = NULL;
|
||||||
|
m_priv->resize_data = NULL;
|
||||||
|
m_priv->close_cb = NULL;
|
||||||
|
m_priv->close_data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in a new issue