Commit 70944c2a authored by Eric Petit's avatar Eric Petit

video_output/opengl.c: fixed a (OS X only) segfault

 macosx/vout*.m: cleaning
parent 3ce6222f
......@@ -47,10 +47,26 @@
- (id)initWithVout:(vout_thread_t *)_p_vout frame:(NSRect *)s_frame
{
[self setReleasedWhenClosed: YES];
int i_timeout;
p_vout = _p_vout;
/* Wait for a MacOS X interface to appear. Timeout is 2 seconds. */
for( i_timeout = 20 ; i_timeout-- ; )
{
if( NSApp == NULL )
{
msleep( INTF_IDLE_SLEEP );
}
}
if( NSApp == NULL )
{
/* No MacOS X intf, unable to communicate with MT */
msg_Err( p_vout, "no MacOS X interface present" );
return NULL;
}
/* p_real_vout: the vout we have to use to check for video-on-top
and a few other things. If we are the QuickTime output, it's us.
It we are the OpenGL provider, it is our parent. */
......@@ -202,6 +218,7 @@
[self updateTitle];
[self makeKeyAndOrderFront: nil];
[self setReleasedWhenClosed: YES];
/* We'll catch mouse events */
[self setAcceptsMouseMovedEvents: YES];
......@@ -215,7 +232,7 @@
{
if( p_fullscreen_state )
{
EndFullScreen( p_fullscreen_state, NULL );
EndFullScreen( p_fullscreen_state, 0 );
}
[super close];
}
......
......@@ -14,7 +14,7 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
......@@ -76,12 +76,6 @@ static void Swap ( vout_thread_t * p_vout );
int E_(OpenVideoGL) ( vlc_object_t * p_this )
{
vout_thread_t * p_vout = (vout_thread_t *) p_this;
int i_timeout;
/* OpenGL interface disabled until
* - the green line is gone
* - other problems?????
*/
if( !CGDisplayUsesOpenGLAcceleration( kCGDirectMainDisplay ) )
{
......@@ -99,35 +93,17 @@ int E_(OpenVideoGL) ( vlc_object_t * p_this )
memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
/* Wait for a MacOS X interface to appear. Timeout is 2 seconds. */
for( i_timeout = 20 ; i_timeout-- ; )
{
if( NSApp == NULL )
{
msleep( INTF_IDLE_SLEEP );
}
}
if( NSApp == NULL )
{
/* No MacOS X intf, unable to communicate with MT */
msg_Err( p_vout, "no MacOS X interface present" );
return VLC_EGENERIC;
}
p_vout->pf_init = Init;
p_vout->pf_end = End;
p_vout->pf_manage = Manage;
p_vout->pf_control= Control;
p_vout->pf_swap = Swap;
p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
/* Spawn window */
p_vout->p_sys->b_got_frame = VLC_FALSE;
p_vout->p_sys->o_window = [[VLCWindow alloc] initWithVout: p_vout
frame: nil];
if( !p_vout->p_sys->o_window )
{
return VLC_EGENERIC;
}
/* Add OpenGL view */
#define o_glview p_vout->p_sys->o_glview
o_glview = [[VLCGLView alloc] initWithFrame:
......@@ -136,13 +112,19 @@ int E_(OpenVideoGL) ( vlc_object_t * p_this )
[o_glview autorelease];
#undef o_glview
p_vout->pf_init = Init;
p_vout->pf_end = End;
p_vout->pf_manage = Manage;
p_vout->pf_control= Control;
p_vout->pf_swap = Swap;
return VLC_SUCCESS;
}
int E_(CloseVideoGL) ( vlc_object_t * p_this )
{
vout_thread_t * p_vout = (vout_thread_t *) p_this;
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
[p_vout->p_sys->o_window close];
......@@ -166,7 +148,7 @@ static int Manage( vout_thread_t * p_vout )
if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
{
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
if( !p_vout->b_fullscreen )
{
/* Save window size and position */
......@@ -245,7 +227,7 @@ static void Swap( vout_thread_t * p_vout )
- (id) initWithFrame: (NSRect) frame vout: (vout_thread_t*) _p_vout
{
p_vout = _p_vout;
NSOpenGLPixelFormatAttribute attribs[] =
{
NSOpenGLPFAAccelerated,
......
......@@ -107,7 +107,6 @@ int E_(OpenVideoQT) ( vlc_object_t *p_this )
{
vout_thread_t * p_vout = (vout_thread_t *)p_this;
OSErr err;
int i_timeout;
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
......@@ -118,22 +117,7 @@ int E_(OpenVideoQT) ( vlc_object_t *p_this )
memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
/* Wait for a MacOS X interface to appear. Timeout is 2 seconds. */
for( i_timeout = 20 ; i_timeout-- ; )
{
if( NSApp == NULL )
{
msleep( INTF_IDLE_SLEEP );
}
}
if( NSApp == NULL )
{
/* no MacOS X intf, unable to communicate with MT */
msg_Err( p_vout, "no MacOS X interface present" );
free( p_vout->p_sys );
return( 1 );
}
p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
p_vout->pf_init = InitVideo;
p_vout->pf_end = EndVideo;
......@@ -142,7 +126,13 @@ int E_(OpenVideoQT) ( vlc_object_t *p_this )
p_vout->pf_display = DisplayVideo;
p_vout->pf_control = ControlVideo;
p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
/* Spawn window */
p_vout->p_sys->o_window =
[[VLCWindow alloc] initWithVout: p_vout frame: nil];
if( !p_vout->p_sys->o_window )
{
return VLC_EGENERIC;
}
p_vout->p_sys->b_altivec = p_vout->p_libvlc->i_cpu & CPU_CAPABILITY_ALTIVEC;
msg_Dbg( p_vout, "We do%s have Altivec", p_vout->p_sys->b_altivec ? "" : "n't" );
......@@ -204,10 +194,6 @@ int E_(OpenVideoQT) ( vlc_object_t *p_this )
return VLC_EGENERIC;
}
/* Spawn window */
p_vout->p_sys->o_window =
[[VLCWindow alloc] initWithVout: p_vout frame: nil];
#define o_qtview p_vout->p_sys->o_qtview
o_qtview = [[VLCQTView alloc] initWithVout: p_vout];
[p_vout->p_sys->o_window setContentView: o_qtview];
......
......@@ -162,6 +162,7 @@ static int CreateVout( vlc_object_t *p_this )
var_Create( p_vout, "opengl-effect", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
p_sys->i_index = 0;
#ifdef SYS_DARWIN
p_sys->i_tex_width = p_vout->render.i_width;
p_sys->i_tex_height = p_vout->render.i_height;
......
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