Commit 78e6b2bc authored by Denis Charmet's avatar Denis Charmet

Fix track selection according to user preference.

Fix #6375 and may benefit to #8936
parent 4a0eb67d
...@@ -1756,28 +1756,34 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force ) ...@@ -1756,28 +1756,34 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force )
if( i_cat == AUDIO_ES ) if( i_cat == AUDIO_ES )
{ {
int idx1 = LanguageArrayIndex( p_sys->ppsz_audio_language, if( p_sys->ppsz_audio_language )
{
int es_idx = LanguageArrayIndex( p_sys->ppsz_audio_language,
es->psz_language_code ); es->psz_language_code );
if( !p_sys->p_es_audio )
if( p_sys->p_es_audio && {
p_sys->p_es_audio->fmt.i_priority >= es->fmt.i_priority ) /* Only select the language if it's in the list */
if( es_idx >= 0 )
i_wanted = es->i_channel;
}
else
{ {
int idx2 = LanguageArrayIndex( p_sys->ppsz_audio_language, int selected_es_idx =
LanguageArrayIndex( p_sys->ppsz_audio_language,
p_sys->p_es_audio->psz_language_code ); p_sys->p_es_audio->psz_language_code );
if( es_idx >= 0 &&
if( idx1 < 0 || ( idx2 >= 0 && idx2 <= idx1 ) ) ( es_idx < selected_es_idx ||
return; ( es_idx == selected_es_idx &&
p_sys->p_es_audio->fmt.i_priority < es->fmt.i_priority ) ) )
i_wanted = es->i_channel; i_wanted = es->i_channel;
} }
}
else else
{ {
/* Select audio if (no audio selected yet) /* Select the first one if there is no selected audio yet
* - no audio-language * then choose by ES priority */
* - no audio code for the ES if( !p_sys->p_es_audio ||
* - audio code in the requested list */ p_sys->p_es_audio->fmt.i_priority < es->fmt.i_priority )
if( idx1 >= 0 ||
!strcmp( es->psz_language_code, "??" ) ||
!p_sys->ppsz_audio_language )
i_wanted = es->i_channel; i_wanted = es->i_channel;
} }
...@@ -1794,34 +1800,44 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force ) ...@@ -1794,34 +1800,44 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force )
} }
else if( i_cat == SPU_ES ) else if( i_cat == SPU_ES )
{ {
int idx1 = LanguageArrayIndex( p_sys->ppsz_sub_language, if( 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 )
{ {
int idx2 = LanguageArrayIndex( p_sys->ppsz_sub_language, int es_idx = LanguageArrayIndex( p_sys->ppsz_sub_language,
p_sys->p_es_sub->psz_language_code ); es->psz_language_code );
if( !p_sys->p_es_sub )
msg_Dbg( p_sys->p_input, "idx1=%d(%s) idx2=%d(%s)", {
idx1, es->psz_language_code, idx2, /* Select the language if it's in the list */
p_sys->p_es_sub->psz_language_code ); if( es_idx >= 0 ||
/*FIXME: Should default subtitle not in the list be
if( idx1 < 0 || ( idx2 >= 0 && idx2 <= idx1 ) ) * displayed if not forbidden by none? */
return; ( p_sys->i_default_sub_id >= 0 &&
/* We found a SPU that matches our language request */ /* check if the subtitle isn't forbidden by none */
LanguageArrayIndex( p_sys->ppsz_sub_language, "none" ) < 0 &&
es->i_id == p_sys->i_default_sub_id ) )
i_wanted = es->i_channel; i_wanted = es->i_channel;
} }
else if( idx1 >= 0 ) else
{ {
msg_Dbg( p_sys->p_input, "idx1=%d(%s)", int selected_es_idx =
idx1, es->psz_language_code ); LanguageArrayIndex( p_sys->ppsz_sub_language,
p_sys->p_es_sub->psz_language_code );
if( es_idx >= 0 &&
( es_idx < selected_es_idx ||
( es_idx == selected_es_idx &&
p_sys->p_es_sub->fmt.i_priority < es->fmt.i_priority ) ) )
i_wanted = es->i_channel; i_wanted = es->i_channel;
} }
else if( p_sys->i_default_sub_id >= 0 ) }
else
{ {
if( es->i_id == p_sys->i_default_sub_id ) /* If there is no user preference, select the default subtitle
* or adapt by ES priority */
if( ( !p_sys->p_es_sub &&
( p_sys->i_default_sub_id >= 0 &&
es->i_id == p_sys->i_default_sub_id ) ) ||
( p_sys->p_es_sub &&
p_sys->p_es_sub->fmt.i_priority < es->fmt.i_priority ) )
i_wanted = es->i_channel; i_wanted = es->i_channel;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment