X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fminimal_macosx%2FVLCOpenGLVoutView.m;h=4fa69c12fa0202e03584b490e844767a1017b6e0;hb=024420d8dfa3c3610d31ca5cd081f6a500efa597;hp=d42f0062ec195c4e949ba4a5dcfde57fc68948a7;hpb=a4eb03a532b5562ad6676ec37172c2714c49ef9f;p=vlc diff --git a/modules/gui/minimal_macosx/VLCOpenGLVoutView.m b/modules/gui/minimal_macosx/VLCOpenGLVoutView.m index d42f0062ec..4fa69c12fa 100644 --- a/modules/gui/minimal_macosx/VLCOpenGLVoutView.m +++ b/modules/gui/minimal_macosx/VLCOpenGLVoutView.m @@ -1,7 +1,7 @@ /***************************************************************************** * VLCOpenGLVoutView.m: MacOS X OpenGL provider ***************************************************************************** - * Copyright (C) 2001-2007 the VideoLAN team + * Copyright (C) 2001-2009 the VideoLAN team * $Id$ * * Authors: Colin Delacroix @@ -49,18 +49,20 @@ int cocoaglvoutviewInit( vout_thread_t * p_vout ) 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" ); } - p_vout->p_sys->b_embedded = VLC_FALSE; + p_vout->p_sys->b_embedded = false; /* Create the GL view */ @@ -80,8 +82,11 @@ void cocoaglvoutviewEnd( vout_thread_t * p_vout ) { id 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]; @@ -89,15 +94,18 @@ void cocoaglvoutviewEnd( vout_thread_t * p_vout ) [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; } @@ -142,7 +150,7 @@ int cocoaglvoutviewManage( vout_thread_t * p_vout ) *****************************************************************************/ int cocoaglvoutviewControl( vout_thread_t *p_vout, int i_query, va_list args ) { - vlc_bool_t b_arg; + bool b_arg; switch( i_query ) { @@ -151,10 +159,8 @@ int cocoaglvoutviewControl( vout_thread_t *p_vout, int i_query, va_list args ) [[p_vout->p_sys->o_glview container] setOnTop: b_arg]; return VLC_SUCCESS; - case VOUT_CLOSE: - case VOUT_REPARENT: default: - return vout_vaControlDefault( p_vout, i_query, args ); + return VLC_EGENERIC; } } @@ -163,7 +169,7 @@ int cocoaglvoutviewControl( vout_thread_t *p_vout, int i_query, va_list args ) *****************************************************************************/ void cocoaglvoutviewSwap( vout_thread_t * p_vout ) { - p_vout->p_sys->b_got_frame = VLC_TRUE; + p_vout->p_sys->b_got_frame = true; [[p_vout->p_sys->o_glview openGLContext] flushBuffer]; } @@ -221,12 +227,12 @@ void cocoaglvoutviewUnlock( vout_thread_t * p_vout ) [super dealloc]; } -- (void)removeFromSuperview +- (void)removeFromSuperviewAndRelease { - [super removeFromSuperview]; + [self removeFromSuperview]; + [self release]; } - - (id) initWithVout: (vout_thread_t *) vout container: (id ) aContainer { NSOpenGLPixelFormatAttribute attribs[] = @@ -288,9 +294,8 @@ void cocoaglvoutviewUnlock( vout_thread_t * p_vout ) [objectLock lock]; if( p_vout ) { - vlc_object_detach( p_vout ); vlc_object_release( p_vout ); - vout_Destroy( (vout_thread_t *)p_vout ); + vlc_object_release( p_vout ); } [objectLock unlock]; } @@ -359,6 +364,8 @@ void cocoaglvoutviewUnlock( vout_thread_t * p_vout ) - (void) update { + if (!p_vout) + return; if( kCGLNoError != CGLLockContext([[self openGLContext] CGLContextObj]) ) return; [super update]; @@ -367,6 +374,8 @@ void cocoaglvoutviewUnlock( vout_thread_t * p_vout ) - (void) drawRect: (NSRect) rect { + if (!p_vout) + return; if( kCGLNoError != CGLLockContext([[self openGLContext] CGLContextObj]) ) return; [[self openGLContext] flushBuffer];