Commit 431201da authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

vout_macosx: Ensure initialization on main thread.

parent 98fa929d
...@@ -132,8 +132,8 @@ static int Open(vlc_object_t *this) ...@@ -132,8 +132,8 @@ static int Open(vlc_object_t *this)
/* Get our main view*/ /* Get our main view*/
nsPool = [[NSAutoreleasePool alloc] init]; nsPool = [[NSAutoreleasePool alloc] init];
sys->glView = [[VLCOpenGLVideoView alloc] init];
[VLCOpenGLVideoView performSelectorOnMainThread:@selector(getNewView:) withObject:[NSValue valueWithPointer:&sys->glView] waitUntilDone:YES];
if (!sys->glView) if (!sys->glView)
goto error; goto error;
...@@ -306,12 +306,19 @@ static void OpenglSwap(vout_opengl_t *gl) ...@@ -306,12 +306,19 @@ static void OpenglSwap(vout_opengl_t *gl)
#define VLCAssertMainThread() assert([[NSThread currentThread] isMainThread]) #define VLCAssertMainThread() assert([[NSThread currentThread] isMainThread])
+ (void)getNewView:(NSValue *)value
{
id *ret = [value pointerValue];
*ret = [[self alloc] init];
}
/** /**
* Gets called by the Open() method. * Gets called by the Open() method.
* (Non main thread).
*/ */
- (id)init - (id)init
{ {
VLCAssertMainThread();
/* Warning - this may be called on non main thread */ /* Warning - this may be called on non main thread */
NSOpenGLPixelFormatAttribute attribs[] = NSOpenGLPixelFormatAttribute attribs[] =
...@@ -326,7 +333,7 @@ static void OpenglSwap(vout_opengl_t *gl) ...@@ -326,7 +333,7 @@ static void OpenglSwap(vout_opengl_t *gl)
0 0
}; };
NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: attribs]; NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
if (!fmt) if (!fmt)
return nil; return nil;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment