From 431201daef97e2babe597e03e09bb401596df445 Mon Sep 17 00:00:00 2001 From: Pierre d'Herbemont Date: Wed, 30 Dec 2009 14:19:48 +0100 Subject: [PATCH] vout_macosx: Ensure initialization on main thread. --- modules/video_output/macosx.m | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m index 7fc4450f12..4f4f9be593 100644 --- a/modules/video_output/macosx.m +++ b/modules/video_output/macosx.m @@ -132,8 +132,8 @@ static int Open(vlc_object_t *this) /* Get our main view*/ nsPool = [[NSAutoreleasePool alloc] init]; - sys->glView = [[VLCOpenGLVideoView alloc] init]; - + + [VLCOpenGLVideoView performSelectorOnMainThread:@selector(getNewView:) withObject:[NSValue valueWithPointer:&sys->glView] waitUntilDone:YES]; if (!sys->glView) goto error; @@ -306,12 +306,19 @@ static void OpenglSwap(vout_opengl_t *gl) #define VLCAssertMainThread() assert([[NSThread currentThread] isMainThread]) ++ (void)getNewView:(NSValue *)value +{ + id *ret = [value pointerValue]; + *ret = [[self alloc] init]; +} + /** * Gets called by the Open() method. - * (Non main thread). */ - (id)init { + VLCAssertMainThread(); + /* Warning - this may be called on non main thread */ NSOpenGLPixelFormatAttribute attribs[] = @@ -326,7 +333,7 @@ static void OpenglSwap(vout_opengl_t *gl) 0 }; - NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: attribs]; + NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs]; if (!fmt) return nil; -- 2.39.5