~ubuntu-branches/ubuntu/natty/spring/natty

« back to all changes in this revision

Viewing changes to rts/System/Sound/Sound.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Ritchie
  • Date: 2010-09-23 18:56:03 UTC
  • mfrom: (3.1.9 experimental)
  • Revision ID: james.westby@ubuntu.com-20100923185603-st97s5chplo42y7w
Tags: 0.82.5.1+dfsg1-1ubuntu1
* Latest upstream version for online play
* debian/control: Replace (rather than conflict) spring-engine
  - spring-engine will be a dummy package (LP: #612905)
  - also set maintainer to MOTU

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef SOUNDSYSTEM_INTERFACE_H
2
 
#define SOUNDSYSTEM_INTERFACE_H
 
1
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
 
2
 
 
3
#ifndef _SOUND_H_
 
4
#define _SOUND_H_
 
5
 
 
6
#include "ISound.h"
3
7
 
4
8
#include <set>
5
9
#include <string>
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>
11
15
 
12
16
#include "float3.h"
13
17
 
16
20
class SoundItem;
17
21
 
18
22
 
19
 
// Sound system interface
20
 
class CSound
 
23
/// Default sound system implementation (OpenAL)
 
24
class CSound : public ISound
21
25
{
22
 
        friend class EffectChannel;
23
26
public:
24
27
        CSound();
25
 
        ~CSound();
26
 
 
27
 
        bool HasSoundItem(const std::string& name);
28
 
        size_t GetSoundId(const std::string& name, bool hardFail = true);
29
 
 
30
 
        /// returns a free soundsource if available, the one with the lowest priority otherwise
31
 
        SoundSource* GetNextBestSource(bool lock = true);
32
 
 
33
 
        void UpdateListener(const float3& campos, const float3& camdir, const float3& camup, float lastFrameTime);
34
 
        void NewFrame();
35
 
 
36
 
        void ConfigNotify(const std::string& key, const std::string& value);
37
 
        void PitchAdjust(const float newPitch);
38
 
 
39
 
        bool Mute();
40
 
        bool IsMuted() const;
41
 
 
42
 
        void Iconified(bool state);
43
 
 
44
 
        void PrintDebugInfo();
45
 
        bool LoadSoundDefs(const std::string& filename);
 
28
        virtual ~CSound();
 
29
 
 
30
        virtual bool HasSoundItem(const std::string& name);
 
31
        virtual size_t GetSoundId(const std::string& name, bool hardFail = true);
 
32
 
 
33
        virtual SoundSource* GetNextBestSource(bool lock = true);
 
34
 
 
35
        virtual void UpdateListener(const float3& campos, const float3& camdir, const float3& camup, float lastFrameTime);
 
36
        virtual void NewFrame();
 
37
 
 
38
        /// @see ConfigHandler::ConfigNotifyCallback
 
39
        virtual void ConfigNotify(const std::string& key, const std::string& value);
 
40
        virtual void PitchAdjust(const float newPitch);
 
41
 
 
42
        virtual bool Mute();
 
43
        virtual bool IsMuted() const;
 
44
 
 
45
        virtual void Iconified(bool state);
 
46
 
 
47
        virtual void PrintDebugInfo();
 
48
        virtual bool LoadSoundDefs(const std::string& fileName);
46
49
 
47
50
private:
48
51
        void StartThread(int maxSounds);
53
56
 
54
57
        size_t MakeItemFromDef(const soundItemDef& itemDef);
55
58
 
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);
57
62
 
58
63
        size_t LoadSoundBuffer(const std::string& filename, bool hardFail);
59
64
 
60
65
        float masterVolume;
61
66
        bool mute;
62
 
        bool appIsIconified; // do not play when minimized / iconified
 
67
        /// we do not play if minimized / iconified
 
68
        bool appIsIconified;
63
69
        bool pitchAdjust;
64
70
 
65
71
        typedef std::map<std::string, size_t> soundMapT;
81
87
        soundItemDefMap soundItemDefs;
82
88
 
83
89
        boost::thread* soundThread;
84
 
        boost::mutex soundMutex;
 
90
        boost::recursive_mutex soundMutex;
 
91
 
 
92
        volatile bool soundThreadQuit;
85
93
};
86
94
 
87
 
extern CSound* sound;
88
 
 
89
 
#endif // SOUNDSYSTEM_INTERFACE_H
 
95
#endif // _SOUND_H_