OpenMW
apps/openmw/mwsound/openal_output.hpp
Go to the documentation of this file.
00001 #ifndef GAME_SOUND_OPENAL_OUTPUT_H
00002 #define GAME_SOUND_OPENAL_OUTPUT_H
00003 
00004 #include <string>
00005 #include <vector>
00006 #include <map>
00007 #include <deque>
00008 
00009 #include "alc.h"
00010 #include "al.h"
00011 
00012 #include "sound_output.hpp"
00013 
00014 namespace MWSound
00015 {
00016     class SoundManager;
00017     class Sound;
00018 
00019     class OpenAL_Output : public Sound_Output
00020     {
00021         ALCdevice *mDevice;
00022         ALCcontext *mContext;
00023 
00024         typedef std::deque<ALuint> IDDq;
00025         IDDq mFreeSources;
00026         IDDq mUnusedBuffers;
00027 
00028         typedef std::map<std::string,ALuint> NameMap;
00029         NameMap mBufferCache;
00030 
00031         typedef std::map<ALuint,ALuint> IDRefMap;
00032         IDRefMap mBufferRefs;
00033 
00034         uint64_t mBufferCacheMemSize;
00035 
00036         typedef std::vector<Sound*> SoundVec;
00037         SoundVec mActiveSounds;
00038 
00039         ALuint getBuffer(const std::string &fname);
00040         void bufferFinished(ALuint buffer);
00041 
00042         Environment mLastEnvironment;
00043 
00044         virtual std::vector<std::string> enumerate();
00045         virtual void init(const std::string &devname="");
00046         virtual void deinit();
00047 
00049         virtual MWBase::SoundPtr playSound(const std::string &fname, float vol, float basevol, float pitch, int flags, float offset);
00051         virtual MWBase::SoundPtr playSound3D(const std::string &fname, const Ogre::Vector3 &pos,
00052                                              float vol, float basevol, float pitch, float min, float max, int flags, float offset);
00053         virtual MWBase::SoundPtr streamSound(DecoderPtr decoder, float volume, float pitch, int flags);
00054 
00055         virtual void updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3 &atdir, const Ogre::Vector3 &updir, Environment env);
00056 
00057         virtual void pauseSounds(int types);
00058         virtual void resumeSounds(int types);
00059 
00060         OpenAL_Output& operator=(const OpenAL_Output &rhs);
00061         OpenAL_Output(const OpenAL_Output &rhs);
00062 
00063         OpenAL_Output(SoundManager &mgr);
00064         virtual ~OpenAL_Output();
00065 
00066         class StreamThread;
00067         std::auto_ptr<StreamThread> mStreamThread;
00068 
00069         friend class OpenAL_Sound;
00070         friend class OpenAL_Sound3D;
00071         friend class OpenAL_SoundStream;
00072         friend class SoundManager;
00073     };
00074 #ifndef DEFAULT_OUTPUT
00075 #define DEFAULT_OUTPUT(x) ::MWSound::OpenAL_Output((x))
00076 #endif
00077 }
00078 
00079 #endif