[vlc-devel] [PATCH] [PATCH] Shortcut for multiple video tracks.

Filip Roséen filip at atch.se
Mon Feb 27 06:49:12 CET 2017


Hi Andrei,

Please see the [comment expressed by *Jean-Baptiste Kempf*][1],
and keep in mind that I expressed the exact same thing earlier.

[1]: https://mailman.videolan.org/pipermail/vlc-devel/2017-February/111777.html

In either case, you are still suffering from code-duplication - I
would advise you to introduce variables holding the information that
differs between the two implementations; there is no need to have the
same function called in two places, only with statically different
arguments.

In other words, in order to avoid code-duplication one can simply
replace usage of `"audio-es"` and `"video-es"` with a variable that is
conditionally initialized to refer to one of the strings (and the same
goes for other entities).

Best Regards,\
Filip

On 2017-02-27 04:06, Andrei Ciurea wrote:

> ---
>  modules/control/hotkeys.c | 60 ++++++++++++++++-------------------------------
>  1 file changed, 20 insertions(+), 40 deletions(-)
> 
> diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
> index 2c25d0c..d1b5727 100644
> --- a/modules/control/hotkeys.c
> +++ b/modules/control/hotkeys.c
> @@ -700,17 +700,26 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
>              }
>              break;
>          }
> -
> +        case ACTIONID_VIDEO_TRACK:
>          case ACTIONID_AUDIO_TRACK:
> -            if( p_input )
> +          if( p_input )
>              {
>                  vlc_value_t val, list, list2;
>                  int i_count, i;
> +
> +                if(i_action == ACTIONID_VIDEO_TRACK){
> +                var_Get( p_input, "video-es", &val );
> +                var_Change( p_input, "video-es", VLC_VAR_GETCHOICES,
> +                            &list, &list2 );
> +
> +                }
> +                else{
>                  var_Get( p_input, "audio-es", &val );
>                  var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES,
>                              &list, &list2 );
> +            }
>                  i_count = list.p_list->i_count;
> -                if( i_count > 1 )
> +                if( (i_count = list.p_list->i_count) > 1 )
>                  {
>                      for( i = 0; i < i_count; i++ )
>                      {
> @@ -719,7 +728,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
>                              break;
>                          }
>                      }
> -                    /* value of audio-es was not in choices list */
> +                    /* value of audio-es / video-es was not in choices list */
>                      if( i == i_count )
>                      {
>                          msg_Warn( p_input,
> @@ -730,49 +739,20 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
>                          i = 1;
>                      else
>                          i++;
> +                    if(i_action == ACTIONID_VIDEO_TRACK){
> +                         var_Set( p_input, "video-es", list.p_list->p_values[i] );
> +                    DisplayMessage( p_vout, _("Video track: %s"),
> +                                    list2.p_list->p_values[i].psz_string );
> +                    }
> +                    else{
>                      var_Set( p_input, "audio-es", list.p_list->p_values[i] );
>                      DisplayMessage( p_vout, _("Audio track: %s"),
>                                      list2.p_list->p_values[i].psz_string );
>                  }
> -                var_FreeList( &list, &list2 );
> -            }
> -            break;  
> -        case ACTIONID_VIDEO_TRACK:
> -         if( p_input )
> -            {
> -                vlc_value_t val, list, list2;
> -                int i_count, i;
> -                var_Get( p_input, "video-es", &val );
> -                var_Change( p_input, "video-es", VLC_VAR_GETCHOICES,
> -                            &list, &list2 );
> -                
> -                if( (i_count = list.p_list->i_count) > 1 )
> -                {
> -                    for( i = 0; i < i_count; i++ )
> -                    {
> -                        if( val.i_int == list.p_list->p_values[i].i_int )
> -                        {
> -                            break;
> -                        }
> -                    }
> -                    /* value of video-es was not in choices list */
> -                    if( i == i_count )
> -                    {
> -                        msg_Warn( p_input,
> -                                  "invalid current video track, selecting 0" );
> -                        i = 0;
> -                    }
> -                    else if( i == i_count - 1 )
> -                        i = 1;
> -                    else
> -                        i++;
> -                    var_Set( p_input, "video-es", list.p_list->p_values[i] );
> -                    DisplayMessage( p_vout, _("Video track: %s"),
> -                                    list2.p_list->p_values[i].psz_string );
>                  }
>                  var_FreeList( &list, &list2 );
>              }
> -            break;
> +            break;  
>          case ACTIONID_SUBTITLE_TRACK:
>              if( p_input )
>              {
> -- 
> 2.10.2
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170227/7c014638/attachment.html>


More information about the vlc-devel mailing list