aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max.kellermann@gmail.com>2018-06-13 11:34:00 +0200
committerMax Kellermann <max.kellermann@gmail.com>2018-06-13 12:13:09 +0200
commit2771e3a893ad61a12201428c1f3f949888d4789a (patch)
treebd8f6ece6b1b7328985b3e7f5e66787e4bec1081
parent406e1d72d2b51b01e0c5f2b5e10671b81b274ba8 (diff)
utils/StreamDetails: make IsWorseThan() const and pass a const reference
-rw-r--r--xbmc/utils/StreamDetails.cpp30
-rw-r--r--xbmc/utils/StreamDetails.h8
2 files changed, 19 insertions, 19 deletions
diff --git a/xbmc/utils/StreamDetails.cpp b/xbmc/utils/StreamDetails.cpp
index 78c9473f86..98532e2bf2 100644
--- a/xbmc/utils/StreamDetails.cpp
+++ b/xbmc/utils/StreamDetails.cpp
@@ -80,14 +80,14 @@ void CStreamDetailVideo::Serialize(CVariant& value) const
value["language"] = m_strLanguage;
}
-bool CStreamDetailVideo::IsWorseThan(CStreamDetail *that)
+bool CStreamDetailVideo::IsWorseThan(const CStreamDetail &that) const
{
- if (that->m_eType != CStreamDetail::VIDEO)
+ if (that.m_eType != CStreamDetail::VIDEO)
return true;
// Best video stream is that with the most pixels
- CStreamDetailVideo *sdv = static_cast<CStreamDetailVideo*>(that);
- return (sdv->m_iWidth * sdv->m_iHeight) > (m_iWidth * m_iHeight);
+ auto &sdv = static_cast<const CStreamDetailVideo &>(that);
+ return (sdv.m_iWidth * sdv.m_iHeight) > (m_iWidth * m_iHeight);
}
CStreamDetailAudio::CStreamDetailAudio() :
@@ -125,20 +125,20 @@ void CStreamDetailAudio::Serialize(CVariant& value) const
value["channels"] = m_iChannels;
}
-bool CStreamDetailAudio::IsWorseThan(CStreamDetail *that)
+bool CStreamDetailAudio::IsWorseThan(const CStreamDetail &that) const
{
- if (that->m_eType != CStreamDetail::AUDIO)
+ if (that.m_eType != CStreamDetail::AUDIO)
return true;
- CStreamDetailAudio *sda = static_cast<CStreamDetailAudio*>(that);
+ auto &sda = static_cast<const CStreamDetailAudio &>(that);
// First choice is the thing with the most channels
- if (sda->m_iChannels > m_iChannels)
+ if (sda.m_iChannels > m_iChannels)
return true;
- if (m_iChannels > sda->m_iChannels)
+ if (m_iChannels > sda.m_iChannels)
return false;
// In case of a tie, revert to codec priority
- return StreamUtils::GetCodecPriority(sda->m_strCodec) > StreamUtils::GetCodecPriority(m_strCodec);
+ return StreamUtils::GetCodecPriority(sda.m_strCodec) > StreamUtils::GetCodecPriority(m_strCodec);
}
CStreamDetailSubtitle::CStreamDetailSubtitle() :
@@ -168,18 +168,18 @@ void CStreamDetailSubtitle::Serialize(CVariant& value) const
value["language"] = m_strLanguage;
}
-bool CStreamDetailSubtitle::IsWorseThan(CStreamDetail *that)
+bool CStreamDetailSubtitle::IsWorseThan(const CStreamDetail &that) const
{
- if (that->m_eType != CStreamDetail::SUBTITLE)
+ if (that.m_eType != CStreamDetail::SUBTITLE)
return true;
- if (g_LangCodeExpander.CompareISO639Codes(m_strLanguage, static_cast<CStreamDetailSubtitle*>(that)->m_strLanguage))
+ if (g_LangCodeExpander.CompareISO639Codes(m_strLanguage, static_cast<const CStreamDetailSubtitle &>(that).m_strLanguage))
return false;
// the best subtitle should be the one in the user's preferred language
// If preferred language is set to "original" this is "eng"
return m_strLanguage.empty() ||
- g_LangCodeExpander.CompareISO639Codes(static_cast<CStreamDetailSubtitle*>(that)->m_strLanguage, g_langInfo.GetSubtitleLanguage());
+ g_LangCodeExpander.CompareISO639Codes(static_cast<const CStreamDetailSubtitle &>(that).m_strLanguage, g_langInfo.GetSubtitleLanguage());
}
CStreamDetailSubtitle& CStreamDetailSubtitle::operator=(const CStreamDetailSubtitle &that)
@@ -566,7 +566,7 @@ void CStreamDetails::DetermineBestStreams(void)
if (!champion)
continue;
- if ((*champion == NULL) || (*champion)->IsWorseThan(*iter))
+ if ((*champion == NULL) || (*champion)->IsWorseThan(**iter))
*champion = *iter;
} /* for each */
}
diff --git a/xbmc/utils/StreamDetails.h b/xbmc/utils/StreamDetails.h
index 2431434525..0fe1c1f39f 100644
--- a/xbmc/utils/StreamDetails.h
+++ b/xbmc/utils/StreamDetails.h
@@ -41,7 +41,7 @@ public:
};
explicit CStreamDetail(StreamType type) : m_eType(type), m_pParent(NULL) {};
- virtual bool IsWorseThan(CStreamDetail *that) = 0;
+ virtual bool IsWorseThan(const CStreamDetail &that) const = 0;
const StreamType m_eType;
@@ -57,7 +57,7 @@ public:
CStreamDetailVideo(const VideoStreamInfo &info, int duration = 0);
void Archive(CArchive& ar) override;
void Serialize(CVariant& value) const override;
- bool IsWorseThan(CStreamDetail *that) override;
+ bool IsWorseThan(const CStreamDetail &that) const override;
int m_iWidth;
int m_iHeight;
@@ -75,7 +75,7 @@ public:
CStreamDetailAudio(const AudioStreamInfo &info);
void Archive(CArchive& ar) override;
void Serialize(CVariant& value) const override;
- bool IsWorseThan(CStreamDetail *that) override;
+ bool IsWorseThan(const CStreamDetail &that) const override;
int m_iChannels;
std::string m_strCodec;
@@ -90,7 +90,7 @@ public:
CStreamDetailSubtitle& operator=(const CStreamDetailSubtitle &that);
void Archive(CArchive& ar) override;
void Serialize(CVariant& value) const override;
- bool IsWorseThan(CStreamDetail *that) override;
+ bool IsWorseThan(const CStreamDetail &that) const override;
std::string m_strLanguage;
};