From 0623561fd66fab72c20155c008065869e5e559ef Mon Sep 17 00:00:00 2001 From: CastagnaIT Date: Mon, 7 Oct 2024 08:48:13 +0200 Subject: [Players][cleanup] Changed audio/sub capabilities to enum class --- xbmc/application/ApplicationPlayer.cpp | 8 ++--- xbmc/application/ApplicationPlayer.h | 4 +-- xbmc/cores/IPlayer.h | 40 ++++++++++++++---------- xbmc/cores/paplayer/PAPlayer.h | 2 +- xbmc/video/dialogs/GUIDialogAudioSettings.cpp | 14 ++++----- xbmc/video/dialogs/GUIDialogAudioSettings.h | 7 +++-- xbmc/video/dialogs/GUIDialogSubtitleSettings.cpp | 12 +++---- xbmc/video/dialogs/GUIDialogSubtitleSettings.h | 5 +-- xbmc/video/guilib/VideoStreamSelectHelper.cpp | 21 +++++++------ 9 files changed, 61 insertions(+), 52 deletions(-) diff --git a/xbmc/application/ApplicationPlayer.cpp b/xbmc/application/ApplicationPlayer.cpp index 9a59242a85..a222557677 100644 --- a/xbmc/application/ApplicationPlayer.cpp +++ b/xbmc/application/ApplicationPlayer.cpp @@ -760,18 +760,18 @@ void CApplicationPlayer::LoadPage(int p, int sp, unsigned char* buffer) player->LoadPage(p, sp, buffer); } -void CApplicationPlayer::GetAudioCapabilities(std::vector& audioCaps) const +void CApplicationPlayer::GetAudioCapabilities(std::vector& caps) const { const std::shared_ptr player = GetInternal(); if (player) - player->GetAudioCapabilities(audioCaps); + player->GetAudioCapabilities(caps); } -void CApplicationPlayer::GetSubtitleCapabilities(std::vector& subCaps) const +void CApplicationPlayer::GetSubtitleCapabilities(std::vector& caps) const { const std::shared_ptr player = GetInternal(); if (player) - player->GetSubtitleCapabilities(subCaps); + player->GetSubtitleCapabilities(caps); } int CApplicationPlayer::SeekChapter(int iChapter) diff --git a/xbmc/application/ApplicationPlayer.h b/xbmc/application/ApplicationPlayer.h index ccee506bd6..ae901d4058 100644 --- a/xbmc/application/ApplicationPlayer.h +++ b/xbmc/application/ApplicationPlayer.h @@ -83,7 +83,7 @@ public: bool CanPause() const; bool CanSeek() const; int GetAudioDelay() const; - void GetAudioCapabilities(std::vector& audioCaps) const; + void GetAudioCapabilities(std::vector& caps) const; int GetAudioStream(); int GetAudioStreamCount() const; void GetAudioStreamInfo(int index, AudioStreamInfo& info) const; @@ -98,7 +98,7 @@ public: KODI::PLAYLIST::Id GetPreferredPlaylist() const; int GetSubtitleDelay() const; int GetSubtitle(); - void GetSubtitleCapabilities(std::vector& subCaps) const; + void GetSubtitleCapabilities(std::vector& caps) const; int GetSubtitleCount() const; void GetSubtitleStreamInfo(int index, SubtitleStreamInfo& info) const; bool GetSubtitleVisible() const; diff --git a/xbmc/cores/IPlayer.h b/xbmc/cores/IPlayer.h index d988d77527..8f6bd763bf 100644 --- a/xbmc/cores/IPlayer.h +++ b/xbmc/cores/IPlayer.h @@ -50,22 +50,24 @@ public: class CFileItem; -enum IPlayerAudioCapabilities +// \brief Player Audio capabilities +enum class IPlayerAudioCaps { - IPC_AUD_ALL, - IPC_AUD_OFFSET, - IPC_AUD_AMP, - IPC_AUD_SELECT_STREAM, - IPC_AUD_OUTPUT_STEREO, - IPC_AUD_SELECT_OUTPUT + ALL, // All capabilities supported + SELECT_STREAM, // Support to change stream + SELECT_OUTPUT, // Support to select an output device + OUTPUT_STEREO, // Support output in stereo mode + OFFSET, // Support to change sync offset + VOLUME_AMP, // Support volume amplification }; -enum IPlayerSubtitleCapabilities +// \brief Player Subtitle capabilities +enum class IPlayerSubtitleCaps { - IPC_SUBS_ALL, - IPC_SUBS_SELECT, - IPC_SUBS_EXTERNAL, - IPC_SUBS_OFFSET + ALL, // All capabilities supported + SELECT_STREAM, // Support to change stream + EXTERNAL, // Support to load external subtitles + OFFSET, // Support to change sync offset }; enum ERENDERFEATURE @@ -211,16 +213,20 @@ public: virtual std::string GetPlayerState() { return ""; } virtual bool SetPlayerState(const std::string& state) { return false; } - virtual void GetAudioCapabilities(std::vector& audioCaps) const + /*! + * \brief Define the audio capabilities of the player + */ + virtual void GetAudioCapabilities(std::vector& caps) const { - audioCaps.assign(1, IPC_AUD_ALL); + caps.assign(1, IPlayerAudioCaps::ALL); } + /*! - \brief define the subtitle capabilities of the player + * \brief Define the subtitle capabilities of the player */ - virtual void GetSubtitleCapabilities(std::vector& subCaps) const + virtual void GetSubtitleCapabilities(std::vector& caps) const { - subCaps.assign(1, IPC_SUBS_ALL); + caps.assign(1, IPlayerSubtitleCaps::ALL); } /*! diff --git a/xbmc/cores/paplayer/PAPlayer.h b/xbmc/cores/paplayer/PAPlayer.h index c2a77dd84a..ae7059bfd8 100644 --- a/xbmc/cores/paplayer/PAPlayer.h +++ b/xbmc/cores/paplayer/PAPlayer.h @@ -50,7 +50,7 @@ public: void GetAudioStreamInfo(int index, AudioStreamInfo& info) const override; void SetTime(int64_t time) override; void SeekTime(int64_t iTime = 0) override; - void GetAudioCapabilities(std::vector& audioCaps) const override {} + void GetAudioCapabilities(std::vector& caps) const override {} int GetAudioStreamCount() const override { return 1; } int GetAudioStream() override { return 0; } diff --git a/xbmc/video/dialogs/GUIDialogAudioSettings.cpp b/xbmc/video/dialogs/GUIDialogAudioSettings.cpp index 3030efaead..e8371ffa3b 100644 --- a/xbmc/video/dialogs/GUIDialogAudioSettings.cpp +++ b/xbmc/video/dialogs/GUIDialogAudioSettings.cpp @@ -263,7 +263,7 @@ void CGUIDialogAudioSettings::InitializeSettings() std::static_pointer_cast(settingAudioVolume->GetControl())->SetFormatter(SettingFormatterPercentAsDecibel); // audio volume amplification setting - if (SupportsAudioFeature(IPC_AUD_AMP)) + if (SupportsAudioFeature(IPlayerAudioCaps::VOLUME_AMP)) { std::shared_ptr settingAudioVolumeAmplification = AddSlider(groupAudio, SETTING_AUDIO_VOLUME_AMPLIFICATION, 660, SettingLevel::Basic, videoSettings.m_VolumeAmplification, 14054, VOLUME_DRC_MINIMUM * 0.01f, (VOLUME_DRC_MAXIMUM - VOLUME_DRC_MINIMUM) / 6000.0f, VOLUME_DRC_MAXIMUM * 0.01f); settingAudioVolumeAmplification->SetDependencies(depsAudioOutputPassthroughDisabled); @@ -277,7 +277,7 @@ void CGUIDialogAudioSettings::InitializeSettings() } // audio delay setting - if (SupportsAudioFeature(IPC_AUD_OFFSET)) + if (SupportsAudioFeature(IPlayerAudioCaps::OFFSET)) { std::shared_ptr settingAudioDelay = AddSlider( groupAudio, SETTING_AUDIO_DELAY, 297, SettingLevel::Basic, videoSettings.m_AudioDelay, 0, @@ -289,11 +289,11 @@ void CGUIDialogAudioSettings::InitializeSettings() } // audio stream setting - if (SupportsAudioFeature(IPC_AUD_SELECT_STREAM)) + if (SupportsAudioFeature(IPlayerAudioCaps::SELECT_STREAM)) AddAudioStreams(groupAudio, SETTING_AUDIO_STREAM); // audio digital/analog setting - if (SupportsAudioFeature(IPC_AUD_SELECT_OUTPUT)) + if (SupportsAudioFeature(IPlayerAudioCaps::SELECT_OUTPUT)) { m_passthrough = CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_AUDIOOUTPUT_PASSTHROUGH); AddToggle(groupAudio, SETTING_AUDIO_PASSTHROUGH, 348, SettingLevel::Basic, m_passthrough); @@ -303,11 +303,11 @@ void CGUIDialogAudioSettings::InitializeSettings() AddButton(groupSaveAsDefault, SETTING_AUDIO_MAKE_DEFAULT, 12376, SettingLevel::Basic); } -bool CGUIDialogAudioSettings::SupportsAudioFeature(int feature) +bool CGUIDialogAudioSettings::SupportsAudioFeature(IPlayerAudioCaps feature) { - for (Features::iterator itr = m_audioCaps.begin(); itr != m_audioCaps.end(); ++itr) + for (IPlayerAudioCaps cap : m_audioCaps) { - if (*itr == feature || *itr == IPC_AUD_ALL) + if (cap == feature || cap == IPlayerAudioCaps::ALL) return true; } diff --git a/xbmc/video/dialogs/GUIDialogAudioSettings.h b/xbmc/video/dialogs/GUIDialogAudioSettings.h index de69b77ae7..d07b694e68 100644 --- a/xbmc/video/dialogs/GUIDialogAudioSettings.h +++ b/xbmc/video/dialogs/GUIDialogAudioSettings.h @@ -15,6 +15,7 @@ #include #include +enum class IPlayerAudioCaps; class CVariant; struct IntegerSettingOption; @@ -44,7 +45,7 @@ protected: // specialization of CGUIDialogSettingsManualBase void InitializeSettings() override; - bool SupportsAudioFeature(int feature); + bool SupportsAudioFeature(IPlayerAudioCaps feature); void AddAudioStreams(const std::shared_ptr& group, const std::string& settingId); @@ -75,8 +76,8 @@ protected: int m_audioStream; bool m_passthrough = false; - typedef std::vector Features; - Features m_audioCaps; + std::vector m_audioCaps; + private: static std::string FormatFlags(StreamFlags flags); }; diff --git a/xbmc/video/dialogs/GUIDialogSubtitleSettings.cpp b/xbmc/video/dialogs/GUIDialogSubtitleSettings.cpp index d1c8e31524..20dd6d8b4b 100644 --- a/xbmc/video/dialogs/GUIDialogSubtitleSettings.cpp +++ b/xbmc/video/dialogs/GUIDialogSubtitleSettings.cpp @@ -297,18 +297,18 @@ void CGUIDialogSubtitleSettings::InitializeSettings() AddToggle(groupSubtitles, SETTING_SUBTITLE_ENABLE, 13397, SettingLevel::Basic, m_subtitleVisible); // subtitle delay setting - if (SupportsSubtitleFeature(IPC_SUBS_OFFSET)) + if (SupportsSubtitleFeature(IPlayerSubtitleCaps::OFFSET)) { std::shared_ptr settingSubtitleDelay = AddSlider(groupSubtitles, SETTING_SUBTITLE_DELAY, 22006, SettingLevel::Basic, videoSettings.m_SubtitleDelay, 0, -CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_videoSubsDelayRange, 0.1f, CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_videoSubsDelayRange, 22006, usePopup); std::static_pointer_cast(settingSubtitleDelay->GetControl())->SetFormatter(SettingFormatterDelay); } // subtitle stream setting - if (SupportsSubtitleFeature(IPC_SUBS_SELECT)) + if (SupportsSubtitleFeature(IPlayerSubtitleCaps::SELECT_STREAM)) AddSubtitleStreams(groupSubtitles, SETTING_SUBTITLE_STREAM); // subtitle browser setting - if (SupportsSubtitleFeature(IPC_SUBS_EXTERNAL)) + if (SupportsSubtitleFeature(IPlayerSubtitleCaps::EXTERNAL)) AddButton(groupSubtitles, SETTING_SUBTITLE_BROWSER, 13250, SettingLevel::Basic); AddButton(groupSubtitles, SETTING_SUBTITLE_SEARCH, 24134, SettingLevel::Basic); @@ -317,11 +317,11 @@ void CGUIDialogSubtitleSettings::InitializeSettings() AddButton(groupSaveAsDefault, SETTING_MAKE_DEFAULT, 12376, SettingLevel::Basic); } -bool CGUIDialogSubtitleSettings::SupportsSubtitleFeature(int feature) +bool CGUIDialogSubtitleSettings::SupportsSubtitleFeature(IPlayerSubtitleCaps feature) { - for (auto item : m_subtitleCapabilities) + for (IPlayerSubtitleCaps cap : m_subtitleCapabilities) { - if (item == feature || item == IPC_SUBS_ALL) + if (cap == feature || cap == IPlayerSubtitleCaps::ALL) return true; } return false; diff --git a/xbmc/video/dialogs/GUIDialogSubtitleSettings.h b/xbmc/video/dialogs/GUIDialogSubtitleSettings.h index 65216ede38..5889734939 100644 --- a/xbmc/video/dialogs/GUIDialogSubtitleSettings.h +++ b/xbmc/video/dialogs/GUIDialogSubtitleSettings.h @@ -15,6 +15,7 @@ #include #include +enum class IPlayerSubtitleCaps; class CVariant; struct IntegerSettingOption; @@ -44,7 +45,7 @@ protected: void InitializeSettings() override; private: - bool SupportsSubtitleFeature(int feature); + bool SupportsSubtitleFeature(IPlayerSubtitleCaps feature); void AddSubtitleStreams(const std::shared_ptr& group, const std::string& settingId); @@ -53,7 +54,7 @@ private: bool m_subtitleVisible; std::shared_ptr m_subtitleStreamSetting; - std::vector m_subtitleCapabilities; + std::vector m_subtitleCapabilities; static std::string FormatFlags(StreamFlags flags); static void SubtitleStreamsOptionFiller(const std::shared_ptr& setting, diff --git a/xbmc/video/guilib/VideoStreamSelectHelper.cpp b/xbmc/video/guilib/VideoStreamSelectHelper.cpp index a8c046eafe..93d7a80936 100644 --- a/xbmc/video/guilib/VideoStreamSelectHelper.cpp +++ b/xbmc/video/guilib/VideoStreamSelectHelper.cpp @@ -256,22 +256,23 @@ struct SortComparerStreamSubtitle } }; -bool SupportsAudioFeature(int feature, const std::vector& caps) +bool SupportsAudioFeature(IPlayerAudioCaps feature, const std::vector& caps) { - for (int item : caps) + for (IPlayerAudioCaps cap : caps) { - if (item == feature || item == IPC_AUD_ALL) + if (cap == feature || cap == IPlayerAudioCaps::ALL) return true; } return false; } -bool SupportsSubtitleFeature(int feature, const std::vector& caps) +bool SupportsSubtitleFeature(IPlayerSubtitleCaps feature, + const std::vector& caps) { - for (int item : caps) + for (IPlayerSubtitleCaps cap : caps) { - if (item == feature || item == IPC_SUBS_ALL) + if (cap == feature || cap == IPlayerSubtitleCaps::ALL) return true; } return false; @@ -374,9 +375,9 @@ void KODI::VIDEO::GUILIB::OpenDialogSelectAudioStream() auto& components = CServiceBroker::GetAppComponents(); auto appPlayer = components.GetComponent(); - std::vector caps; + std::vector caps; appPlayer->GetAudioCapabilities(caps); - if (!SupportsAudioFeature(IPC_AUD_SELECT_STREAM, caps)) + if (!SupportsAudioFeature(IPlayerAudioCaps::SELECT_STREAM, caps)) return; const int streamCount = appPlayer->GetAudioStreamCount(); @@ -446,9 +447,9 @@ void KODI::VIDEO::GUILIB::OpenDialogSelectSubtitleStream() auto& components = CServiceBroker::GetAppComponents(); auto appPlayer = components.GetComponent(); - std::vector caps; + std::vector caps; appPlayer->GetSubtitleCapabilities(caps); - if (!SupportsSubtitleFeature(IPC_SUBS_SELECT, caps)) + if (!SupportsSubtitleFeature(IPlayerSubtitleCaps::SELECT_STREAM, caps)) return; const int streamCount = appPlayer->GetSubtitleCount(); -- cgit v1.2.3