1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-01 00:07:33 +00:00

loadfile: fix forced subtitles not respecting slang

fbe8f99194 made it possible for mpv to
autoselect forced subtitles again (it was bugged and would ignore
without slang being specified). Unfortunately, I forgot to take slang
into account here, so it would always autoselect the subtitles if they
are available. Fix this by checking both that it matches the lang and
that the previous track pick wasn't already matched (os_langs being true
is essentially equivalent to there not being any specified slang). This
way, it still respects the order of languages in your slang list.
Probably someone out there will be upset that forced subtitles aren't
always preferred regardless of the order, but that can be another option
for later I guess.
This commit is contained in:
Dudemanguy 2023-09-01 11:21:37 -05:00
parent c9c917c5c3
commit eca51d8e45

View File

@ -645,12 +645,17 @@ struct track *select_default_track(struct MPContext *mpctx, int order,
if (!pick || compare_track(track, pick, langs, os_langs, mpctx->opts, preferred_program))
pick = track;
// We only try to autoselect forced tracks if they match the audio language and are subs or
// if the user always wants forced sub tracks
// Autoselecting forced sub tracks requires the following:
// 1. Matches the audio language or --subs-fallback-forced=always.
// 2. Matches the users list of preferred languages or none were specified (i.e. slang was not set).
// 3. A track *wasn't* already selected by slang previously.
if (fallback_forced && track->forced_track &&
(os_langs || (match_lang(langs, track->lang) && !match_lang(langs, pick->lang))) &&
(mp_match_lang_single(audio_lang, track->lang) || opts->subs_fallback_forced == 2) &&
(!forced_pick || compare_track(track, forced_pick, langs, os_langs, mpctx->opts, preferred_program)))
{
forced_pick = track;
}
}
// If we found a forced track, use that.