]> git.sesse.net Git - vlc/commitdiff
vout_macosx: Ensure initialization on main thread.
authorPierre d'Herbemont <pdherbemont@free.fr>
Wed, 30 Dec 2009 13:19:48 +0000 (14:19 +0100)
committerPierre d'Herbemont <pdherbemont@free.fr>
Thu, 31 Dec 2009 16:05:13 +0000 (17:05 +0100)
modules/video_output/macosx.m

index 7fc4450f12a36efb0e1722ca8f56e22de30f7f59..4f4f9be5935ca584844bd81188158650432657fb 100644 (file)
@@ -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;