/*****************************************************************************
* VLCOpenGLVoutView.m: MacOS X OpenGL provider
*****************************************************************************
- * Copyright (C) 2001-2007 the VideoLAN team
+ * Copyright (C) 2001-2009 the VideoLAN team
* $Id$
*
* Authors: Colin Delacroix <colin@zoy.org>
msg_Dbg( p_vout, "Mac OS X Vout is opening" );
- var_Create( p_vout, "drawable", VLC_VAR_DOINHERIT );
- var_Get( p_vout, "drawable", &value_drawable );
+ var_Create( p_vout, "drawable-nsobject", VLC_VAR_DOINHERIT );
+ var_Get( p_vout, "drawable-nsobject", &value_drawable );
p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
- o_cocoaglview_container = (id) value_drawable.i_int;
+ /* This will be released in cocoaglvoutviewEnd(), on
+ * main thread, after we are done using it. */
+ o_cocoaglview_container = [(id) value_drawable.p_address retain];
if (!o_cocoaglview_container)
{
msg_Warn( p_vout, "No drawable!, spawing a window" );
{
id <VLCOpenGLVoutEmbedding> o_cocoaglview_container;
+ if (!p_vout->p_sys->o_glview)
+ return;
+
msg_Dbg( p_vout, "Mac OS X Vout is closing" );
- var_Destroy( p_vout, "drawable" );
+ var_Destroy( p_vout, "drawable-nsobject" );
o_cocoaglview_container = [p_vout->p_sys->o_glview container];
[p_vout->p_sys->o_glview detachFromVout];
msg_Dbg( p_vout, "Mac OS X Vout is closing" );
- /* Let the view go, _without_blocking_ */
- [p_vout->p_sys->o_glview performSelectorOnMainThread:@selector(removeFromSuperview) withObject:NULL waitUntilDone:NO];
-
if( [(id)o_cocoaglview_container respondsToSelector:@selector(removeVoutSubview:)] )
- [o_cocoaglview_container removeVoutSubview: p_vout->p_sys->o_glview];
+ [o_cocoaglview_container performSelectorOnMainThread:@selector(removeVoutSubview:) withObject:p_vout->p_sys->o_glview waitUntilDone:NO];
+
+ /* Let the view go and release it, _without_blocking_ */
+ [p_vout->p_sys->o_glview performSelectorOnMainThread:@selector(removeFromSuperviewAndRelease) withObject:nil waitUntilDone:NO];
+ p_vout->p_sys->o_glview = nil;
- [p_vout->p_sys->o_glview release];
+ /* Release the container now that we don't use it */
+ [o_cocoaglview_container performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
[p_vout->p_sys->o_pool release];
+ p_vout->p_sys->o_pool = nil;
}
[[p_vout->p_sys->o_glview container] setOnTop: b_arg];
return VLC_SUCCESS;
- case VOUT_REPARENT:
default:
- return vout_vaControlDefault( p_vout, i_query, args );
+ return VLC_EGENERIC;
}
}
[super dealloc];
}
-- (void)removeFromSuperview
+- (void)removeFromSuperviewAndRelease
{
- [super removeFromSuperview];
+ [self removeFromSuperview];
+ [self release];
}
-
- (id) initWithVout: (vout_thread_t *) vout container: (id <VLCOpenGLVoutEmbedding>) aContainer
{
NSOpenGLPixelFormatAttribute attribs[] =
[objectLock lock];
if( p_vout )
{
- vlc_object_detach( p_vout );
vlc_object_release( p_vout );
vlc_object_release( p_vout );
}
- (void) update
{
+ if (!p_vout)
+ return;
if( kCGLNoError != CGLLockContext([[self openGLContext] CGLContextObj]) )
return;
[super update];
- (void) drawRect: (NSRect) rect
{
+ if (!p_vout)
+ return;
if( kCGLNoError != CGLLockContext([[self openGLContext] CGLContextObj]) )
return;
[[self openGLContext] flushBuffer];