{
GError *error = NULL;
- g_assert (![NSThread isMainThread]);
-
if (!gst_gl_ensure_element_data (ca_sink, &ca_sink->display,
&ca_sink->other_context))
return FALSE;
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
+ _ensure_gl_setup (ca_sink);
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
g_atomic_int_set (&ca_sink->to_quit, 0);
gint preferred_height;
GLint viewport_dim[4];
+
+ /* atomic set when the internal NSView has been created */
+ int view_ready;
};
static void
GST_DEBUG ("NSWindow id: %"G_GUINTPTR_FORMAT, (guintptr) priv->internal_win_id);
- [priv->internal_win_id setContentView:glView];
+ [priv->internal_win_id setContentView:glView];
+
+ g_atomic_int_set (&window_cocoa->priv->view_ready, 1);
return TRUE;
}
gst_gl_window_cocoa_draw (GstGLWindow * window)
{
GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window);
- GstGLNSView *view = (GstGLNSView *)[window_cocoa->priv->internal_win_id contentView];
+ GstGLNSView *view;
+
+ /* As the view is created asynchronously in the main thread we cannot know
+ * exactly when it will be ready to draw to */
+ if (!g_atomic_int_get (&window_cocoa->priv->view_ready))
+ return;
+
+ view = (GstGLNSView *)[window_cocoa->priv->internal_win_id contentView];
/* this redraws the GstGLCAOpenGLLayer which calls
* gst_gl_window_cocoa_draw_thread(). Use an explicit CATransaction since we
if ([NSThread isMainThread]) {
func (data);
} else {
- dispatch_sync (dispatch_get_main_queue (), ^{
+ dispatch_async (dispatch_get_main_queue (), ^{
func (data);
});
}
}
-