/
SoundManager.h
61 lines (45 loc) · 1.53 KB
/
SoundManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once
#include "SoundShader.h"
#include "SoundPlayer.h"
#include "isound.h"
#include "icommandsystem.h"
#include "ThreadedDefLoader.h"
#include <map>
namespace sound {
/// SoundManager implementing class.
class SoundManager :
public ISoundManager
{
public: /* TYPES */
// Map of named sound shaders
typedef std::map<std::string, SoundShader::Ptr> ShaderMap;
private: /* FIELDS */
// Master map of shaders
ShaderMap _shaders;
// Shaders are loaded asynchronically, this loader
// takes care of the worker thread
util::ThreadedDefLoader<void> _defLoader;
SoundShader::Ptr _emptyShader;
// The helper class for playing the sounds
std::unique_ptr<SoundPlayer> _soundPlayer;
sigc::signal<void> _sigSoundShadersReloaded;
private:
void loadShadersFromFilesystem();
void ensureShadersLoaded();
void reloadSoundsCmd(const cmd::ArgumentList& args);
public:
SoundManager();
// ISoundManager implementation
void forEachShader(std::function<void(const ISoundShader&)>) override;
ISoundShaderPtr getSoundShader(const std::string& shaderName) override;
bool playSound(const std::string& fileName) override;
bool playSound(const std::string& fileName, bool loopSound) override;
void stopSound() override;
void reloadSounds() override;
sigc::signal<void>& signal_soundShadersReloaded() override;
// RegisterableModule implementation
const std::string& getName() const override;
const StringSet& getDependencies() const override;
void initialiseModule(const IApplicationContext& ctx) override;
};
}