Repository: xbmc/xbmc
File: xbmc/cores/VideoPlayer/VideoPlayer.cpp (C++)

Code before:
 *        The priority sequence is exactly as shown by the code sequence of the operator() method.
 *
 *        NOTE: Dont exists a "default" setting for subtitles, as there is for audio (media default),
 *              so the default flag will give a priority over another only when two streams
 *              have same properties (e.g. same language with a same flag, but a different codec, author, etc...).
 */
class PredicateSubtitlePriority
{
private:
  std::string m_playedAudioLang;
  std::string m_subLang;
  bool m_isPrefOriginal;
  bool m_isPrefForced;
  bool m_isPrefHearingImp;
  PredicateSubtitleFilter m_filter;
  int m_subStream;

public:
  explicit PredicateSubtitlePriority(const std::string& lang, int stream)
    : m_playedAudioLang(lang), m_filter(lang, stream), m_subStream(stream)
  {
    auto settings = CServiceBroker::GetSettingsComponent()->GetSettings();
    const std::string subLangSetting =
        settings->GetString(CSettings::SETTING_LOCALE_SUBTITLELANGUAGE);

    const bool isSubNone = StringUtils::EqualsNoCase(subLangSetting, "none");
    m_isPrefOriginal = StringUtils::EqualsNoCase(subLangSetting, "original");
    m_isPrefForced = StringUtils::EqualsNoCase(subLangSetting, "forced_only");
    m_isPrefHearingImp = settings->GetBool(CSettings::SETTING_ACCESSIBILITY_SUBHEARING);

    m_subLang = g_langInfo.GetSubtitleLanguage(false);
    if (m_subLang.empty()) // No language set (due to none, original, forced_only settings)
    {
      m_subLang = g_langInfo.GetAudioLanguage(false);
      if (m_subLang.empty()) // No language set (due to default, original, mediadefault settings)
        m_subLang = m_playedAudioLang;
    }

    // Dont allow "forced" setting to be combined with "impaired" setting
    if (m_isPrefHearingImp && m_isPrefForced)
      m_isPrefForced = false;
  };

  // \brief Check if a stream can match the user settings
  bool relevant(const SelectionStream& ss) const { return !m_filter(ss); }

  bool operator()(const SelectionStream& lh, const SelectionStream& rh) const
  {
    PREDICATE_RETURN(lh.type_index == m_subStream, rh.type_index == m_subStream);

    const bool isLexternal = STREAM_SOURCE_MASK(lh.source) == STREAM_SOURCE_DEMUX_SUB ||

Review comment (suggestion):
Unused variable:

```
/home/jenkins/jenkins-root/workspace/android-arm64-docker@4/xbmc/cores/VideoPlayer/VideoPlayer.cpp:285:16: warning: unused variable 'isSubNone' [-Wunused-variable]
  285 |     const bool isSubNone = StringUtils::EqualsNoCase(subLangSetting, "none");
      |                ^~~~~~~~~
1 warning generated.
```

Code after:
 *        The priority sequence is exactly as shown by the code sequence of the operator() method.
 *
 *        NOTE: Dont exists a "default" setting for subtitles, as there is for audio (media default),
 *              so the default flag will give a priority over another only when two streams
 *              have same properties (e.g. same language with a same flag, but a different codec, author, etc...).
 */
class PredicateSubtitlePriority
{
private:
  std::string m_playedAudioLang;
  std::string m_subLang;
  bool m_isPrefOriginal;
  bool m_isPrefForced;
  bool m_isPrefHearingImp;
  PredicateSubtitleFilter m_filter;
  int m_subStream;

public:
  explicit PredicateSubtitlePriority(const std::string& lang, int stream)
    : m_playedAudioLang(lang), m_filter(lang, stream), m_subStream(stream)
  {
    auto settings = CServiceBroker::GetSettingsComponent()->GetSettings();
    const std::string subLangSetting =
        settings->GetString(CSettings::SETTING_LOCALE_SUBTITLELANGUAGE);

    m_isPrefOriginal = StringUtils::EqualsNoCase(subLangSetting, "original");
    m_isPrefForced = StringUtils::EqualsNoCase(subLangSetting, "forced_only");
    m_isPrefHearingImp = settings->GetBool(CSettings::SETTING_ACCESSIBILITY_SUBHEARING);

    m_subLang = g_langInfo.GetSubtitleLanguage(false);
    if (m_subLang.empty()) // No language set (due to none, original, forced_only settings)
    {
      m_subLang = g_langInfo.GetAudioLanguage(false);
      if (m_subLang.empty()) // No language set (due to default, original, mediadefault settings)
        m_subLang = m_playedAudioLang;
    }

    // Dont allow "forced" setting to be combined with "impaired" setting
    if (m_isPrefHearingImp && m_isPrefForced)
      m_isPrefForced = false;
  };

  // \brief Check if a stream can match the user settings
  bool relevant(const SelectionStream& ss) const { return !m_filter(ss); }

  bool operator()(const SelectionStream& lh, const SelectionStream& rh) const
  {
    PREDICATE_RETURN(lh.type_index == m_subStream, rh.type_index == m_subStream);

    const bool isLexternal = STREAM_SOURCE_MASK(lh.source) == STREAM_SOURCE_DEMUX_SUB ||
                             STREAM_SOURCE_MASK(lh.source) == STREAM_SOURCE_TEXT;