diff --git a/xbmc/ApplicationPlayer.cpp b/xbmc/ApplicationPlayer.cpp index 9d9f2a792d3ec..5382dcf2d9cf1 100644 --- a/xbmc/ApplicationPlayer.cpp +++ b/xbmc/ApplicationPlayer.cpp @@ -23,7 +23,13 @@ using namespace std::chrono_literals; -std::shared_ptr CApplicationPlayer::GetInternal() const +std::shared_ptr CApplicationPlayer::GetInternal() const +{ + std::unique_lock lock(m_playerLock); + return m_pPlayer; +} + +std::shared_ptr CApplicationPlayer::GetInternal() { std::unique_lock lock(m_playerLock); return m_pPlayer; @@ -66,9 +72,9 @@ void CApplicationPlayer::CreatePlayer(const CPlayerCoreFactory &factory, const s } } -std::string CApplicationPlayer::GetCurrentPlayer() +std::string CApplicationPlayer::GetCurrentPlayer() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); if (player) { return player->m_name; @@ -162,8 +168,8 @@ void CApplicationPlayer::OpenNext(const CPlayerCoreFactory &factory) bool CApplicationPlayer::HasPlayer() const { - std::shared_ptr player = GetInternal(); - return player != NULL; + std::shared_ptr player = GetInternal(); + return player != nullptr; } int CApplicationPlayer::GetChapter() @@ -203,19 +209,19 @@ int64_t CApplicationPlayer::GetChapterPos(int chapterIdx) bool CApplicationPlayer::HasAudio() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); return (player && player->HasAudio()); } bool CApplicationPlayer::HasVideo() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); return (player && player->HasVideo()); } bool CApplicationPlayer::HasGame() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); return (player && player->HasGame()); } @@ -232,7 +238,7 @@ int CApplicationPlayer::GetPreferredPlaylist() const bool CApplicationPlayer::HasRDS() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); return (player && player->HasRDS()); } @@ -243,7 +249,7 @@ bool CApplicationPlayer::IsPaused() bool CApplicationPlayer::IsPlaying() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); return (player && player->IsPlaying()); } @@ -311,7 +317,7 @@ void CApplicationPlayer::SeekPercentage(float fPercent) bool CApplicationPlayer::IsPassthrough() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); return (player && player->IsPassthrough()); } @@ -350,7 +356,7 @@ void CApplicationPlayer::SeekTimeRelative(int64_t iTime) int64_t CApplicationPlayer::GetTime() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); if (player) return CDataCacheCore::GetInstance().GetPlayTime(); else @@ -359,7 +365,7 @@ int64_t CApplicationPlayer::GetTime() const int64_t CApplicationPlayer::GetMinTime() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); if (player) return CDataCacheCore::GetInstance().GetMinTime(); else @@ -368,7 +374,7 @@ int64_t CApplicationPlayer::GetMinTime() const int64_t CApplicationPlayer::GetMaxTime() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); if (player) return CDataCacheCore::GetInstance().GetMaxTime(); else @@ -377,7 +383,7 @@ int64_t CApplicationPlayer::GetMaxTime() const time_t CApplicationPlayer::GetStartTime() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); if (player) return CDataCacheCore::GetInstance().GetStartTime(); else @@ -386,7 +392,7 @@ time_t CApplicationPlayer::GetStartTime() const int64_t CApplicationPlayer::GetTotalTime() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); if (player) { int64_t total = CDataCacheCore::GetInstance().GetMaxTime() - CDataCacheCore::GetInstance().GetMinTime(); @@ -398,19 +404,19 @@ int64_t CApplicationPlayer::GetTotalTime() const bool CApplicationPlayer::IsCaching() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); return (player && player->IsCaching()); } bool CApplicationPlayer::IsInMenu() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); return (player && player->IsInMenu()); } MenuType CApplicationPlayer::GetSupportedMenuType() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); if (!player) { return MenuType::NONE; @@ -420,7 +426,7 @@ MenuType CApplicationPlayer::GetSupportedMenuType() const int CApplicationPlayer::GetCacheLevel() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); if (player) return player->GetCacheLevel(); else @@ -491,7 +497,7 @@ std::shared_ptr CApplicationPlayer::GetTeletextCache() float CApplicationPlayer::GetPercentage() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); if (player) { float fPercent = CDataCacheCore::GetInstance().GetPlayPercentage(); @@ -503,7 +509,7 @@ float CApplicationPlayer::GetPercentage() const float CApplicationPlayer::GetCachePercentage() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); if (player) return player->GetCachePercentage(); else @@ -787,9 +793,9 @@ void CApplicationPlayer::SetPlaySpeed(float speed) SetSpeed(speed); } -float CApplicationPlayer::GetPlaySpeed() +float CApplicationPlayer::GetPlaySpeed() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); if (player) { return CDataCacheCore::GetInstance().GetSpeed(); @@ -798,9 +804,9 @@ float CApplicationPlayer::GetPlaySpeed() return 0; } -float CApplicationPlayer::GetPlayTempo() +float CApplicationPlayer::GetPlayTempo() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); if (player) { return CDataCacheCore::GetInstance().GetTempo(); @@ -983,9 +989,9 @@ bool CApplicationPlayer::IsRemotePlaying() return false; } -CVideoSettings CApplicationPlayer::GetVideoSettings() +CVideoSettings CApplicationPlayer::GetVideoSettings() const { - std::shared_ptr player = GetInternal(); + std::shared_ptr player = GetInternal(); if (player) { return player->GetVideoSettings(); diff --git a/xbmc/ApplicationPlayer.h b/xbmc/ApplicationPlayer.h index d866d19f20bdd..fda6b62a62693 100644 --- a/xbmc/ApplicationPlayer.h +++ b/xbmc/ApplicationPlayer.h @@ -37,9 +37,9 @@ class CApplicationPlayer // player management void ClosePlayer(); void ResetPlayer(); - std::string GetCurrentPlayer(); - float GetPlaySpeed(); - float GetPlayTempo(); + std::string GetCurrentPlayer() const; + float GetPlaySpeed() const; + float GetPlayTempo() const; bool HasPlayer() const; bool OpenFile(const CFileItem& item, const CPlayerOptions& options, const CPlayerCoreFactory &factory, @@ -160,7 +160,7 @@ class CApplicationPlayer void SetSpeed(float speed); bool SupportsTempo(); - CVideoSettings GetVideoSettings(); + CVideoSettings GetVideoSettings() const; void SetVideoSettings(CVideoSettings& settings); CSeekHandler& GetSeekHandler(); @@ -173,7 +173,8 @@ class CApplicationPlayer bool HasGameAgent(); private: - std::shared_ptr GetInternal() const; + std::shared_ptr GetInternal() const; + std::shared_ptr GetInternal(); void CreatePlayer(const CPlayerCoreFactory &factory, const std::string &player, IPlayerCallback& callback); void CloseFile(bool reopen = false); diff --git a/xbmc/cores/IPlayer.h b/xbmc/cores/IPlayer.h index 8e6da9c5c5845..eeb03903e6810 100644 --- a/xbmc/cores/IPlayer.h +++ b/xbmc/cores/IPlayer.h @@ -106,7 +106,7 @@ class IPlayer virtual void Seek(bool bPlus = true, bool bLargeStep = false, bool bChapterOverride = false) = 0; virtual bool SeekScene(bool bPlus = true) {return false;} virtual void SeekPercentage(float fPercent = 0){} - virtual float GetCachePercentage(){ return 0;} + virtual float GetCachePercentage() const { return 0; } virtual void SetMute(bool bOnOff){} virtual void SetVolume(float volume){} virtual void SetDynamicRangeCompression(long drc){} @@ -253,7 +253,7 @@ class IPlayer } // video and audio settings - virtual CVideoSettings GetVideoSettings() { return CVideoSettings(); } + virtual CVideoSettings GetVideoSettings() const { return CVideoSettings(); } virtual void SetVideoSettings(CVideoSettings& settings) {} /*! diff --git a/xbmc/cores/RetroPlayer/RetroPlayer.cpp b/xbmc/cores/RetroPlayer/RetroPlayer.cpp index 7b7b2608922a1..c2df077b3c08c 100644 --- a/xbmc/cores/RetroPlayer/RetroPlayer.cpp +++ b/xbmc/cores/RetroPlayer/RetroPlayer.cpp @@ -331,7 +331,7 @@ void CRetroPlayer::SeekPercentage(float fPercent /* = 0 */) SeekTime(static_cast(totalTime * fPercent / 100.0f)); } -float CRetroPlayer::GetCachePercentage() +float CRetroPlayer::GetCachePercentage() const { const float cacheMs = static_cast(m_playback->GetCacheTimeMs()); const float totalMs = static_cast(m_playback->GetTotalTimeMs()); diff --git a/xbmc/cores/RetroPlayer/RetroPlayer.h b/xbmc/cores/RetroPlayer/RetroPlayer.h index 7c2581754b033..4e6dbb7282831 100644 --- a/xbmc/cores/RetroPlayer/RetroPlayer.h +++ b/xbmc/cores/RetroPlayer/RetroPlayer.h @@ -56,7 +56,7 @@ class CRetroPlayer : public IPlayer, bool CanSeek() override; void Seek(bool bPlus = true, bool bLargeStep = false, bool bChapterOverride = false) override; void SeekPercentage(float fPercent = 0) override; - float GetCachePercentage() override; + float GetCachePercentage() const override; void SetMute(bool bOnOff) override; void SeekTime(int64_t iTime = 0) override; bool SeekTimeRelative(int64_t iTime) override; diff --git a/xbmc/cores/VideoPlayer/VideoPlayer.cpp b/xbmc/cores/VideoPlayer/VideoPlayer.cpp index c3b8a724f8abe..779b552247ea3 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayer.cpp +++ b/xbmc/cores/VideoPlayer/VideoPlayer.cpp @@ -3263,7 +3263,7 @@ float CVideoPlayer::GetPercentage() return GetTime() * 100 / (float)iTotalTime; } -float CVideoPlayer::GetCachePercentage() +float CVideoPlayer::GetCachePercentage() const { std::unique_lock lock(m_StateSection); return (float) (m_State.cache_offset * 100); // NOTE: Percentage returned is relative @@ -4876,7 +4876,7 @@ void CVideoPlayer::SetDynamicRangeCompression(long drc) m_VideoPlayerAudio->SetDynamicRangeCompression(drc); } -CVideoSettings CVideoPlayer::GetVideoSettings() +CVideoSettings CVideoPlayer::GetVideoSettings() const { return m_processInfo->GetVideoSettings(); } diff --git a/xbmc/cores/VideoPlayer/VideoPlayer.h b/xbmc/cores/VideoPlayer/VideoPlayer.h index 6255c227b7062..ccb5fa3ac3f12 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayer.h +++ b/xbmc/cores/VideoPlayer/VideoPlayer.h @@ -257,7 +257,7 @@ class CVideoPlayer : public IPlayer, public CThread, public IVideoPlayer, void Seek(bool bPlus, bool bLargeStep, bool bChapterOverride) override; bool SeekScene(bool bPlus = true) override; void SeekPercentage(float iPercent) override; - float GetCachePercentage() override; + float GetCachePercentage() const override; void SetDynamicRangeCompression(long drc) override; bool CanPause() override; @@ -352,7 +352,7 @@ class CVideoPlayer : public IPlayer, public CThread, public IVideoPlayer, int OnDiscNavResult(void* pData, int iMessage) override; void GetVideoResolution(unsigned int &width, unsigned int &height) override; - CVideoSettings GetVideoSettings() override; + CVideoSettings GetVideoSettings() const override; void SetVideoSettings(CVideoSettings& settings) override; void SetUpdateStreamDetails(); diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.h b/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.h index 4ac994ccf3e81..4af912fb07d56 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.h +++ b/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.h @@ -48,7 +48,7 @@ class IRenderMsg virtual void UpdateRenderBuffers(int queued, int discard, int free) = 0; virtual void UpdateGuiRender(bool gui) = 0; virtual void UpdateVideoRender(bool video) = 0; - virtual CVideoSettings GetVideoSettings() = 0; + virtual CVideoSettings GetVideoSettings() const = 0; }; class CRenderManager