/xbmc/guilib/GUIAudioManager.h

http://github.com/xbmc/xbmc · C Header · 89 lines · 59 code · 21 blank · 9 comment · 0 complexity · d38b99c07af09cbdc42e7bebe28fa6a3 MD5 · raw file

  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. #pragma once
  9. #include "GUIComponent.h"
  10. #include "cores/AudioEngine/Interfaces/AESound.h"
  11. #include "settings/lib/ISettingCallback.h"
  12. #include "threads/CriticalSection.h"
  13. #include <map>
  14. #include <string>
  15. // forward definitions
  16. class CAction;
  17. class CSettings;
  18. class TiXmlNode;
  19. class IAESound;
  20. enum WINDOW_SOUND { SOUND_INIT = 0, SOUND_DEINIT };
  21. class CGUIAudioManager : public ISettingCallback
  22. {
  23. class CWindowSounds
  24. {
  25. public:
  26. IAESound *initSound;
  27. IAESound *deInitSound;
  28. };
  29. class CSoundInfo
  30. {
  31. public:
  32. int usage;
  33. IAESound *sound;
  34. };
  35. public:
  36. CGUIAudioManager();
  37. ~CGUIAudioManager() override;
  38. void OnSettingChanged(std::shared_ptr<const CSetting> setting) override;
  39. bool OnSettingUpdate(std::shared_ptr<CSetting> setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) override;
  40. void Initialize();
  41. void DeInitialize();
  42. bool Load();
  43. void UnLoad();
  44. void PlayActionSound(const CAction& action);
  45. void PlayWindowSound(int id, WINDOW_SOUND event);
  46. void PlayPythonSound(const std::string& strFileName, bool useCached = true);
  47. void Enable(bool bEnable);
  48. void SetVolume(float level);
  49. void Stop();
  50. private:
  51. // Construction parameters
  52. std::shared_ptr<CSettings> m_settings;
  53. typedef std::map<const std::string, CSoundInfo> soundCache;
  54. typedef std::map<int, IAESound* > actionSoundMap;
  55. typedef std::map<int, CWindowSounds > windowSoundMap;
  56. typedef std::map<const std::string, IAESound* > pythonSoundsMap;
  57. soundCache m_soundCache;
  58. actionSoundMap m_actionSoundMap;
  59. windowSoundMap m_windowSoundMap;
  60. pythonSoundsMap m_pythonSounds;
  61. std::string m_strMediaDir;
  62. bool m_bEnabled;
  63. CCriticalSection m_cs;
  64. IAESound* LoadSound(const std::string &filename);
  65. void FreeSound(IAESound *sound);
  66. void FreeSoundAllUsage(IAESound *sound);
  67. IAESound* LoadWindowSound(TiXmlNode* pWindowNode, const std::string& strIdentifier);
  68. };