]> git.sesse.net Git - vlc/blobdiff - modules/video_output/opengl.c
Remove useless test before a free().
[vlc] / modules / video_output / opengl.c
index dfeeb6bbe8f1958e305e98df1bf51879f5958bfb..a3b1ba9a7d36e5f3bc2554ac538ebbe5725df237 100644 (file)
  *****************************************************************************/
 #include <errno.h>                                                 /* ENOMEM */
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
 #include <vlc_vout.h>
 
@@ -141,7 +145,7 @@ static int SendEvents    ( vlc_object_t *, char const *,
 
 #ifdef OPENGL_MORE_EFFECT
 static float Z_Compute   ( float, int, float, float );
-static void Transform    ( float, int, float, float, int, int, int, int, double *, double * );
+static void Transform    ( int, float, float, int, int, int, int, double *, double * );
 
 /*****************************************************************************
  * Module descriptor
@@ -160,6 +164,8 @@ static void Transform    ( float, int, float, float, int, int, int, int, double
 #define POV_Z_LONGTEXT N_("Point of view (Z coordinate) of the cube/cylinder "\
                            "effect, if enabled.")
 #endif
+#define PROVIDER_TEXT N_("OpenGL Provider")
+#define PROVIDER_LONGTEXT N_("Allows you to modify what OpenGL provider should be used")
 #define SPEED_TEXT N_( "OpenGL cube rotation speed" )
 #define SPEED_LONGTEXT N_( "Rotation speed of the OpenGL cube effect, if " \
         "enabled." )
@@ -200,6 +206,9 @@ vlc_module_begin();
                     RADIUS_LONGTEXT, VLC_TRUE );
 
 #endif
+    /* Allow opengl provider plugin selection */
+    add_string( "opengl-provider", "default", NULL, PROVIDER_TEXT, 
+                    PROVIDER_LONGTEXT, VLC_TRUE );
     set_callbacks( CreateVout, DestroyVout );
     add_string( "opengl-effect", "none", NULL, EFFECT_TEXT,
                  EFFECT_LONGTEXT, VLC_FALSE );
@@ -235,6 +244,7 @@ static int CreateVout( vlc_object_t *p_this )
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
     vout_sys_t *p_sys;
+    char * psz;
 
     /* Allocate structure */
     p_vout->p_sys = p_sys = malloc( sizeof( vout_sys_t ) );
@@ -280,13 +290,19 @@ static int CreateVout( vlc_object_t *p_this )
     p_sys->p_vout->b_scale = p_vout->b_scale;
     p_sys->p_vout->i_alignment = p_vout->i_alignment;
 
+    psz = config_GetPsz( p_vout, "opengl-provider" );
+
+    msg_Dbg( p_vout, "requesting \"%s\" opengl provider",
+                      psz ? psz : "default" );
+
     p_sys->p_vout->p_module =
-        module_Need( p_sys->p_vout, "opengl provider", NULL, 0 );
+        module_Need( p_sys->p_vout, "opengl provider", psz, 0 );
+    free( psz );
     if( p_sys->p_vout->p_module == NULL )
     {
         msg_Warn( p_vout, "No OpenGL provider found" );
         vlc_object_detach( p_sys->p_vout );
-        vlc_object_destroy( p_sys->p_vout );
+        vlc_object_release( p_sys->p_vout );
         return VLC_ENOOBJ;
     }
 
@@ -479,7 +495,7 @@ static int Init( vout_thread_t *p_vout )
         p_sys->i_effect = OPENGL_EFFECT_NONE;
 #endif
     }
-    if( val.psz_string ) free( val.psz_string );
+    free( val.psz_string );
 
     if( p_sys->i_effect & ( OPENGL_EFFECT_CUBE |
                 OPENGL_EFFECT_TRANSPARENT_CUBE ) )
@@ -537,8 +553,8 @@ static void End( vout_thread_t *p_vout )
 
     /* Free the texture buffer*/
     glDeleteTextures( 2, p_sys->p_textures );
-    if( p_sys->pp_buffer[0] ) free( p_sys->pp_buffer[0] );
-    if( p_sys->pp_buffer[1] ) free( p_sys->pp_buffer[1] );
+    free( p_sys->pp_buffer[0] );
+    free( p_sys->pp_buffer[1] );
 
     if( p_sys->p_vout->pf_unlock )
     {
@@ -558,7 +574,7 @@ static void DestroyVout( vlc_object_t *p_this )
 
     module_Unneed( p_sys->p_vout, p_sys->p_vout->p_module );
     vlc_object_detach( p_sys->p_vout );
-    vlc_object_destroy( p_sys->p_vout );
+    vlc_object_release( p_sys->p_vout );
 
     free( p_sys );
 }
@@ -675,7 +691,6 @@ static int Manage( vout_thread_t *p_vout )
         p_vout->i_changes = VOUT_CROP_CHANGE;        //to force change
         p_sys->p_vout->i_alignment = p_vout->i_alignment;    
     }
-    
     return i_ret;
 }
 
@@ -684,6 +699,7 @@ static int Manage( vout_thread_t *p_vout )
  *****************************************************************************/
 static void Render( vout_thread_t *p_vout, picture_t *p_pic )
 {
+    VLC_UNUSED(p_pic);
     vout_sys_t *p_sys = p_vout->p_sys;
 
     /* On Win32/GLX, we do this the usual way:
@@ -748,7 +764,7 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic )
 /*****************************************************************************
  *   Transform: Calculate the distorted grid coordinates
  *****************************************************************************/
-static void Transform(float p, int distortion, float width, float height,int i, int j, int i_visible_width, int i_visible_height, double *ix,double *iy)
+static void Transform( int distortion, float width, float height,int i, int j, int i_visible_width, int i_visible_height, double *ix, double *iy )
 {
     double x,y,xnew,ynew;
     double r,theta,rnew,thetanew;
@@ -857,6 +873,7 @@ static float Z_Compute(float p, int distortion, float x, float y)
  *****************************************************************************/
 static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
 {
+    VLC_UNUSED(p_pic);
     vout_sys_t *p_sys = p_vout->p_sys;
     float f_width, f_height, f_x, f_y;
 
@@ -939,7 +956,7 @@ static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
                 int i_k = ((i_m % 4) == 1) || ((i_m % 4) == 2);
                 int i_l = ((i_m % 4) == 2) || ((i_m % 4) == 3);
 
-                Transform(f_p, i_distortion, f_width, f_height, i_i + i_k * i_n_x, i_j + i_l * i_n_y, p_vout->fmt_out.i_visible_width, p_vout->fmt_out.i_visible_height, &d_x, &d_y);
+                Transform( i_distortion, f_width, f_height, i_i + i_k * i_n_x, i_j + i_l * i_n_y, p_vout->fmt_out.i_visible_width, p_vout->fmt_out.i_visible_height, &d_x, &d_y);
                 glTexCoord2f(f_x + d_x, f_y + d_y);
                 d_x =  - 1.0 + 2.0 * ((double)(i_k * i_n_x + i_i) / (double)p_vout->fmt_out.i_visible_width);
                 d_y =    1.0 - 2.0 * (((double)i_l * i_n_y + i_j) / (double)p_vout->fmt_out.i_visible_height);
@@ -1091,5 +1108,6 @@ static int InitTextures( vout_thread_t *p_vout )
 static int SendEvents( vlc_object_t *p_this, char const *psz_var,
                        vlc_value_t oldval, vlc_value_t newval, void *_p_vout )
 {
+    VLC_UNUSED(p_this); VLC_UNUSED(oldval);
     return var_Set( (vlc_object_t *)_p_vout, psz_var, newval );
 }