7
11
#include <boost/ptr_container/ptr_vector.hpp>
8
12
#include <boost/shared_ptr.hpp>
9
13
#include <boost/thread/thread.hpp>
10
#include <boost/thread/mutex.hpp>
14
#include <boost/thread/recursive_mutex.hpp>
12
16
#include "float3.h"
19
// Sound system interface
23
/// Default sound system implementation (OpenAL)
24
class CSound : public ISound
22
friend class EffectChannel;
27
bool HasSoundItem(const std::string& name);
28
size_t GetSoundId(const std::string& name, bool hardFail = true);
30
/// returns a free soundsource if available, the one with the lowest priority otherwise
31
SoundSource* GetNextBestSource(bool lock = true);
33
void UpdateListener(const float3& campos, const float3& camdir, const float3& camup, float lastFrameTime);
36
void ConfigNotify(const std::string& key, const std::string& value);
37
void PitchAdjust(const float newPitch);
42
void Iconified(bool state);
44
void PrintDebugInfo();
45
bool LoadSoundDefs(const std::string& filename);
30
virtual bool HasSoundItem(const std::string& name);
31
virtual size_t GetSoundId(const std::string& name, bool hardFail = true);
33
virtual SoundSource* GetNextBestSource(bool lock = true);
35
virtual void UpdateListener(const float3& campos, const float3& camdir, const float3& camup, float lastFrameTime);
36
virtual void NewFrame();
38
/// @see ConfigHandler::ConfigNotifyCallback
39
virtual void ConfigNotify(const std::string& key, const std::string& value);
40
virtual void PitchAdjust(const float newPitch);
43
virtual bool IsMuted() const;
45
virtual void Iconified(bool state);
47
virtual void PrintDebugInfo();
48
virtual bool LoadSoundDefs(const std::string& fileName);
48
51
void StartThread(int maxSounds);
54
57
size_t MakeItemFromDef(const soundItemDef& itemDef);
56
void PlaySample(size_t id, const float3 &p, const float3& velocity, float volume, bool relative);
59
friend class EffectChannel;
60
// this is used by EffectChannel in AudioChannel.cpp
61
virtual void PlaySample(size_t id, const float3 &p, const float3& velocity, float volume, bool relative);
58
63
size_t LoadSoundBuffer(const std::string& filename, bool hardFail);
60
65
float masterVolume;
62
bool appIsIconified; // do not play when minimized / iconified
67
/// we do not play if minimized / iconified
65
71
typedef std::map<std::string, size_t> soundMapT;
81
87
soundItemDefMap soundItemDefs;
83
89
boost::thread* soundThread;
84
boost::mutex soundMutex;
90
boost::recursive_mutex soundMutex;
92
volatile bool soundThreadQuit;
89
#endif // SOUNDSYSTEM_INTERFACE_H