/* * 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 "GUIComponent.h" #include "cores/AudioEngine/Interfaces/AESound.h" #include "settings/lib/ISettingCallback.h" #include "threads/CriticalSection.h" #include #include #include // forward definitions class CAction; class CSettings; class TiXmlNode; class IAESound; enum WINDOW_SOUND { SOUND_INIT = 0, SOUND_DEINIT }; class CGUIAudioManager : public ISettingCallback { class CWindowSounds { public: std::shared_ptr initSound; std::shared_ptr deInitSound; }; struct IAESoundDeleter { void operator()(IAESound* s); }; public: CGUIAudioManager(); ~CGUIAudioManager() override; void OnSettingChanged(const std::shared_ptr& setting) override; bool OnSettingUpdate(const std::shared_ptr& setting, const char* oldSettingId, const TiXmlNode* oldSettingNode) override; void Initialize(); void DeInitialize(); bool Load(); void UnLoad(); void PlayActionSound(const CAction& action); void PlayWindowSound(int id, WINDOW_SOUND event); void PlayPythonSound(const std::string& strFileName, bool useCached = true); void Enable(bool bEnable); void SetVolume(float level); void Stop(); private: // Construction parameters std::shared_ptr m_settings; typedef std::map> soundCache; typedef std::map> actionSoundMap; typedef std::map windowSoundMap; typedef std::map> pythonSoundsMap; soundCache m_soundCache; actionSoundMap m_actionSoundMap; windowSoundMap m_windowSoundMap; pythonSoundsMap m_pythonSounds; std::string m_strMediaDir; bool m_bEnabled; CCriticalSection m_cs; std::shared_ptr LoadSound(const std::string& filename); std::shared_ptr LoadWindowSound(TiXmlNode* pWindowNode, const std::string& strIdentifier); };