1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00
OpenMW/apps/openmw/mwsound/openal_output.hpp

88 lines
3.0 KiB
C++
Raw Normal View History

#ifndef GAME_SOUND_OPENAL_OUTPUT_H
#define GAME_SOUND_OPENAL_OUTPUT_H
#include <string>
#include <vector>
2012-03-19 10:33:06 -07:00
#include <map>
#include <deque>
#include "alc.h"
#include "al.h"
#include "sound_output.hpp"
namespace MWSound
{
class SoundManager;
2012-03-17 02:55:08 -07:00
class Sound;
class OpenAL_Output : public Sound_Output
{
ALCdevice *mDevice;
ALCcontext *mContext;
2012-03-28 05:35:51 -07:00
typedef std::deque<ALuint> IDDq;
IDDq mFreeSources;
typedef std::vector<MWBase::SoundPtr> SoundVec;
2012-12-17 21:50:01 -08:00
SoundVec mActiveSounds;
typedef std::vector<MWBase::SoundStreamPtr> StreamVec;
StreamVec mActiveStreams;
2012-12-17 21:50:01 -08:00
osg::Vec3f mListenerPos;
Environment mListenerEnv;
struct StreamThread;
std::auto_ptr<StreamThread> mStreamThread;
2015-12-02 09:55:51 -08: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);
OpenAL_Output& operator=(const OpenAL_Output &rhs);
OpenAL_Output(const OpenAL_Output &rhs);
public:
virtual std::vector<std::string> enumerate();
2012-03-18 12:19:54 -07:00
virtual void init(const std::string &devname="");
virtual void deinit();
virtual Sound_Handle loadSound(const std::string &fname);
virtual void unloadSound(Sound_Handle data);
2015-11-23 06:52:37 -08:00
virtual size_t getSoundDataSize(Sound_Handle data) const;
virtual void playSound(MWBase::SoundPtr sound, Sound_Handle data, float offset);
virtual void playSound3D(MWBase::SoundPtr sound, Sound_Handle data, float offset);
virtual void stopSound(MWBase::SoundPtr sound);
virtual bool isSoundPlaying(MWBase::SoundPtr sound);
2015-11-30 14:34:14 -08:00
virtual void updateSound(MWBase::SoundPtr sound);
virtual void streamSound(DecoderPtr decoder, MWBase::SoundStreamPtr sound);
virtual void streamSound3D(DecoderPtr decoder, MWBase::SoundStreamPtr sound);
virtual void stopStream(MWBase::SoundStreamPtr sound);
virtual double getStreamDelay(MWBase::SoundStreamPtr sound);
virtual double getStreamOffset(MWBase::SoundStreamPtr sound);
virtual bool isStreamPlaying(MWBase::SoundStreamPtr sound);
2015-11-30 14:34:14 -08:00
virtual void updateStream(MWBase::SoundStreamPtr sound);
2012-03-17 02:55:08 -07: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);
virtual void pauseSounds(int types);
virtual void resumeSounds(int types);
virtual void loadLoudnessAsync(DecoderPtr decoder, Sound_Loudness *loudness);
OpenAL_Output(SoundManager &mgr);
virtual ~OpenAL_Output();
};
#ifndef DEFAULT_OUTPUT
2012-12-18 10:22:40 -08:00
#define DEFAULT_OUTPUT(x) ::MWSound::OpenAL_Output((x))
#endif
2012-10-09 17:10:25 +02:00
}
#endif