[vlc-devel] commit: vout_macosx: Ensure initialization on main thread. (Pierre d' Herbemont )

git version control git at videolan.org
Thu Dec 31 17:08:51 CET 2009


vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Wed Dec 30 14:19:48 2009 +0100| [431201daef97e2babe597e03e09bb401596df445] | committer: Pierre d'Herbemont 

vout_macosx: Ensure initialization on main thread.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=431201daef97e2babe597e03e09bb401596df445
---

 modules/video_output/macosx.m |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index 7fc4450..4f4f9be 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;




More information about the vlc-devel mailing list