2012-03-17 05:12:17 +00:00
|
|
|
#ifndef GAME_SOUND_OPENAL_OUTPUT_H
|
|
|
|
#define GAME_SOUND_OPENAL_OUTPUT_H
|
|
|
|
|
2012-03-17 06:40:07 +00:00
|
|
|
#include <string>
|
2012-03-19 14:11:01 +00:00
|
|
|
#include <vector>
|
2012-03-19 17:33:06 +00:00
|
|
|
#include <map>
|
|
|
|
#include <deque>
|
2012-03-17 05:12:17 +00:00
|
|
|
|
|
|
|
#include "alc.h"
|
|
|
|
#include "al.h"
|
|
|
|
|
2012-03-17 06:40:07 +00:00
|
|
|
#include "sound_output.hpp"
|
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
namespace MWSound
|
|
|
|
{
|
2012-03-17 06:40:07 +00:00
|
|
|
class SoundManager;
|
2012-03-17 09:55:08 +00:00
|
|
|
class Sound;
|
2012-03-17 06:40:07 +00:00
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
class OpenAL_Output : public Sound_Output
|
|
|
|
{
|
2012-03-18 18:30:53 +00:00
|
|
|
ALCdevice *mDevice;
|
|
|
|
ALCcontext *mContext;
|
2012-03-17 05:12:17 +00:00
|
|
|
|
2012-03-28 12:35:51 +00:00
|
|
|
typedef std::deque<ALuint> IDDq;
|
|
|
|
IDDq mFreeSources;
|
|
|
|
IDDq mUnusedBuffers;
|
2012-03-19 14:11:01 +00:00
|
|
|
|
2012-03-19 17:33:06 +00:00
|
|
|
typedef std::map<std::string,ALuint> NameMap;
|
|
|
|
NameMap mBufferCache;
|
|
|
|
|
|
|
|
typedef std::map<ALuint,ALuint> IDRefMap;
|
|
|
|
IDRefMap mBufferRefs;
|
|
|
|
|
2012-03-19 20:19:22 +00:00
|
|
|
uint64_t mBufferCacheMemSize;
|
|
|
|
|
2012-12-18 05:50:01 +00:00
|
|
|
typedef std::vector<Sound*> SoundVec;
|
|
|
|
SoundVec mActiveSounds;
|
|
|
|
|
2012-03-19 17:33:06 +00:00
|
|
|
ALuint getBuffer(const std::string &fname);
|
|
|
|
void bufferFinished(ALuint buffer);
|
|
|
|
|
2012-03-31 17:06:12 +00:00
|
|
|
Environment mLastEnvironment;
|
|
|
|
|
2012-03-22 03:15:01 +00:00
|
|
|
virtual std::vector<std::string> enumerate();
|
2012-03-18 19:19:54 +00:00
|
|
|
virtual void init(const std::string &devname="");
|
2012-03-18 18:30:53 +00:00
|
|
|
virtual void deinit();
|
2012-03-17 05:12:17 +00:00
|
|
|
|
2013-07-26 16:43:06 +00:00
|
|
|
/// @param offset Value from [0,1] meaning from which fraction the sound the playback starts.
|
|
|
|
virtual MWBase::SoundPtr playSound(const std::string &fname, float vol, float basevol, float pitch, int flags, float offset);
|
|
|
|
/// @param offset Value from [0,1] meaning from which fraction the sound the playback starts.
|
2012-08-09 12:33:21 +00:00
|
|
|
virtual MWBase::SoundPtr playSound3D(const std::string &fname, const Ogre::Vector3 &pos,
|
2013-07-26 16:43:06 +00:00
|
|
|
float vol, float basevol, float pitch, float min, float max, int flags, float offset);
|
2012-12-13 06:32:02 +00:00
|
|
|
virtual MWBase::SoundPtr streamSound(DecoderPtr decoder, float volume, float pitch, int flags);
|
2012-03-17 09:55:08 +00:00
|
|
|
|
2012-03-31 17:06:12 +00:00
|
|
|
virtual void updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3 &atdir, const Ogre::Vector3 &updir, Environment env);
|
2012-03-17 11:22:54 +00:00
|
|
|
|
2012-12-18 12:19:35 +00:00
|
|
|
virtual void pauseSounds(int types);
|
|
|
|
virtual void resumeSounds(int types);
|
2012-12-12 10:33:12 +00:00
|
|
|
|
2012-03-24 10:49:03 +00:00
|
|
|
OpenAL_Output& operator=(const OpenAL_Output &rhs);
|
|
|
|
OpenAL_Output(const OpenAL_Output &rhs);
|
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
OpenAL_Output(SoundManager &mgr);
|
|
|
|
virtual ~OpenAL_Output();
|
|
|
|
|
2012-03-19 09:15:08 +00:00
|
|
|
class StreamThread;
|
|
|
|
std::auto_ptr<StreamThread> mStreamThread;
|
|
|
|
|
2012-03-19 14:11:01 +00:00
|
|
|
friend class OpenAL_Sound;
|
2012-03-31 08:15:27 +00:00
|
|
|
friend class OpenAL_Sound3D;
|
2012-03-19 09:15:08 +00:00
|
|
|
friend class OpenAL_SoundStream;
|
2012-03-17 05:12:17 +00:00
|
|
|
friend class SoundManager;
|
|
|
|
};
|
|
|
|
#ifndef DEFAULT_OUTPUT
|
2012-12-18 18:22:40 +00:00
|
|
|
#define DEFAULT_OUTPUT(x) ::MWSound::OpenAL_Output((x))
|
2012-03-17 05:12:17 +00:00
|
|
|
#endif
|
2012-10-09 15:10:25 +00:00
|
|
|
}
|
2012-03-17 05:12:17 +00:00
|
|
|
|
|
|
|
#endif
|