]> git.sesse.net Git - vlc/commitdiff
video_output/opengl.c: fixed a (OS X only) segfault
authorEric Petit <titer@videolan.org>
Fri, 18 Feb 2005 14:01:21 +0000 (14:01 +0000)
committerEric Petit <titer@videolan.org>
Fri, 18 Feb 2005 14:01:21 +0000 (14:01 +0000)
 macosx/vout*.m: cleaning

modules/gui/macosx/vout.m
modules/gui/macosx/voutgl.m
modules/gui/macosx/voutqt.m
modules/video_output/opengl.c

index 484f8cb63a0b328e60a6c6432e9aea98656aa084..e372ca35600f3efd6a08fc645c17f72839504ca3 100644 (file)
 
 - (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. */
 
     [self updateTitle];
     [self makeKeyAndOrderFront: nil];
+    [self setReleasedWhenClosed: YES];
 
     /* We'll catch mouse events */
     [self setAcceptsMouseMovedEvents: YES];
 {
     if( p_fullscreen_state )
     {
-        EndFullScreen( p_fullscreen_state, NULL );
+        EndFullScreen( p_fullscreen_state, 0 );
     }
     [super close];
 }
index bceb7bcbb458b3547a181d71899bfd0586489da5..5eded56574f44d55f769a5a031668c75e0c40332 100644 (file)
@@ -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,
index 390fe50cb06d744034107aaf4645307ccb82313c..831c6f8a3b2694c401c4bb1c388a8948da882560 100644 (file)
@@ -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];
index 872c4776ba438b07daa2c6a67f5963221c9394c3..8e492283e5c7f3c49e364a5ffc36ffad3ec8894b 100644 (file)
@@ -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;