]> git.sesse.net Git - vlc/blobdiff - modules/control/rc.c
The last but not the least commit about these useless tests.
[vlc] / modules / control / rc.c
index 63dd4a0c5561ac9a36bca6f341e8fb8f8f109e03..e771248ddc2d9235d5c8858cef1b2b5c2441c381 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
 
 #include <errno.h>                                                 /* ENOMEM */
@@ -99,7 +103,7 @@ static int  Statistics   ( vlc_object_t *, char const *,
                            vlc_value_t, vlc_value_t, void * );
 
 static int updateStatistics( intf_thread_t *, input_item_t *);
-#ifdef UPDATE_CHECK
+#if 0 && defined( UPDATE_CHECK )
 static void checkUpdates( intf_thread_t *p_intf );
 #endif
 
@@ -122,7 +126,6 @@ struct intf_sys_t
     /* status changes */
     vlc_mutex_t       status_lock;
     playlist_status_t i_last_state;
-    vlc_bool_t        b_statistics;
 
 #ifdef WIN32
     HANDLE hConsoleIn;
@@ -130,10 +133,7 @@ struct intf_sys_t
 #endif
 };
 
-#ifdef HAVE_VARIADIC_MACROS
-#   define msg_rc( psz_format, args... ) \
-      __msg_rc( p_intf, psz_format, ## args )
-#endif
+#define msg_rc( ... ) __msg_rc( p_intf, __VA_ARGS__ )
 
 static void __msg_rc( intf_thread_t *p_intf, const char *psz_fmt, ... )
 {
@@ -323,7 +323,6 @@ static int Activate( vlc_object_t *p_this )
     p_intf->p_sys->psz_unix_path = psz_unix_path;
     vlc_mutex_init( p_intf, &p_intf->p_sys->status_lock );
     p_intf->p_sys->i_last_state = PLAYLIST_STOPPED;
-    p_intf->p_sys->b_statistics = VLC_FALSE;
 
     /* Non-buffered stdout */
     setvbuf( stdout, (char *)NULL, _IOLBF, 0 );
@@ -582,13 +581,6 @@ static void Run( intf_thread_t *p_intf )
             }
         }
 
-        if( p_input && p_intf->p_sys->b_statistics )
-        {
-            vlc_mutex_lock( &input_GetItem(p_input)->lock );
-            updateStatistics( p_intf, input_GetItem(p_input) );
-            vlc_mutex_unlock( &input_GetItem(p_input)->lock );
-        }
-
         /* Is there something to do? */
         if( !b_complete ) continue;
 
@@ -612,7 +604,7 @@ static void Run( intf_thread_t *p_intf )
         }
         else
         {
-            psz_arg = "";
+            psz_arg = (char*)"";
         }
 
         /* module specfic commands: @<module name> <command> <args...> */
@@ -766,7 +758,7 @@ static void Run( intf_thread_t *p_intf )
 
             Help( p_intf, b_longhelp );
         }
-#ifdef UPDATE_CHECK
+#if 0 && defined( UPDATE_CHECK )
         else if( !strcmp( psz_cmd, "check-updates" ) )
         {
             checkUpdates( p_intf );
@@ -941,7 +933,7 @@ static void Help( intf_thread_t *p_intf, vlc_bool_t b_longhelp)
         msg_rc(_("| @name mosaic-cols #. . . . . . . . . . .number of cols"));
         msg_rc(_("| @name mosaic-order id(,id)* . . . . order of pictures "));
         msg_rc(_("| @name mosaic-keep-aspect-ratio {0,1} . . .aspect ratio"));
-#ifdef UPDATE_CHECK
+#if 0 && defined( UPDATE_CHECK )
         msg_rc(  "| ");
         msg_rc(_("| check-updates [newer] [equal] [older]\n"
                  "|               [undef] [info] [source] [binary] [plugin]"));
@@ -962,6 +954,8 @@ static void Help( intf_thread_t *p_intf, vlc_bool_t b_longhelp)
 static int TimeOffsetChanged( vlc_object_t *p_this, char const *psz_cmd,
     vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(p_this); VLC_UNUSED(psz_cmd);
+    VLC_UNUSED(oldval); VLC_UNUSED(newval);
     intf_thread_t *p_intf = (intf_thread_t*)p_data;
     input_thread_t *p_input = NULL;
 
@@ -980,6 +974,7 @@ static int TimeOffsetChanged( vlc_object_t *p_this, char const *psz_cmd,
 static int VolumeChanged( vlc_object_t *p_this, char const *psz_cmd,
     vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(newval);
     intf_thread_t *p_intf = (intf_thread_t*)p_data;
 
     vlc_mutex_lock( &p_intf->p_sys->status_lock );
@@ -992,6 +987,7 @@ static int VolumeChanged( vlc_object_t *p_this, char const *psz_cmd,
 static int StateChanged( vlc_object_t *p_this, char const *psz_cmd,
     vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(p_this); VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
     intf_thread_t *p_intf = (intf_thread_t*)p_data;
     playlist_t    *p_playlist = NULL;
     input_thread_t *p_input = NULL;
@@ -1030,6 +1026,8 @@ static int StateChanged( vlc_object_t *p_this, char const *psz_cmd,
 static int RateChanged( vlc_object_t *p_this, char const *psz_cmd,
     vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(p_this); VLC_UNUSED(psz_cmd);
+    VLC_UNUSED(oldval); VLC_UNUSED(newval);
     intf_thread_t *p_intf = (intf_thread_t*)p_data;
     input_thread_t *p_input = NULL;
 
@@ -1051,6 +1049,7 @@ static int RateChanged( vlc_object_t *p_this, char const *psz_cmd,
 static int Input( vlc_object_t *p_this, char const *psz_cmd,
                   vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(oldval); VLC_UNUSED(p_data);
     intf_thread_t *p_intf = (intf_thread_t*)p_this;
     input_thread_t *p_input;
     vlc_value_t     val;
@@ -1271,7 +1270,7 @@ static int Input( vlc_object_t *p_this, char const *psz_cmd,
                         &val, &text );
             msg_rc( "+----[ end of %s ]", val_name.psz_string );
 
-            if( val_name.psz_string ) free( val_name.psz_string );
+            free( val_name.psz_string );
 
             i_error = VLC_SUCCESS;
         }
@@ -1287,6 +1286,7 @@ static int Input( vlc_object_t *p_this, char const *psz_cmd,
 static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
                      vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(oldval); VLC_UNUSED(p_data);
     vlc_value_t val;
 
     intf_thread_t *p_intf = (intf_thread_t*)p_this;
@@ -1423,9 +1423,12 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
         if( p_item )
         {
             msg_rc( "Trying to add %s to playlist.", newval.psz_string );
-            playlist_AddInput( p_playlist, p_item,
+            if( playlist_AddInput( p_playlist, p_item,
                      PLAYLIST_GO|PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
-                     VLC_FALSE );
+                     VLC_FALSE ) != VLC_SUCCESS );
+            {
+                return VLC_EGENERIC;
+            }
         }
     }
     else if( !strcmp( psz_cmd, "enqueue" ) &&
@@ -1436,9 +1439,12 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
         if( p_item )
         {
             msg_rc( "trying to enqueue %s to playlist", newval.psz_string );
-            playlist_AddInput( p_playlist, p_item,
+            if( playlist_AddInput( p_playlist, p_item,
                                PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
-                               VLC_FALSE);
+                               VLC_FALSE ) != VLC_SUCCESS )
+            {
+                return VLC_EGENERIC;
+            }
         }
     }
     else if( !strcmp( psz_cmd, "playlist" ) )
@@ -1465,7 +1471,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
             msg_rc( STATUS_CHANGE "( audio volume: %d )",
                     config_GetInt( p_intf, "volume" ));
 
-            vlc_mutex_lock( &p_playlist->object_lock );
+            PL_LOCK;
             switch( p_playlist->status.i_status )
             {
                 case PLAYLIST_STOPPED:
@@ -1481,7 +1487,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
                     msg_rc( STATUS_CHANGE "( state unknown )" );
                     break;
             }
-            vlc_mutex_unlock( &p_playlist->object_lock );
+            PL_UNLOCK;
         }
     }
 
@@ -1500,6 +1506,8 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
 static int Quit( vlc_object_t *p_this, char const *psz_cmd,
                  vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(p_data); VLC_UNUSED(psz_cmd);
+    VLC_UNUSED(oldval); VLC_UNUSED(newval);
     playlist_t *p_playlist;
 
     p_playlist = vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
@@ -1515,6 +1523,7 @@ static int Quit( vlc_object_t *p_this, char const *psz_cmd,
 static int Intf( vlc_object_t *p_this, char const *psz_cmd,
                  vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
     intf_thread_t *p_newintf = NULL;
 
     p_newintf = intf_Create( p_this->p_libvlc, newval.psz_string, 0, NULL );
@@ -1533,6 +1542,7 @@ static int Intf( vlc_object_t *p_this, char const *psz_cmd,
 static int Volume( vlc_object_t *p_this, char const *psz_cmd,
                    vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
     intf_thread_t *p_intf = (intf_thread_t*)p_this;
     input_thread_t *p_input = NULL;
     int i_error = VLC_EGENERIC;
@@ -1600,6 +1610,7 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd,
 static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd,
                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(oldval); VLC_UNUSED(p_data);
     intf_thread_t *p_intf = (intf_thread_t*)p_this;
     audio_volume_t i_volume;
     input_thread_t *p_input = NULL;
@@ -1651,6 +1662,7 @@ static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd,
 static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
                         vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(oldval); VLC_UNUSED(p_data);
     intf_thread_t *p_intf = (intf_thread_t*)p_this;
     input_thread_t *p_input = NULL;
     vout_thread_t * p_vout;
@@ -1766,7 +1778,7 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
                     &val, &text );
         msg_rc( "+----[ end of %s ]", val_name.psz_string );
 
-        if( val_name.psz_string ) free( val_name.psz_string );
+        free( val_name.psz_string );
 
         i_error = VLC_SUCCESS;
     }
@@ -1777,6 +1789,7 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
 static int AudioConfig( vlc_object_t *p_this, char const *psz_cmd,
                         vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(oldval); VLC_UNUSED(p_data);
     intf_thread_t *p_intf = (intf_thread_t*)p_this;
     input_thread_t *p_input = NULL;
     aout_instance_t * p_aout;
@@ -1852,7 +1865,7 @@ static int AudioConfig( vlc_object_t *p_this, char const *psz_cmd,
                     &val, &text );
         msg_rc( "+----[ end of %s ]", val_name.psz_string );
 
-        if( val_name.psz_string ) free( val_name.psz_string );
+        free( val_name.psz_string );
         i_error = VLC_SUCCESS;
     }
     else
@@ -1871,6 +1884,7 @@ static int AudioConfig( vlc_object_t *p_this, char const *psz_cmd,
 static int Menu( vlc_object_t *p_this, char const *psz_cmd,
     vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
     intf_thread_t *p_intf = (intf_thread_t*)p_this;
     playlist_t    *p_playlist = NULL;
     vlc_value_t val;
@@ -1919,18 +1933,19 @@ static int Menu( vlc_object_t *p_this, char const *psz_cmd,
     {
         msg_rc( _("Please provide one of the following parameters:") );
         msg_rc( "[on|off|up|down|left|right|select]" );
-        if( val.psz_string ) free( val.psz_string );
-            return i_error;
+        free( val.psz_string );
+        return i_error;
     }
 
     i_error = VLC_SUCCESS;
-    if( val.psz_string ) free( val.psz_string );
+    free( val.psz_string );
     return i_error;
 }
 
 static int Statistics ( vlc_object_t *p_this, char const *psz_cmd,
     vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(oldval); VLC_UNUSED(newval); VLC_UNUSED(p_data);
     intf_thread_t *p_intf = (intf_thread_t*)p_this;
     input_thread_t *p_input = NULL;
     int i_error;
@@ -1941,11 +1956,9 @@ static int Statistics ( vlc_object_t *p_this, char const *psz_cmd,
 
     if( !strcmp( psz_cmd, "stats" ) )
     {
-        p_intf->p_sys->b_statistics = !p_intf->p_sys->b_statistics;
-        if( p_intf->p_sys->b_statistics )
-            msg_rc(_("statistics update on"));
-        else
-            msg_rc(_("statistics update off"));
+        vlc_mutex_lock( &input_GetItem(p_input)->lock );
+        updateStatistics( p_intf, input_GetItem(p_input) );
+        vlc_mutex_unlock( &input_GetItem(p_input)->lock );
     }
     /*
      * sanity check
@@ -2207,7 +2220,7 @@ static input_item_t *parse_MRL( intf_thread_t *p_intf, char *psz_mrl )
 /*****************************************************************************
  * checkUpdates : check for updates
  ****************************************************************************/
-#ifdef UPDATE_CHECK
+#if 0 && defined( UPDATE_CHECK )
 static void checkUpdates( intf_thread_t *p_intf )
 {
     /*TODO: - modify this to delete p_update to avoid a memory leak !