DVDCodecs: Amlogic: Handle conditions in which amcodec should be opened during Open()
[vuplus_xbmc] / xbmc / guilib / GUIAudioManager.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22
23 #include <map>
24
25 #include "cores/AudioEngine/Interfaces/AESound.h"
26 #include "settings/lib/ISettingCallback.h"
27 #include "threads/CriticalSection.h"
28 #include "utils/log.h"
29 #include "utils/StdString.h"
30
31 // forward definitions
32 class CAction;
33 class TiXmlNode;
34 class IAESound;
35
36 enum WINDOW_SOUND { SOUND_INIT = 0, SOUND_DEINIT };
37
38 class CGUIAudioManager : public ISettingCallback
39 {
40   class CWindowSounds
41   {
42   public:
43     IAESound *initSound;
44     IAESound *deInitSound;
45   };
46
47   class CSoundInfo
48   {
49   public:
50     int usage;
51     IAESound *sound;      
52   };
53
54 public:
55   CGUIAudioManager();
56   ~CGUIAudioManager();
57
58   virtual void OnSettingChanged(const CSetting *setting);
59
60   void Initialize();
61   void DeInitialize();
62
63   bool Load();
64   void UnLoad();
65
66
67   void PlayActionSound(const CAction& action);
68   void PlayWindowSound(int id, WINDOW_SOUND event);
69   void PlayPythonSound(const CStdString& strFileName);
70
71   void Enable(bool bEnable);
72   void SetVolume(float level);
73   void Stop();
74 private:
75   typedef std::map<const CStdString, CSoundInfo> soundCache;
76   typedef std::map<int, IAESound*              > actionSoundMap;
77   typedef std::map<int, CWindowSounds          > windowSoundMap;
78   typedef std::map<const CStdString, IAESound* > pythonSoundsMap;
79
80   soundCache          m_soundCache;
81   actionSoundMap      m_actionSoundMap;
82   windowSoundMap      m_windowSoundMap;
83   pythonSoundsMap     m_pythonSounds;
84
85   CStdString          m_strMediaDir;
86   bool                m_bEnabled;
87
88   CCriticalSection    m_cs;
89
90   IAESound* LoadSound(const CStdString &filename);
91   void      FreeSound(IAESound *sound);
92   IAESound* LoadWindowSound(TiXmlNode* pWindowNode, const CStdString& strIdentifier);
93 };
94
95 extern CGUIAudioManager g_audioManager;