PageRenderTime 38ms CodeModel.GetById 27ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

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