OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
sound_output.hpp
Go to the documentation of this file.
1 #ifndef GAME_SOUND_SOUND_OUTPUT_H
2 #define GAME_SOUND_SOUND_OUTPUT_H
3 
4 #include <string>
5 #include <memory>
6 #include <vector>
7 
8 #include "soundmanagerimp.hpp"
9 
10 namespace MWSound
11 {
12  class SoundManager;
13  struct Sound_Decoder;
14  class Sound;
15  class Stream;
16 
17  // An opaque handle for the implementation's sound buffers.
18  typedef void *Sound_Handle;
19  // An opaque handle for the implementation's sound instances.
20  typedef void *Sound_Instance;
21 
22  enum class HrtfMode {
23  Disable,
24  Enable,
25  Auto
26  };
27 
29  {
31 
32  virtual std::vector<std::string> enumerate() = 0;
33  virtual bool init(const std::string &devname, const std::string &hrtfname, HrtfMode hrtfmode) = 0;
34  virtual void deinit() = 0;
35 
36  virtual std::vector<std::string> enumerateHrtf() = 0;
37  virtual void setHrtf(const std::string &hrtfname, HrtfMode hrtfmode) = 0;
38 
39  virtual std::pair<Sound_Handle,size_t> loadSound(const std::string &fname) = 0;
40  virtual size_t unloadSound(Sound_Handle data) = 0;
41 
42  virtual bool playSound(Sound *sound, Sound_Handle data, float offset) = 0;
43  virtual bool playSound3D(Sound *sound, Sound_Handle data, float offset) = 0;
44  virtual void finishSound(Sound *sound) = 0;
45  virtual bool isSoundPlaying(Sound *sound) = 0;
46  virtual void updateSound(Sound *sound) = 0;
47 
48  virtual bool streamSound(DecoderPtr decoder, Stream *sound) = 0;
49  virtual bool streamSound3D(DecoderPtr decoder, Stream *sound, bool getLoudnessData) = 0;
50  virtual void finishStream(Stream *sound) = 0;
51  virtual double getStreamDelay(Stream *sound) = 0;
52  virtual double getStreamOffset(Stream *sound) = 0;
53  virtual float getStreamLoudness(Stream *sound) = 0;
54  virtual bool isStreamPlaying(Stream *sound) = 0;
55  virtual void updateStream(Stream *sound) = 0;
56 
57  virtual void startUpdate() = 0;
58  virtual void finishUpdate() = 0;
59 
60  virtual void updateListener(const osg::Vec3f &pos, const osg::Vec3f &atdir, const osg::Vec3f &updir, Environment env) = 0;
61 
62  virtual void pauseSounds(int types) = 0;
63  virtual void resumeSounds(int types) = 0;
64 
65  Sound_Output& operator=(const Sound_Output &rhs);
66  Sound_Output(const Sound_Output &rhs);
67 
68  protected:
70 
72  : mManager(mgr), mInitialized(false)
73  { }
74  public:
75  virtual ~Sound_Output() { }
76 
77  bool isInitialized() const { return mInitialized; }
78 
79  friend class OpenAL_Output;
80  friend class SoundManager;
81  };
82 }
83 
84 #endif
void * Sound_Handle
Definition: sound_output.hpp:15
virtual bool init(const std::string &devname, const std::string &hrtfname, HrtfMode hrtfmode)=0
Definition: openal_output.hpp:21
Sound_Output(const Sound_Output &rhs)
virtual std::vector< std::string > enumerate()=0
virtual std::vector< std::string > enumerateHrtf()=0
bool isInitialized() const
Definition: sound_output.hpp:77
virtual void setHrtf(const std::string &hrtfname, HrtfMode hrtfmode)=0
virtual void finishUpdate()=0
MWSound::Sound Sound
Definition: soundmanager.hpp:56
virtual void finishSound(Sound *sound)=0
Definition: sound.hpp:95
virtual bool playSound(Sound *sound, Sound_Handle data, float offset)=0
virtual ~Sound_Output()
Definition: sound_output.hpp:75
virtual bool streamSound3D(DecoderPtr decoder, Stream *sound, bool getLoudnessData)=0
virtual float getStreamLoudness(Stream *sound)=0
void * Sound_Instance
Definition: sound_output.hpp:20
Sound_Output & operator=(const Sound_Output &rhs)
virtual bool streamSound(DecoderPtr decoder, Stream *sound)=0
Sound_Output(SoundManager &mgr)
Definition: sound_output.hpp:71
virtual void updateSound(Sound *sound)=0
virtual bool isSoundPlaying(Sound *sound)=0
bool mInitialized
Definition: sound_output.hpp:69
virtual void pauseSounds(int types)=0
virtual void updateListener(const osg::Vec3f &pos, const osg::Vec3f &atdir, const osg::Vec3f &updir, Environment env)=0
virtual void updateStream(Stream *sound)=0
SoundManager & mManager
Definition: sound_output.hpp:30
virtual void resumeSounds(int types)=0
HrtfMode
Definition: sound_output.hpp:22
virtual bool playSound3D(Sound *sound, Sound_Handle data, float offset)=0
virtual void startUpdate()=0
virtual size_t unloadSound(Sound_Handle data)=0
Definition: soundmanagerimp.hpp:45
virtual double getStreamOffset(Stream *sound)=0
Definition: sound_output.hpp:28
virtual std::pair< Sound_Handle, size_t > loadSound(const std::string &fname)=0
std::shared_ptr< Sound_Decoder > DecoderPtr
Definition: soundmanager.hpp:19
virtual void deinit()=0
virtual void finishStream(Stream *sound)=0
Environment
Definition: soundmanagerimp.hpp:35
virtual double getStreamDelay(Stream *sound)=0
Definition: sound.hpp:104
virtual bool isStreamPlaying(Stream *sound)=0