[vlc-devel] [PATCH] Fix track selection according to user preference.

Rafaël Carré funman at videolan.org
Fri Jul 12 09:52:00 CEST 2013


Hello,

Le 12/07/2013 02:29, Denis Charmet a écrit :
> Fix #6375 and may benefit to #8936
> ---
>  src/input/es_out.c |   58 ++++++++++++++++++++++++++++++++++++----------------
>  1 file changed, 40 insertions(+), 18 deletions(-)
> 
> diff --git a/src/input/es_out.c b/src/input/es_out.c
> index c566287..01bbbc5 100644
> --- a/src/input/es_out.c
> +++ b/src/input/es_out.c
> @@ -1759,27 +1759,32 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force )
>              int idx1 = LanguageArrayIndex( p_sys->ppsz_audio_language,
>                                       es->psz_language_code );
>  
> -            if( p_sys->p_es_audio &&
> -                p_sys->p_es_audio->fmt.i_priority >= es->fmt.i_priority )
> +            if( p_sys->p_es_audio )
>              {
>                  int idx2 = LanguageArrayIndex( p_sys->ppsz_audio_language,
>                                           p_sys->p_es_audio->psz_language_code );
>  
> -                if( idx1 < 0 || ( idx2 >= 0 && idx2 <= idx1 ) )
> +                /* Don't update the active track if: */
> +                if( idx1 < 0 || /* this track isn't in the language list */
> +                    ( idx2 >= 0 &&
> +                      ( idx2 < idx1 || /* it's less prioritar from the user

prioritary?
or something like:
"its user priority is lower than the already selected one" ?

> +                                        * perspective than the already selected
> +                                        * one */
> +                        ( idx2 == idx1 &&  /* the user priority is the same but
> +                                            * the track priority is lesser than
> +                                            *  the one already selected */

I think it'd look better this way:

if (idx1 < 0) /* xxx */
    return;
if (idx2 >= 0 && idx2 <= idx1) /* xxx */
    return;
..

> +                          p_sys->p_es_audio->fmt.i_priority >= es->fmt.i_priority ) ) ) )
>                      return;
> +
>                  i_wanted = es->i_channel;
>              }
> -            else
> -            {
> -                /* Select audio if (no audio selected yet)
> -                 * - no audio-language
> -                 * - no audio code for the ES
> -                 * - audio code in the requested list */
> -                if( idx1 >= 0 ||
> -                    !strcmp( es->psz_language_code, "??" ) ||
> -                    !p_sys->ppsz_audio_language )
> -                    i_wanted = es->i_channel;
> -            }
> +            /* Select audio if (no audio selected yet)
> +             * - no audio-language
> +             * - no audio code for the ES
> +             * - audio code in the requested list */
> +            else if( idx1 >= 0 || !strcmp( es->psz_language_code, "??" ) ||
> +                     !p_sys->ppsz_audio_language )
> +                i_wanted = es->i_channel;

Cosmetic change?

>  
>              if( p_sys->i_audio_last >= 0 )
>                  i_wanted = p_sys->i_audio_last;
> @@ -1797,8 +1802,7 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force )
>              int idx1 = LanguageArrayIndex( p_sys->ppsz_sub_language,
>                                       es->psz_language_code );
>  
> -            if( p_sys->p_es_sub &&
> -                p_sys->p_es_sub->fmt.i_priority >= es->fmt.i_priority )
> +            if( p_sys->p_es_sub )
>              {
>                  int idx2 = LanguageArrayIndex( p_sys->ppsz_sub_language,
>                                           p_sys->p_es_sub->psz_language_code );
> @@ -1807,8 +1811,18 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force )
>                          idx1, es->psz_language_code, idx2,
>                          p_sys->p_es_sub->psz_language_code );
>  
> -                if( idx1 < 0 || ( idx2 >= 0 && idx2 <= idx1 ) )
> +                /* Don't update the active track if: */
> +                if( idx1 < 0 || /* this track isn't in the language list */
> +                    ( idx2 >= 0 &&
> +                      ( idx2 < idx1 || /* it's less prioritar from the user
> +                                        * perspective than the already selected
> +                                        * one */
> +                        ( idx2 == idx1 &&  /* the user priority is the same but
> +                                            * the track priority is lesser than
> +                                            *  the one already selected */
> +                          p_sys->p_es_sub->fmt.i_priority >= es->fmt.i_priority ) ) ) )
>                      return;
> +
>                  /* We found a SPU that matches our language request */
>                  i_wanted  = es->i_channel;
>              }
> @@ -2751,7 +2765,15 @@ static char **LanguageSplit( const char *psz_langs, bool b_default_any )
>      char **ppsz = NULL;
>      int i_psz = 0;
>  
> -    if( psz_langs == NULL ) return NULL;
> +    if( psz_langs == NULL || !*psz_langs )
> +    {
> +        if ( b_default_any )
> +        {
> +            TAB_APPEND( i_psz, ppsz, strdup("any") );
> +            TAB_APPEND( i_psz, ppsz, NULL );
> +        }
> +        return ppsz;
> +    }
>  
>      psz_parser = psz_dup = strdup(psz_langs);
>  
> 

Is this change related?



More information about the vlc-devel mailing list