summaryrefslogtreecommitdiffstats
path: root/xbmc/application/ApplicationVolumeHandling.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /xbmc/application/ApplicationVolumeHandling.h
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/application/ApplicationVolumeHandling.h')
-rw-r--r--xbmc/application/ApplicationVolumeHandling.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/xbmc/application/ApplicationVolumeHandling.h b/xbmc/application/ApplicationVolumeHandling.h
new file mode 100644
index 0000000..d417227
--- /dev/null
+++ b/xbmc/application/ApplicationVolumeHandling.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2005-2018 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#pragma once
+
+#include "application/IApplicationComponent.h"
+
+class CAction;
+class CApplication;
+class CSetting;
+class CSettings;
+class TiXmlNode;
+
+/*!
+ * \brief Class handling application support for audio volume management.
+ */
+class CApplicationVolumeHandling : public IApplicationComponent
+{
+ friend class CApplication;
+
+public:
+ // replay gain settings struct for quick access by the player multiple
+ // times per second (saves doing settings lookup)
+ struct ReplayGainSettings
+ {
+ int iPreAmp;
+ int iNoGainPreAmp;
+ int iType;
+ bool bAvoidClipping;
+ };
+
+ float GetVolumePercent() const;
+ float GetVolumeRatio() const;
+ bool IsMuted() const;
+
+ void SetVolume(float iValue, bool isPercentage = true);
+ void SetMute(bool mute);
+ void ToggleMute(void);
+
+ const ReplayGainSettings& GetReplayGainSettings() const { return m_replayGainSettings; }
+
+ static constexpr float VOLUME_MINIMUM = 0.0f; // -60dB
+ static constexpr float VOLUME_MAXIMUM = 1.0f; // 0dB
+ static constexpr float VOLUME_DYNAMIC_RANGE = 90.0f; // 60dB
+
+ bool Load(const TiXmlNode* settings);
+ bool Save(TiXmlNode* settings) const;
+ bool OnSettingChanged(const CSetting& setting);
+
+protected:
+ bool IsMutedInternal() const { return m_muted; }
+ void ShowVolumeBar(const CAction* action = nullptr);
+
+ void CacheReplayGainSettings(const CSettings& settings);
+
+ void Mute();
+ void UnMute();
+
+ void SetHardwareVolume(float hardwareVolume);
+
+ void VolumeChanged();
+
+ bool m_muted = false;
+ float m_volumeLevel = VOLUME_MAXIMUM;
+ ReplayGainSettings m_replayGainSettings;
+};