[vlc-devel] commit: Prefer leaking on closing plugin iso crashing. (Jean-Paul Saman )
git version control
git at videolan.org
Tue Nov 11 14:44:48 CET 2008
vlc | branch: 0.8.6-bugfix | Jean-Paul Saman <jpsaman at videolan.org> | Wed Oct 29 22:02:51 2008 +0100| [d41f6f367ae740453db18cf791633f1c0855f692] | committer: Jean-Paul Saman
Prefer leaking on closing plugin iso crashing.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d41f6f367ae740453db18cf791633f1c0855f692
---
modules/gui/macosx/voutgl.m | 57 ++++++++++++++++++++++++++----------------
1 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/modules/gui/macosx/voutgl.m b/modules/gui/macosx/voutgl.m
index c50d5dd..c920149 100644
--- a/modules/gui/macosx/voutgl.m
+++ b/modules/gui/macosx/voutgl.m
@@ -51,8 +51,8 @@
vout_thread_t * p_vout;
}
-+ (void)resetVout: (vout_thread_t *)p_vout;
-- (id) initWithVout: (vout_thread_t *) p_vout;
++ (void) resetVout: (vout_thread_t *) vout;
+- (id) initWithVout: (vout_thread_t *) vout;
@end
struct vout_sys_t
@@ -101,16 +101,13 @@ int E_(OpenVideoGL) ( vlc_object_t * p_this )
{
msg_Warn( p_vout, "no OpenGL hardware acceleration found. "
"Video display will be slow" );
- return( 1 );
+ return VLC_EGENERIC;
}
msg_Dbg( p_vout, "display is Quartz Extreme accelerated" );
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
- {
- msg_Err( p_vout, "out of memory" );
- return( 1 );
- }
+ return VLC_ENOMEM;
memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
@@ -140,6 +137,7 @@ int E_(OpenVideoGL) ( vlc_object_t * p_this )
if( NULL == pixFormat )
{
msg_Err( p_vout, "no screen renderer available for required attributes." );
+ free( p_vout->p_sys );
return VLC_EGENERIC;
}
@@ -148,6 +146,7 @@ int E_(OpenVideoGL) ( vlc_object_t * p_this )
if( NULL == p_vout->p_sys->agl_ctx )
{
msg_Err( p_vout, "cannot create AGL context." );
+ free( p_vout->p_sys );
return VLC_EGENERIC;
}
else {
@@ -180,6 +179,8 @@ int E_(OpenVideoGL) ( vlc_object_t * p_this )
if( !p_vout->p_sys->o_vout_view )
{
+ aglDestroyContext( p_vout->p_sys->agl_ctx );
+ free( p_vout->p_sys );
return VLC_EGENERIC;
}
p_vout->pf_init = Init;
@@ -198,17 +199,22 @@ int E_(OpenVideoGL) ( vlc_object_t * p_this )
void E_(CloseVideoGL) ( vlc_object_t * p_this )
{
vout_thread_t * p_vout = (vout_thread_t *) p_this;
+
+ if( !p_vout->p_sys ) return;
+
if( p_vout->p_sys->b_embedded )
{
- if( p_vout->b_fullscreen )
- {
- p_vout->i_changes = VOUT_FULLSCREEN_CHANGE;
- aglManage( p_vout );
- }
- aglDestroyContext(p_vout->p_sys->agl_ctx);
- var_SetBool( p_vout->p_parent, "fullscreen", VLC_FALSE );
+ vlc_value_t val;
+ val.b_bool = VLC_FALSE;
+ var_Set( p_vout->p_parent, "fullscreen", val );
+
+ aglEnd( p_vout );
+ if( p_vout->p_sys->agl_ctx )
+ aglDestroyContext(p_vout->p_sys->agl_ctx);
+ p_vout->p_sys->agl_ctx = NULL;
+ p_vout->b_fullscreen = VLC_FALSE;
}
- else if(!VLCIntf->b_die)
+ else if( !VLCIntf->b_die )
{
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
@@ -217,9 +223,11 @@ void E_(CloseVideoGL) ( vlc_object_t * p_this )
[o_pool release];
}
+
/* Clean up */
vlc_mutex_destroy( &p_vout->p_sys->lock );
free( p_vout->p_sys );
+ p_vout->p_sys = NULL;
}
static int Init( vout_thread_t * p_vout )
@@ -336,9 +344,9 @@ static void Unlock( vout_thread_t * p_vout )
}
/* This function will reset the o_vout_view. It's useful to go fullscreen. */
-+ (void)resetVout:(NSData *)arg
++ (void)resetVout:(vout_thread_t *) vout
{
- vout_thread_t * p_vout = [arg pointerValue];
+ vout_thread_t * p_vout = vout;
if( p_vout->b_fullscreen )
{
@@ -531,7 +539,9 @@ static int aglInit( vout_thread_t * p_vout )
static void aglEnd( vout_thread_t * p_vout )
{
aglSetCurrentContext(NULL);
- if( p_vout->p_sys->theWindow ) DisposeWindow( p_vout->p_sys->theWindow );
+ if( p_vout->p_sys->theWindow )
+ DisposeWindow( p_vout->p_sys->theWindow );
+ p_vout->p_sys->theWindow = NULL;
}
static void aglReshape( vout_thread_t * p_vout )
@@ -638,11 +648,15 @@ static int aglManage( vout_thread_t * p_vout )
aglSetCurrentContext(p_vout->p_sys->agl_ctx);
aglSetViewport(p_vout, viewBounds, clipBounds);
- /* Most Carbon APIs are not thread-safe, therefore delagate some GUI visibilty update to the main thread */
- sendEventToMainThread(GetWindowEventTarget(p_vout->p_sys->theWindow), kEventClassVLCPlugin, kEventVLCPluginHideFullscreen);
+ if( p_vout->p_sys->theWindow )
+ {
+ /* Most Carbon APIs are not thread-safe, therefore delagate some GUI visibilty update to the main thread */
+ sendEventToMainThread(GetWindowEventTarget(p_vout->p_sys->theWindow), kEventClassVLCPlugin, kEventVLCPluginHideFullscreen);
+ }
}
else
{
+ /* Go into fullscreen */
Rect deviceRect;
GDHandle deviceHdl = GetMainDevice();
@@ -696,7 +710,6 @@ static int aglManage( vout_thread_t * p_vout )
aglSetDrawable(p_vout->p_sys->agl_ctx, p_vout->p_sys->agl_drawable);
aglSetCurrentContext(p_vout->p_sys->agl_ctx);
aglSetViewport(p_vout, deviceRect, deviceRect);
- //aglSetFullScreen(p_vout->p_sys->agl_ctx, device_width, device_height, 0, 0);
/* Most Carbon APIs are not thread-safe, therefore delagate some GUI visibilty update to the main thread */
sendEventToMainThread(GetWindowEventTarget(p_vout->p_sys->theWindow), kEventClassVLCPlugin, kEventVLCPluginShowFullscreen);
@@ -875,7 +888,7 @@ static pascal OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, Event
vlc_value_t val;
val.b_bool = VLC_FALSE;
- var_Set((vout_thread_t *) p_vout->p_parent, "fullscreen", val);
+ var_Set( p_vout->p_parent, "fullscreen", val);
}
else
{
More information about the vlc-devel
mailing list