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

Denis Charmet typx at dinauz.org
Fri Jul 12 02:29:20 CEST 2013


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
+                                        * 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_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;
 
             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);
 
-- 
1.7.10.4




More information about the vlc-devel mailing list