]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/audiobargraph_v.c
Use same string in definition as in ui
[vlc] / modules / video_filter / audiobargraph_v.c
index fbd7f3981dce46266c37514fe6c730c375f99cc1..ed2fb1f301509ac63c4a9f37d74eee41868e0a48 100644 (file)
@@ -1,24 +1,24 @@
 /*****************************************************************************
  * audiobargraph_v.c : audiobargraph video plugin for vlc
  *****************************************************************************
- * Copyright (C) 2003-2006 the VideoLAN team
+ * Copyright (C) 2003-2006 VLC authors and VideoLAN
  *
  * Authors: Clement CHESNIN <clement.chesnin@gmail.com>
  *          Philippe COENT <philippe.coent@tdf.fr>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 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
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -45,7 +45,7 @@
  *****************************************************************************/
 
 #define I_VALUES_TEXT N_("Value of the audio channels levels")
-#define I_VALUES_LONGTEXT N_("Value of the audio level of each channels between 0 and 1" \
+#define I_VALUES_LONGTEXT N_("Value of the audio level of each channels between 0 and 1" \
     "Each level should be separated with ':'.")
 #define POSX_TEXT N_("X coordinate")
 #define POSX_LONGTEXT N_("X coordinate of the bargraph." )
@@ -238,7 +238,7 @@ static int OpenCommon( vlc_object_t *p_this, bool b_sub )
     p_sys->i_pos_y = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-y" );
     p_BarGraph->i_alpha = var_CreateGetIntegerCommand( p_filter,
                                                         "audiobargraph_v-transparency" );
-    p_BarGraph->i_alpha = __MAX( __MIN( p_BarGraph->i_alpha, 255 ), 0 );
+    p_BarGraph->i_alpha = VLC_CLIP( p_BarGraph->i_alpha, 0, 255 );
     i_values = var_CreateGetStringCommand( p_filter, "audiobargraph_v-i_values" );
     //p_BarGraph->nbChannels = 0;
     //p_BarGraph->i_values = NULL;
@@ -461,7 +461,6 @@ static int BarGraphCallback( vlc_object_t *p_this, char const *psz_var,
     VLC_UNUSED(oldval);
     filter_sys_t *p_sys = (filter_sys_t *)p_data;
     BarGraph_t *p_BarGraph = &(p_sys->p_BarGraph);
-    char* i_values;
     char* res = NULL;
 
     vlc_mutex_lock( &p_sys->lock );
@@ -479,7 +478,7 @@ static int BarGraphCallback( vlc_object_t *p_this, char const *psz_var,
     }
     else if ( !strcmp( psz_var, "audiobargraph_v-transparency" ) )
     {
-        p_BarGraph->i_alpha = __MAX( __MIN( newval.i_int, 255 ), 0 );
+        p_BarGraph->i_alpha = VLC_CLIP( newval.i_int, 0, 255 );
     }
     else if ( !strcmp( psz_var, "audiobargraph_v-i_values" ) )
     {
@@ -488,15 +487,16 @@ static int BarGraphCallback( vlc_object_t *p_this, char const *psz_var,
             picture_Release( p_BarGraph->p_pic );
             p_BarGraph->p_pic = NULL;
         }
-        i_values = strdup( newval.psz_string );
+        char *psz_i_values = strdup( newval.psz_string );
         free(p_BarGraph->i_values);
         //p_BarGraph->i_values = NULL;
         //p_BarGraph->nbChannels = 0;
         // in case many answer are received at the same time, only keep one
-        res = strchr(i_values, '@');
+        res = strchr(psz_i_values, '@');
         if (res)
             *res = 0;
-        parse_i_values( p_BarGraph, i_values);
+        parse_i_values( p_BarGraph, psz_i_values);
+        free( psz_i_values );
         LoadBarGraph(p_this,p_BarGraph);
     }
     else if ( !strcmp( psz_var, "audiobargraph_v-alarm" ) )
@@ -939,7 +939,7 @@ void parse_i_values( BarGraph_t *p_BarGraph, char *i_values)
         p_BarGraph->nbChannels++;
         p_BarGraph->i_values = xrealloc(p_BarGraph->i_values,
                                           p_BarGraph->nbChannels*sizeof(int));
-        p_BarGraph->i_values[p_BarGraph->nbChannels-1] = __MAX( __MIN( atof(res)*p_BarGraph->scale, p_BarGraph->scale ), 0 );
+        p_BarGraph->i_values[p_BarGraph->nbChannels-1] = VLC_CLIP( atof(res)*p_BarGraph->scale, 0, p_BarGraph->scale );
         res = strtok_r(NULL, delim, &tok);
     }