2012-03-16 22:12:17 -07:00
|
|
|
#ifndef GAME_SOUND_OPENAL_OUTPUT_H
|
|
|
|
#define GAME_SOUND_OPENAL_OUTPUT_H
|
|
|
|
|
2012-03-16 23:40:07 -07:00
|
|
|
#include <string>
|
2012-03-19 07:11:01 -07:00
|
|
|
#include <vector>
|
2012-03-19 10:33:06 -07:00
|
|
|
#include <map>
|
|
|
|
#include <deque>
|
2012-03-16 22:12:17 -07:00
|
|
|
|
|
|
|
#include "alc.h"
|
|
|
|
#include "al.h"
|
|
|
|
|
2012-03-16 23:40:07 -07:00
|
|
|
#include "sound_output.hpp"
|
|
|
|
|
2012-03-16 22:12:17 -07:00
|
|
|
namespace MWSound
|
|
|
|
{
|
2012-03-16 23:40:07 -07:00
|
|
|
class SoundManager;
|
2012-03-17 02:55:08 -07:00
|
|
|
class Sound;
|
2012-03-16 23:40:07 -07:00
|
|
|
|
2012-03-16 22:12:17 -07:00
|
|
|
class OpenAL_Output : public Sound_Output
|
|
|
|
{
|
2012-03-18 11:30:53 -07:00
|
|
|
ALCdevice *mDevice;
|
|
|
|
ALCcontext *mContext;
|
2012-03-16 22:12:17 -07:00
|
|
|
|
2012-03-28 05:35:51 -07:00
|
|
|
typedef std::deque<ALuint> IDDq;
|
|
|
|
IDDq mFreeSources;
|
2012-03-19 13:19:22 -07:00
|
|
|
|
2015-11-30 05:42:51 -08:00
|
|
|
typedef std::vector<MWBase::SoundPtr> SoundVec;
|
2012-12-17 21:50:01 -08:00
|
|
|
SoundVec mActiveSounds;
|
2015-11-30 07:32:42 -08:00
|
|
|
typedef std::vector<MWBase::SoundStreamPtr> StreamVec;
|
2015-11-23 07:51:52 -08:00
|
|
|
StreamVec mActiveStreams;
|
2012-12-17 21:50:01 -08:00
|
|
|
|
2012-03-31 10:06:12 -07:00
|
|
|
Environment mLastEnvironment;
|
|
|
|
|
2012-03-21 20:15:01 -07:00
|
|
|
virtual std::vector<std::string> enumerate();
|
2012-03-18 12:19:54 -07:00
|
|
|
virtual void init(const std::string &devname="");
|
2012-03-18 11:30:53 -07:00
|
|
|
virtual void deinit();
|
2012-03-16 22:12:17 -07:00
|
|
|
|
2015-11-23 20:13:24 -08:00
|
|
|
virtual Sound_Handle loadSound(const std::string &fname);
|
2015-11-23 01:01:20 -08:00
|
|
|
virtual void unloadSound(Sound_Handle data);
|
2015-11-23 06:52:37 -08:00
|
|
|
virtual size_t getSoundDataSize(Sound_Handle data) const;
|
2015-11-23 01:01:20 -08:00
|
|
|
|
|
|
|
virtual MWBase::SoundPtr playSound(Sound_Handle data, float vol, float basevol, float pitch, int flags, float offset);
|
|
|
|
virtual MWBase::SoundPtr playSound3D(Sound_Handle data, const osg::Vec3f &pos,
|
|
|
|
float vol, float basevol, float pitch, float min, float max, int flags, float offset);
|
2015-11-30 05:42:51 -08:00
|
|
|
virtual void stopSound(MWBase::SoundPtr sound);
|
|
|
|
virtual bool isSoundPlaying(MWBase::SoundPtr sound);
|
|
|
|
|
2015-11-30 07:32:42 -08:00
|
|
|
virtual MWBase::SoundStreamPtr streamSound(DecoderPtr decoder, float basevol, float pitch, int flags);
|
|
|
|
virtual MWBase::SoundStreamPtr streamSound3D(DecoderPtr decoder, const osg::Vec3f &pos,
|
|
|
|
float vol, float basevol, float pitch, float min, float max, int flags);
|
|
|
|
virtual void stopStream(MWBase::SoundStreamPtr sound);
|
|
|
|
virtual double getStreamDelay(MWBase::SoundStreamPtr sound);
|
|
|
|
virtual double getStreamOffset(MWBase::SoundStreamPtr sound);
|
|
|
|
virtual bool isStreamPlaying(MWBase::SoundStreamPtr sound);
|
2012-03-17 02:55:08 -07:00
|
|
|
|
2015-11-24 20:37:38 -08:00
|
|
|
virtual void startUpdate();
|
|
|
|
virtual void finishUpdate();
|
|
|
|
|
2015-05-12 19:02:56 +02:00
|
|
|
virtual void updateListener(const osg::Vec3f &pos, const osg::Vec3f &atdir, const osg::Vec3f &updir, Environment env);
|
2012-03-17 04:22:54 -07:00
|
|
|
|
2012-12-18 04:19:35 -08:00
|
|
|
virtual void pauseSounds(int types);
|
|
|
|
virtual void resumeSounds(int types);
|
2012-12-12 02:33:12 -08:00
|
|
|
|
2015-11-27 09:47:14 -08:00
|
|
|
virtual void loadLoudnessAsync(DecoderPtr decoder, Sound_Loudness *loudness);
|
|
|
|
|
2012-03-24 03:49:03 -07:00
|
|
|
OpenAL_Output& operator=(const OpenAL_Output &rhs);
|
|
|
|
OpenAL_Output(const OpenAL_Output &rhs);
|
|
|
|
|
2012-03-16 22:12:17 -07:00
|
|
|
OpenAL_Output(SoundManager &mgr);
|
|
|
|
virtual ~OpenAL_Output();
|
|
|
|
|
2015-03-06 21:36:42 +13:00
|
|
|
struct StreamThread;
|
2012-03-19 02:15:08 -07:00
|
|
|
std::auto_ptr<StreamThread> mStreamThread;
|
|
|
|
|
2012-03-19 07:11:01 -07:00
|
|
|
friend class OpenAL_Sound;
|
2012-03-31 01:15:27 -07:00
|
|
|
friend class OpenAL_Sound3D;
|
2012-03-19 02:15:08 -07:00
|
|
|
friend class OpenAL_SoundStream;
|
2015-11-23 19:41:57 -08:00
|
|
|
friend class OpenAL_SoundStream3D;
|
2012-03-16 22:12:17 -07:00
|
|
|
friend class SoundManager;
|
|
|
|
};
|
|
|
|
#ifndef DEFAULT_OUTPUT
|
2012-12-18 10:22:40 -08:00
|
|
|
#define DEFAULT_OUTPUT(x) ::MWSound::OpenAL_Output((x))
|
2012-03-16 22:12:17 -07:00
|
|
|
#endif
|
2012-10-09 17:10:25 +02:00
|
|
|
}
|
2012-03-16 22:12:17 -07:00
|
|
|
|
|
|
|
#endif
|