[vlc-commits] input/control: input_vaControl: clean-up

Filip Roséen git at videolan.org
Thu May 18 18:21:01 CEST 2017


vlc | branch: master | Filip Roséen <filip at atch.se> | Thu May 18 12:29:45 2017 +0200| [8b4015ff32bcaeb1a4e009a59b560dd4fdcbd247] | committer: Rémi Denis-Courmont

input/control: input_vaControl: clean-up

 - remove redundant casts
 - remove unnecessary whitespace
 - fix indentation
 - merge declaration + initialization

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8b4015ff32bcaeb1a4e009a59b560dd4fdcbd247
---

 src/input/control.c | 100 ++++++++++++++++++++++++----------------------------
 1 file changed, 47 insertions(+), 53 deletions(-)

diff --git a/src/input/control.c b/src/input/control.c
index 96b0be50e3..51010fec77 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -63,7 +63,7 @@ int input_Control( input_thread_t *p_input, int i_query, ...  )
 
 int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
 {
-    input_thread_private_t *priv =input_priv(p_input);
+    input_thread_private_t *priv = input_priv(p_input);
     seekpoint_t *p_bkmk, ***ppp_bkmk;
     int i_bkmk = 0;
     int *pi_bkmk;
@@ -79,63 +79,63 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
     switch( i_query )
     {
         case INPUT_GET_POSITION:
-            pf = (double*)va_arg( args, double * );
+            pf = va_arg( args, double * );
             *pf = var_GetFloat( p_input, "position" );
             return VLC_SUCCESS;
 
         case INPUT_SET_POSITION:
-            f = (double)va_arg( args, double );
+            f = va_arg( args, double );
             return var_SetFloat( p_input, "position", f );
 
         case INPUT_GET_LENGTH:
-            pi_64 = (int64_t*)va_arg( args, int64_t * );
+            pi_64 = va_arg( args, int64_t * );
             *pi_64 = var_GetInteger( p_input, "length" );
             return VLC_SUCCESS;
 
         case INPUT_GET_TIME:
-            pi_64 = (int64_t*)va_arg( args, int64_t * );
+            pi_64 = va_arg( args, int64_t * );
             *pi_64 = var_GetInteger( p_input, "time" );
             return VLC_SUCCESS;
 
         case INPUT_SET_TIME:
-            i_64 = (int64_t)va_arg( args, int64_t );
+            i_64 = va_arg( args, int64_t );
             return var_SetInteger( p_input, "time", i_64 );
 
         case INPUT_GET_RATE:
-            pi_int = (int*)va_arg( args, int * );
+            pi_int = va_arg( args, int * );
             *pi_int = INPUT_RATE_DEFAULT / var_GetFloat( p_input, "rate" );
             return VLC_SUCCESS;
 
         case INPUT_SET_RATE:
-            i_int = (int)va_arg( args, int );
+            i_int = va_arg( args, int );
             return var_SetFloat( p_input, "rate",
                                  (float)INPUT_RATE_DEFAULT / (float)i_int );
 
         case INPUT_GET_STATE:
-            pi_int = (int*)va_arg( args, int * );
+            pi_int = va_arg( args, int * );
             *pi_int = var_GetInteger( p_input, "state" );
             return VLC_SUCCESS;
 
         case INPUT_SET_STATE:
-            i_int = (int)va_arg( args, int );
+            i_int = va_arg( args, int );
             return var_SetInteger( p_input, "state", i_int );
 
         case INPUT_GET_AUDIO_DELAY:
-            pi_64 = (int64_t*)va_arg( args, int64_t * );
+            pi_64 = va_arg( args, int64_t * );
             *pi_64 = var_GetInteger( p_input, "audio-delay" );
             return VLC_SUCCESS;
 
         case INPUT_GET_SPU_DELAY:
-            pi_64 = (int64_t*)va_arg( args, int64_t * );
+            pi_64 = va_arg( args, int64_t * );
             *pi_64 = var_GetInteger( p_input, "spu-delay" );
             return VLC_SUCCESS;
 
         case INPUT_SET_AUDIO_DELAY:
-            i_64 = (int64_t)va_arg( args, int64_t );
+            i_64 = va_arg( args, int64_t );
             return var_SetInteger( p_input, "audio-delay", i_64 );
 
         case INPUT_SET_SPU_DELAY:
-            i_64 = (int64_t)va_arg( args, int64_t );
+            i_64 = va_arg( args, int64_t );
             return var_SetInteger( p_input, "spu-delay", i_64 );
 
         case INPUT_NAV_ACTIVATE:
@@ -151,9 +151,9 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
 
         case INPUT_ADD_INFO:
         {
-            char *psz_cat = (char *)va_arg( args, char * );
-            char *psz_name = (char *)va_arg( args, char * );
-            char *psz_format = (char *)va_arg( args, char * );
+            char *psz_cat = va_arg( args, char * );
+            char *psz_name = va_arg( args, char * );
+            char *psz_format = va_arg( args, char * );
 
             char *psz_value;
 
@@ -184,8 +184,8 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
         }
         case INPUT_DEL_INFO:
         {
-            char *psz_cat = (char *)va_arg( args, char * );
-            char *psz_name = (char *)va_arg( args, char * );
+            char *psz_cat = va_arg( args, char * );
+            char *psz_name = va_arg( args, char * );
 
             int i_ret = input_item_DelInfo( priv->p_item, psz_cat, psz_name );
 
@@ -193,7 +193,6 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
                 input_SendEventMetaInfo( p_input );
             return i_ret;
         }
-
         case INPUT_ADD_BOOKMARK:
             p_bkmk = va_arg( args, seekpoint_t * );
             p_bkmk = vlc_seekpoint_Duplicate( p_bkmk );
@@ -241,7 +240,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             return VLC_SUCCESS;
 
         case INPUT_DEL_BOOKMARK:
-            i_bkmk = (int)va_arg( args, int );
+            i_bkmk = va_arg( args, int );
 
             vlc_mutex_lock( &priv->p_item->lock );
             if( i_bkmk < priv->i_bookmark )
@@ -261,8 +260,8 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             return VLC_EGENERIC;
 
         case INPUT_GET_BOOKMARKS:
-            ppp_bkmk = (seekpoint_t ***)va_arg( args, seekpoint_t *** );
-            pi_bkmk = (int *)va_arg( args, int * );
+            ppp_bkmk = va_arg( args, seekpoint_t *** );
+            pi_bkmk = va_arg( args, int * );
 
             vlc_mutex_lock( &priv->p_item->lock );
             if( priv->i_bookmark )
@@ -302,7 +301,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             return VLC_SUCCESS;
 
         case INPUT_SET_BOOKMARK:
-            i_bkmk = (int)va_arg( args, int );
+            i_bkmk = va_arg( args, int );
 
             val.i_int = i_bkmk;
             input_ControlPush( p_input, INPUT_CONTROL_SET_BOOKMARK, &val );
@@ -310,7 +309,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             return VLC_SUCCESS;
 
         case INPUT_GET_BOOKMARK:
-            p_bkmk = (seekpoint_t *)va_arg( args, seekpoint_t * );
+            p_bkmk = va_arg( args, seekpoint_t * );
 
             vlc_mutex_lock( &priv->p_item->lock );
             *p_bkmk = priv->bookmark;
@@ -319,8 +318,8 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
 
         case INPUT_GET_TITLE_INFO:
         {
-            input_title_t **p_title = (input_title_t **)va_arg( args, input_title_t ** );
-            int *pi_req_title_offset = (int *) va_arg( args, int * );
+            input_title_t **p_title = va_arg( args, input_title_t ** );
+            int *pi_req_title_offset = va_arg( args, int * );
 
             vlc_mutex_lock( &priv->p_item->lock );
 
@@ -343,12 +342,9 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
 
         case INPUT_GET_FULL_TITLE_INFO:
         {
-            input_title_t **array;
-            unsigned count;
-
             vlc_mutex_lock( &priv->p_item->lock );
-            count = priv->i_title;
-            array = malloc( count * sizeof (*array) );
+            unsigned count = priv->i_title;
+            input_title_t **array = malloc( count * sizeof (*array) );
 
             if( count > 0 && unlikely(array == NULL) )
             {
@@ -413,8 +409,8 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
         case INPUT_ADD_SLAVE:
         {
             enum slave_type type =  (enum slave_type) va_arg( args, enum slave_type );
-            psz = (char*)va_arg( args, char * );
-            b_bool = (bool)va_arg( args, int );
+            psz = va_arg( args, char * );
+            b_bool = va_arg( args, int );
 
             if( !psz || ( type != SLAVE_TYPE_SPU && type != SLAVE_TYPE_AUDIO ) )
                 return VLC_EGENERIC;
@@ -431,8 +427,8 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
         }
 
         case INPUT_ADD_SUBTITLE:
-            psz = (char*)va_arg( args, char * );
-            b_bool = (bool)va_arg( args, int );
+            psz = va_arg( args, char * );
+            b_bool = va_arg( args, int );
 
             if( !psz || *psz == '\0' )
                 return VLC_EGENERIC;
@@ -445,9 +441,8 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
 
         case INPUT_GET_ATTACHMENTS: /* arg1=input_attachment_t***, arg2=int*  res=can fail */
         {
-            input_attachment_t ***ppp_attachment = (input_attachment_t***)va_arg( args, input_attachment_t *** );
-            int *pi_attachment = (int*)va_arg( args, int * );
-            int i;
+            input_attachment_t ***ppp_attachment = va_arg( args, input_attachment_t *** );
+            int *pi_attachment = va_arg( args, int * );
 
             vlc_mutex_lock( &priv->p_item->lock );
             if( priv->i_attachment <= 0 )
@@ -459,7 +454,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             }
             *pi_attachment = priv->i_attachment;
             *ppp_attachment = malloc( sizeof(input_attachment_t*) * priv->i_attachment );
-            for( i = 0; i < priv->i_attachment; i++ )
+            for( int i = 0; i < priv->i_attachment; i++ )
                 (*ppp_attachment)[i] = vlc_input_attachment_Duplicate( priv->attachment[i] );
 
             vlc_mutex_unlock( &priv->p_item->lock );
@@ -468,12 +463,11 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
 
         case INPUT_GET_ATTACHMENT:  /* arg1=input_attachment_t**, arg2=char*  res=can fail */
         {
-            input_attachment_t **pp_attachment = (input_attachment_t**)va_arg( args, input_attachment_t ** );
-            const char *psz_name = (const char*)va_arg( args, const char * );
-            int i;
+            input_attachment_t **pp_attachment = va_arg( args, input_attachment_t ** );
+            const char *psz_name = va_arg( args, const char * );
 
             vlc_mutex_lock( &priv->p_item->lock );
-            for( i = 0; i < priv->i_attachment; i++ )
+            for( int i = 0; i < priv->i_attachment; i++ )
             {
                 if( !strcmp( priv->attachment[i]->psz_name, psz_name ) )
                 {
@@ -488,17 +482,17 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
         }
 
         case INPUT_SET_RECORD_STATE:
-            b_bool = (bool)va_arg( args, int );
+            b_bool = va_arg( args, int );
             var_SetBool( p_input, "record", b_bool );
             return VLC_SUCCESS;
 
         case INPUT_GET_RECORD_STATE:
-            pb_bool = (bool*)va_arg( args, bool* );
+            pb_bool = va_arg( args, bool* );
             *pb_bool = var_GetBool( p_input, "record" );
             return VLC_SUCCESS;
 
         case INPUT_RESTART_ES:
-            val.i_int = (int)va_arg( args, int );
+            val.i_int = va_arg( args, int );
             input_ControlPush( p_input, INPUT_CONTROL_RESTART_ES, &val );
             return VLC_SUCCESS;
 
@@ -522,15 +516,15 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             if( !p_aout )
                 return VLC_EGENERIC;
 
-            audio_output_t **pp_aout = (audio_output_t**)va_arg( args, audio_output_t** );
+            audio_output_t **pp_aout = va_arg( args, audio_output_t** );
             *pp_aout = p_aout;
             return VLC_SUCCESS;
         }
 
         case INPUT_GET_VOUTS:
         {
-            vout_thread_t ***ppp_vout = (vout_thread_t***)va_arg( args, vout_thread_t*** );
-            size_t        *pi_vout = va_arg( args, size_t * );
+            vout_thread_t ***ppp_vout = va_arg( args, vout_thread_t*** );
+            size_t *pi_vout = va_arg( args, size_t * );
 
             input_resource_HoldVouts( priv->p_resource, ppp_vout, pi_vout );
             if( *pi_vout <= 0 )
@@ -541,9 +535,9 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
         case INPUT_GET_ES_OBJECTS:
         {
             const int i_id = va_arg( args, int );
-            vlc_object_t    **pp_decoder = va_arg( args, vlc_object_t ** );
-            vout_thread_t   **pp_vout    = va_arg( args, vout_thread_t ** );
-            audio_output_t **pp_aout    = va_arg( args, audio_output_t ** );
+            vlc_object_t **pp_decoder = va_arg( args, vlc_object_t ** );
+            vout_thread_t **pp_vout = va_arg( args, vout_thread_t ** );
+            audio_output_t **pp_aout = va_arg( args, audio_output_t ** );
 
             return es_out_Control( priv->p_es_out_display,
                                    ES_OUT_GET_ES_OBJECTS_BY_ID, i_id,



More information about the vlc-commits mailing list