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;
|
2012-03-19 20:19:22 +00:00
|
|
|
|
2015-11-30 13:42:51 +00:00
|
|
|
typedef std::vector<MWBase::SoundPtr> SoundVec;
|
2012-12-18 05:50:01 +00:00
|
|
|
SoundVec mActiveSounds;
|
2015-11-30 15:32:42 +00:00
|
|
|
typedef std::vector<MWBase::SoundStreamPtr> StreamVec;
|
2015-11-23 15:51:52 +00:00
|
|
|
StreamVec mActiveStreams;
|
2012-12-18 05:50:01 +00:00
|
|
|
|
2015-11-30 16:00:02 +00:00
|
|
|
osg::Vec3f mListenerPos;
|
|
|
|
Environment mListenerEnv;
|
2012-03-31 17:06:12 +00:00
|
|
|
|
2015-11-30 16:00:02 +00:00
|
|
|
struct StreamThread;
|
|
|
|
std::auto_ptr<StreamThread> mStreamThread;
|
|
|
|
|
2015-12-02 17:55:51 +00:00
|
|
|
void initCommon2D(ALuint source, const osg::Vec3f &pos, ALfloat gain, ALfloat pitch, bool loop, bool useenv);
|
|
|
|
void initCommon3D(ALuint source, const osg::Vec3f &pos, ALfloat mindist, ALfloat maxdist, ALfloat gain, ALfloat pitch, bool loop, bool useenv);
|
|
|
|
|
|
|
|
void updateCommon(ALuint source, const osg::Vec3f &pos, ALfloat maxdist, ALfloat gain, ALfloat pitch, bool useenv, bool is3d);
|
|
|
|
|
2015-11-30 16:00:02 +00:00
|
|
|
OpenAL_Output& operator=(const OpenAL_Output &rhs);
|
|
|
|
OpenAL_Output(const OpenAL_Output &rhs);
|
|
|
|
|
|
|
|
public:
|
2012-03-22 03:15:01 +00:00
|
|
|
virtual std::vector<std::string> enumerate();
|
2015-12-04 20:54:41 +00:00
|
|
|
virtual void init(const std::string &devname=std::string());
|
2012-03-18 18:30:53 +00:00
|
|
|
virtual void deinit();
|
2012-03-17 05:12:17 +00:00
|
|
|
|
2015-12-04 20:54:41 +00:00
|
|
|
virtual std::vector<std::string> enumerateHrtf();
|
|
|
|
virtual void enableHrtf(const std::string &hrtfname, bool auto_enable);
|
|
|
|
virtual void disableHrtf();
|
|
|
|
|
2015-11-24 04:13:24 +00:00
|
|
|
virtual Sound_Handle loadSound(const std::string &fname);
|
2015-11-23 09:01:20 +00:00
|
|
|
virtual void unloadSound(Sound_Handle data);
|
2015-11-23 14:52:37 +00:00
|
|
|
virtual size_t getSoundDataSize(Sound_Handle data) const;
|
2015-11-23 09:01:20 +00:00
|
|
|
|
2015-12-02 14:35:35 +00:00
|
|
|
virtual void playSound(MWBase::SoundPtr sound, Sound_Handle data, float offset);
|
|
|
|
virtual void playSound3D(MWBase::SoundPtr sound, Sound_Handle data, float offset);
|
2015-12-11 23:13:14 +00:00
|
|
|
virtual void finishSound(MWBase::SoundPtr sound);
|
2015-11-30 13:42:51 +00:00
|
|
|
virtual bool isSoundPlaying(MWBase::SoundPtr sound);
|
2015-11-30 22:34:14 +00:00
|
|
|
virtual void updateSound(MWBase::SoundPtr sound);
|
2015-11-30 13:42:51 +00:00
|
|
|
|
2015-12-02 16:04:30 +00:00
|
|
|
virtual void streamSound(DecoderPtr decoder, MWBase::SoundStreamPtr sound);
|
2016-06-27 19:37:02 +00:00
|
|
|
virtual void streamSound3D(DecoderPtr decoder, MWBase::SoundStreamPtr sound, bool getLoudnessData);
|
2015-12-11 23:13:14 +00:00
|
|
|
virtual void finishStream(MWBase::SoundStreamPtr sound);
|
2015-11-30 15:32:42 +00:00
|
|
|
virtual double getStreamDelay(MWBase::SoundStreamPtr sound);
|
|
|
|
virtual double getStreamOffset(MWBase::SoundStreamPtr sound);
|
2016-06-27 18:54:42 +00:00
|
|
|
virtual float getStreamLoudness(MWBase::SoundStreamPtr sound);
|
2015-11-30 15:32:42 +00:00
|
|
|
virtual bool isStreamPlaying(MWBase::SoundStreamPtr sound);
|
2015-11-30 22:34:14 +00:00
|
|
|
virtual void updateStream(MWBase::SoundStreamPtr sound);
|
2012-03-17 09:55:08 +00:00
|
|
|
|
2015-11-25 04:37:38 +00:00
|
|
|
virtual void startUpdate();
|
|
|
|
virtual void finishUpdate();
|
|
|
|
|
2015-05-12 17:02:56 +00:00
|
|
|
virtual void updateListener(const osg::Vec3f &pos, const osg::Vec3f &atdir, const osg::Vec3f &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-17 05:12:17 +00:00
|
|
|
OpenAL_Output(SoundManager &mgr);
|
|
|
|
virtual ~OpenAL_Output();
|
|
|
|
};
|
|
|
|
#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
|