kodi
ApplicationVolumeHandling.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "application/IApplicationComponent.h"
12 
13 class CAction;
14 class CApplication;
15 class CSetting;
16 class CSettings;
17 class TiXmlNode;
18 
23 {
24  friend class CApplication;
25 
26 public:
27  // replay gain settings struct for quick access by the player multiple
28  // times per second (saves doing settings lookup)
30  {
31  int iPreAmp;
32  int iNoGainPreAmp;
33  int iType;
34  bool bAvoidClipping;
35  };
36 
37  float GetVolumePercent() const;
38  float GetVolumeRatio() const;
39  bool IsMuted() const;
40 
41  void SetVolume(float iValue, bool isPercentage = true);
42  void SetMute(bool mute);
43  void ToggleMute(void);
44 
45  const ReplayGainSettings& GetReplayGainSettings() const { return m_replayGainSettings; }
46 
47  static constexpr float VOLUME_MINIMUM = 0.0f; // -60dB
48  static constexpr float VOLUME_MAXIMUM = 1.0f; // 0dB
49  static constexpr float VOLUME_DYNAMIC_RANGE = 90.0f; // 60dB
50 
51  bool Load(const TiXmlNode* settings);
52  bool Save(TiXmlNode* settings) const;
53  bool OnSettingChanged(const CSetting& setting);
54 
55 protected:
56  bool IsMutedInternal() const { return m_muted; }
57  void ShowVolumeBar(const CAction* action = nullptr);
58 
59  void CacheReplayGainSettings(const CSettings& settings);
60 
61  void Mute();
62  void UnMute();
63 
64  void SetHardwareVolume(float hardwareVolume);
65 
66  void VolumeChanged();
67 
68  bool m_muted = false;
69  float m_volumeLevel = VOLUME_MAXIMUM;
70  ReplayGainSettings m_replayGainSettings;
71 };
Class handling application support for audio volume management.
Definition: ApplicationVolumeHandling.h:22
Wrapper around CSettingsManager responsible for properly setting up the settings manager and register...
Definition: Settings.h:27
Setting base class containing all the properties which are common to all settings independent of the ...
Definition: Setting.h:46
Definition: Application.h:82
Class encapsulating information regarding a particular user action to be sent to windows and controls...
Definition: Action.h:21
Base class for application components.
Definition: IApplicationComponent.h:12
Definition: settings.py:1
Definition: ApplicationVolumeHandling.h:29