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-19 14:11:01 +00:00
|
|
|
typedef std::vector<ALuint> IDVec;
|
|
|
|
IDVec mFreeSources;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
typedef std::deque<ALuint> IDDq;
|
|
|
|
IDDq mUnusedBuffers;
|
|
|
|
|
2012-03-19 20:19:22 +00:00
|
|
|
uint64_t mBufferCacheMemSize;
|
|
|
|
|
2012-03-19 17:33:06 +00:00
|
|
|
ALuint getBuffer(const std::string &fname);
|
|
|
|
void bufferFinished(ALuint buffer);
|
|
|
|
|
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
|
|
|
|
2012-03-27 12:59:09 +00:00
|
|
|
virtual SoundPtr playSound(const std::string &fname, float volume, float pitch, bool loop);
|
|
|
|
virtual SoundPtr playSound3D(const std::string &fname, const float *pos, float volume, float pitch,
|
|
|
|
float min, float max, bool loop);
|
2012-03-17 13:51:44 +00:00
|
|
|
|
2012-03-27 12:59:09 +00:00
|
|
|
virtual SoundPtr streamSound(const std::string &fname, float volume, float pitch);
|
|
|
|
virtual SoundPtr streamSound3D(const std::string &fname, const float *pos, float volume, float pitch,
|
|
|
|
float min, float max);
|
2012-03-17 09:55:08 +00:00
|
|
|
|
2012-03-18 18:30:53 +00:00
|
|
|
virtual void updateListener(const float *pos, const float *atdir, const float *updir);
|
2012-03-17 11:22:54 +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-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-03-23 01:44:55 +00:00
|
|
|
#define DEFAULT_OUTPUT (::MWSound::OpenAL_Output)
|
2012-03-17 05:12:17 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|