]> git.sesse.net Git - vlc/blobdiff - modules/video_output/opengl.c
module_need wants pointers and boolean so give NULL and false instead of 0.
[vlc] / modules / video_output / opengl.c
index deab0f79fca2b7bc727b748f8fe1a49c1a6e7e77..065069ac2d1d60198cc824ef117f07bca2796c61 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <errno.h>                                                 /* ENOMEM */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
+#include <errno.h>                                                 /* ENOMEM */
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_vout.h>
@@ -181,17 +182,17 @@ static const char *const ppsz_effects_text[] = {
         N_("None"), N_("Cube"), N_("Transparent Cube") };
 #endif
 
-vlc_module_begin();
-    set_shortname( "OpenGL" );
-    set_category( CAT_VIDEO );
-    set_subcategory( SUBCAT_VIDEO_VOUT );
-    set_description( N_("OpenGL video output") );
+vlc_module_begin ()
+    set_shortname( "OpenGL" )
+    set_category( CAT_VIDEO )
+    set_subcategory( SUBCAT_VIDEO_VOUT )
+    set_description( N_("OpenGL video output") )
 #ifdef __APPLE__
-    set_capability( "video output", 200 );
+    set_capability( "video output", 200 )
 #else
-    set_capability( "video output", 20 );
+    set_capability( "video output", 20 )
 #endif
-    add_shortcut( "opengl" );
+    add_shortcut( "opengl" )
     add_float( "opengl-cube-speed", 2.0, NULL, SPEED_TEXT,
                     SPEED_LONGTEXT, true );
 #ifdef OPENGL_MORE_EFFECT
@@ -210,11 +211,11 @@ vlc_module_begin();
     /* Allow opengl provider plugin selection */
     add_string( "opengl-provider", "default", NULL, PROVIDER_TEXT, 
                     PROVIDER_LONGTEXT, true );
-    set_callbacks( CreateVout, DestroyVout );
+    set_callbacks( CreateVout, DestroyVout )
     add_string( "opengl-effect", "none", NULL, EFFECT_TEXT,
                  EFFECT_LONGTEXT, false );
         change_string_list( ppsz_effects, ppsz_effects_text, 0 );
-vlc_module_end();
+vlc_module_end ()
 
 /*****************************************************************************
  * vout_sys_t: video output method descriptor
@@ -269,10 +270,10 @@ static int CreateVout( vlc_object_t *p_this )
 
     /* Get window */
     p_sys->p_vout =
-        (vout_thread_t *)vlc_object_create( p_this, VLC_OBJECT_OPENGL );
+        (vout_thread_t *)vlc_object_create( p_this, sizeof( vout_thread_t ) );
     if( p_sys->p_vout == NULL )
     {
-        msg_Err( p_vout, "out of memory" );
+        free( p_sys );
         return VLC_ENOMEM;
     }
     vlc_object_attach( p_sys->p_vout, p_this );
@@ -294,7 +295,7 @@ static int CreateVout( vlc_object_t *p_this )
                       psz ? psz : "default" );
 
     p_sys->p_vout->p_module =
-        module_Need( p_sys->p_vout, "opengl provider", psz, 0 );
+        module_need( p_sys->p_vout, "opengl provider", psz, false );
     free( psz );
     if( p_sys->p_vout->p_module == NULL )
     {
@@ -468,18 +469,22 @@ static int Init( vout_thread_t *p_vout )
     else
     {
 #ifdef OPENGL_MORE_EFFECT
-        p_sys->i_effect = 3;
-        while (( strcmp( val.psz_string, ppsz_effects[p_sys->i_effect]) ) && (pow(2,p_sys->i_effect) < INIFILE))
+        long i, size = sizeof(ppsz_effects)/sizeof(*ppsz_effects);
+        p_sys->i_effect = OPENGL_EFFECT_NONE;
+
+        for(i = 3; i < size; i++)
         {
-            p_sys->i_effect ++;
+            if(!strcmp( val.psz_string, ppsz_effects[i]))
+            {
+                p_sys->i_effect = 1 << i;
+                break;
+            }
         }
-        if (pow(2,p_sys->i_effect) < INIFILE)
-            p_sys->i_effect = pow(2,p_sys->i_effect);
-        else if ( strcmp( val.psz_string, ppsz_effects[p_sys->i_effect]))
+
+        if( p_sys->i_effect == OPENGL_EFFECT_NONE )
         {
             msg_Warn( p_vout, "no valid opengl effect provided, using "
                       "\"none\"" );
-            p_sys->i_effect = OPENGL_EFFECT_NONE;
         }
 #else
         msg_Warn( p_vout, "no valid opengl effect provided, using "
@@ -564,8 +569,7 @@ static void DestroyVout( vlc_object_t *p_this )
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
     vout_sys_t *p_sys = p_vout->p_sys;
 
-    module_Unneed( p_sys->p_vout, p_sys->p_vout->p_module );
-    vlc_object_detach( p_sys->p_vout );
+    module_unneed( p_sys->p_vout, p_sys->p_vout->p_module );
     vlc_object_release( p_sys->p_vout );
 
     free( p_sys );