]> git.sesse.net Git - vlc/blobdiff - modules/audio_filter/audiobargraph_a.c
Spatializer: kill warnings and improve locality
[vlc] / modules / audio_filter / audiobargraph_a.c
index 4973ded76db40e86ba821edbf71202dfc08b9ab2..7236eb3af48f5d9a6c5eef2e712504d40b944323 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * audiobargraph_a.c : audiobargraph audio plugin for vlc
  *****************************************************************************
- * Copyright (C) 2002-2006 the VideoLAN team
+ * Copyright (C) 2002-2009 the VideoLAN team
  * $Id$
  *
  * Authors: Clement CHESNIN <clement.chesnin@gmail.com>
@@ -37,8 +37,6 @@
 #include <vlc_network.h>
 #include <math.h>
 
-
-
 #define ADDRESS_TEXT N_("TCP address to use (default localhost)")
 #define ADDRESS_LONGTEXT N_("TCP address to use to communicate with the video "\
                 "part of the Bar Graph (default localhost)." \
 #define PORT_LONGTEXT N_("TCP port to use to communicate with the video "\
                 "part of the Bar Graph (default 12345)." \
                 "Use the same port as the one used in the rc interface." )
-#define BARGRAPH_TEXT N_("Defines if BarGraph information should be send (default 1)")
-#define BARGRAPH_LONGTEXT N_("Defines if BarGraph information should be send. "\
+#define BARGRAPH_TEXT N_("Defines if BarGraph information should be sent (default 1)")
+#define BARGRAPH_LONGTEXT N_("Defines if BarGraph information should be sent. "\
                 "1 if the information should be sent, 0 otherwise (default 1)." )
 #define BARGRAPH_REPETITION_TEXT N_("Sends the barGraph information every n audio packets (default 4)")
 #define BARGRAPH_REPETITION_LONGTEXT N_("Defines how often the barGraph information should be sent. "\
                 "Sends the barGraph information every n audio packets (default 4)." )
-#define SILENCE_TEXT N_("Defines if silence alarm information should be send (default 1)")
-#define SILENCE_LONGTEXT N_("Defines if silence alarm information should be send. "\
+#define SILENCE_TEXT N_("Defines if silence alarm information should be sent (default 1)")
+#define SILENCE_LONGTEXT N_("Defines if silence alarm information should be sent. "\
                 "1 if the information should be sent, 0 otherwise (default 1)." )
 #define TIME_WINDOW_TEXT N_("Time window to use in ms (default 5000)")
 #define TIME_WINDOW_LONGTEXT N_("Time Window during when the audio level is measured in ms for silence detection. "\
@@ -64,7 +62,7 @@
 #define ALARM_THRESHOLD_LONGTEXT N_("Threshold to be attained to raise an alarm. "\
                 "If the audio level is under the threshold during this time, "\
                 "an alarm is sent (default 0.1)." )
-#define REPETITION_TIME_TEXT N_("Time between two alamr messages in ms (default 2000)" )
+#define REPETITION_TIME_TEXT N_("Time between two alarm messages in ms (default 2000)" )
 #define REPETITION_TIME_LONGTEXT N_("Time between two alarm messages in ms. "\
                 "This value is used to avoid alarm saturation (default 2000)." )
 #define CONNECTION_RESET_TEXT N_("Force connection reset regularly (default 1)" )
@@ -82,21 +80,21 @@ static block_t *DoWork( filter_t *, block_t * );
 
 vlc_module_begin ()
     set_description( N_("Audio part of the BarGraph function") )
-    set_shortname( N_("audiobargraph_a") )
+    set_shortname( N_("Audiobar Graph") )
     set_capability( "audio filter", 0 )
     set_category( CAT_AUDIO )
     set_subcategory( SUBCAT_AUDIO_AFILTER )
-    
-    add_string( CFG_PREFIX "address", "localhost", NULL, ADDRESS_TEXT, ADDRESS_LONGTEXT, false )
-    add_integer( CFG_PREFIX "port", 12345, NULL, PORT_TEXT, PORT_LONGTEXT, false )
-    add_integer( CFG_PREFIX "bargraph", 1, NULL, BARGRAPH_TEXT, BARGRAPH_LONGTEXT, false )
-    add_integer( CFG_PREFIX "bargraph_repetition", 4, NULL, BARGRAPH_REPETITION_TEXT, BARGRAPH_REPETITION_LONGTEXT, false )
-    add_integer( CFG_PREFIX "silence", 1, NULL, SILENCE_TEXT, SILENCE_LONGTEXT, false )
-    add_integer( CFG_PREFIX "time_window", 5000, NULL, TIME_WINDOW_TEXT, TIME_WINDOW_LONGTEXT, false )
-    add_float( CFG_PREFIX "alarm_threshold", 0.1, NULL, ALARM_THRESHOLD_TEXT, ALARM_THRESHOLD_LONGTEXT, false )
-    add_integer( CFG_PREFIX "repetition_time", 2000, NULL, REPETITION_TIME_TEXT, REPETITION_TIME_LONGTEXT, false )
-    add_integer( CFG_PREFIX "connection_reset", 1, NULL, CONNECTION_RESET_TEXT, CONNECTION_RESET_LONGTEXT, false )
-    
+
+    add_string( CFG_PREFIX "address", "localhost", ADDRESS_TEXT, ADDRESS_LONGTEXT, false )
+    add_integer( CFG_PREFIX "port", 12345, PORT_TEXT, PORT_LONGTEXT, false )
+    add_integer( CFG_PREFIX "bargraph", 1, BARGRAPH_TEXT, BARGRAPH_LONGTEXT, false )
+    add_integer( CFG_PREFIX "bargraph_repetition", 4, BARGRAPH_REPETITION_TEXT, BARGRAPH_REPETITION_LONGTEXT, false )
+    add_integer( CFG_PREFIX "silence", 1, SILENCE_TEXT, SILENCE_LONGTEXT, false )
+    add_integer( CFG_PREFIX "time_window", 5000, TIME_WINDOW_TEXT, TIME_WINDOW_LONGTEXT, false )
+    add_float( CFG_PREFIX "alarm_threshold", 0.1, ALARM_THRESHOLD_TEXT, ALARM_THRESHOLD_LONGTEXT, false )
+    add_integer( CFG_PREFIX "repetition_time", 2000, REPETITION_TIME_TEXT, REPETITION_TIME_LONGTEXT, false )
+    add_integer( CFG_PREFIX "connection_reset", 1, CONNECTION_RESET_TEXT, CONNECTION_RESET_LONGTEXT, false )
+
     set_callbacks( Open, Close )
 vlc_module_end ()
 
@@ -153,7 +151,7 @@ static int Open( vlc_object_t *p_this )
     p_sys = p_filter->p_sys = malloc( sizeof( *p_sys ) );
     if( !p_sys )
         return VLC_ENOMEM;
-        
+
     p_sys->bargraph = var_CreateGetIntegerCommand( p_filter, "audiobargraph_a-bargraph" );
     p_sys->bargraph_repetition = var_CreateGetIntegerCommand( p_filter, "audiobargraph_a-bargraph_repetition" );
     p_sys->silence = var_CreateGetIntegerCommand( p_filter, "audiobargraph_a-silence" );
@@ -195,17 +193,16 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
     ValueDate_t* current = NULL;
     float sum;
     int count = 0;
-    int i_ret;
-    
+
     nbChannels = aout_FormatNbChannels( &p_filter->fmt_in.audio );
     p_sys->nbChannels = nbChannels;
-    
+
     i_value = (float*)malloc(nbChannels * sizeof(float));
-    
+
     for (i=0; i<nbChannels; i++) {
         i_value[i] = 0;
     }
-    
+
     /* 1 - Compute the peack values */
     for ( i = 0 ; i < (int)(p_in_buf->i_nb_samples); i++ )
     {
@@ -218,7 +215,7 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
         }
     }
     max = pow( max, 2 );
-    
+
     if (p_sys->silence) {
         /* 2 - store the new value */
         new = (ValueDate_t*)malloc(sizeof(ValueDate_t));
@@ -232,7 +229,7 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
         if (p_sys->first == NULL) {
             p_sys->first = new;
         }
-        
+
         /* 3 - delete too old values */
         while (p_sys->first->date < (new->date - (p_sys->time_window*1000))) {
             p_sys->started = 1; // we have enough values to compute a valid total
@@ -240,10 +237,10 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
             p_sys->first = p_sys->first->next;
             free(current);
         }
-        
+
         /* If last message was sent enough time ago */
         if ((p_sys->started) && (p_in_buf->i_pts > p_sys->lastAlarm + (p_sys->repetition_time*1000))) {
-            
+
             /* 4 - compute the RMS */
             current = p_sys->first;
             sum = 0.0;
@@ -254,7 +251,7 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
             }
             sum = sum / count;
             sum = sqrt(sum);
-        
+
             /* 5 - compare it to the threshold */
             if (sum < p_sys->alarm_threshold) {
                 i=1;
@@ -262,12 +259,12 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
                 i=0;
             }
             snprintf(message,255,"@audiobargraph_v audiobargraph_v-alarm %d\n",i);
-            
+
             msg_Dbg( p_filter, "message alarm : %s", message );
             //TCPconnection = net_ConnectTCP(p_filter,p_sys->address,p_sys->port);
             net_Write(p_filter, p_sys->TCPconnection, NULL, message, strlen(message));
             //net_Close(TCPconnection);
-            
+
             p_sys->lastAlarm = p_in_buf->i_pts;
         }
     }
@@ -279,7 +276,7 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
         else
             p_sys->value[i] = p_sys->value[i] - 6;
     }*/
-    
+
     if (p_sys->bargraph) {
         /* 6 - sent the message with the values for the BarGraph */
         if ((nbChannels > 0) && (p_sys->counter%(p_sys->bargraph_repetition) == 0)) {
@@ -293,13 +290,13 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
             //test = send(p_sys->TCPconnection,message,strlen(message),0);
             //net_Write(p_filter, p_sys->TCPconnection, NULL, message, strlen(message));
 
-            i_ret= net_Write(p_filter, p_sys->TCPconnection, NULL, message, strlen(message));
+            net_Write(p_filter, p_sys->TCPconnection, NULL, message, strlen(message));
 
         }
     }
-    
+
     free(i_value);
-    
+
     if (p_sys->counter > p_sys->bargraph_repetition*100) {
         if (p_sys->connection_reset) {
             net_Close(p_sys->TCPconnection);
@@ -307,10 +304,10 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
         }
         p_sys->counter = 0;
     }
-    
+
     //free(message);
     p_sys->counter++;
-    
+
     return p_in_buf;
 }
 
@@ -322,7 +319,7 @@ static void Close( vlc_object_t *p_this )
     filter_t * p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
     ValueDate_t* current;
-    
+
     p_sys->last = NULL;
     while (p_sys->first != NULL) {
         current = p_sys->first;