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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

125 lines
3.9 KiB
C++
Raw Normal View History

#ifndef GAME_SOUND_OPENAL_OUTPUT_H
#define GAME_SOUND_OPENAL_OUTPUT_H
2012-03-19 10:33:06 -07:00
#include <deque>
#include <map>
2023-03-02 22:58:07 +01:00
#include <mutex>
#include <string>
#include <vector>
#include "al.h"
#include "alc.h"
#include "alext.h"
#include "sound_output.hpp"
namespace MWSound
{
class SoundManager;
2022-07-03 12:51:28 +00:00
class SoundBase;
2012-03-17 02:55:08 -07:00
class Sound;
class Stream;
class OpenAL_Output : public Sound_Output
{
ALCdevice* mDevice;
ALCcontext* mContext;
struct
{
2017-09-14 04:48:12 -07:00
bool EXT_EFX : 1;
bool SOFT_HRTF : 1;
2018-09-08 19:54:22 +04:00
} ALC = { false, false };
struct
{
2017-09-14 04:48:12 -07:00
bool SOFT_source_spatialize : 1;
2018-09-08 19:54:22 +04:00
} AL = { false };
2012-03-28 05:35:51 -07:00
typedef std::deque<ALuint> IDDq;
IDDq mFreeSources;
typedef std::vector<Sound*> SoundVec;
2012-12-17 21:50:01 -08:00
SoundVec mActiveSounds;
typedef std::vector<Stream*> StreamVec;
StreamVec mActiveStreams;
2012-12-17 21:50:01 -08:00
osg::Vec3f mListenerPos;
Environment mListenerEnv;
ALuint mWaterFilter;
ALuint mWaterEffect;
ALuint mDefaultEffect;
ALuint mEffectSlot;
struct StreamThread;
std::unique_ptr<StreamThread> mStreamThread;
2023-03-02 22:58:07 +01:00
std::string mDeviceName;
std::vector<ALCint> mContextAttributes;
std::mutex mReopenMutex;
class DefaultDeviceThread;
std::unique_ptr<DefaultDeviceThread> mDefaultDeviceThread;
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);
2015-12-02 09:55:51 -08:00
2022-07-03 12:51:28 +00:00
float getTimeScaledPitch(SoundBase* sound);
OpenAL_Output& operator=(const OpenAL_Output& rhs);
OpenAL_Output(const OpenAL_Output& rhs);
2023-03-02 22:58:07 +01:00
static void eventCallback(
ALenum eventType, ALuint object, ALuint param, ALsizei length, const ALchar* message, void* userParam);
void onDisconnect();
public:
std::vector<std::string> enumerate() override;
bool init(const std::string& devname, const std::string& hrtfname, HrtfMode hrtfmode) override;
void deinit() override;
std::vector<std::string> enumerateHrtf() override;
void setHrtf(const std::string& hrtfname, HrtfMode hrtfmode) override;
std::pair<Sound_Handle, size_t> loadSound(const std::string& fname) override;
size_t unloadSound(Sound_Handle data) override;
bool playSound(Sound* sound, Sound_Handle data, float offset) override;
bool playSound3D(Sound* sound, Sound_Handle data, float offset) override;
void finishSound(Sound* sound) override;
bool isSoundPlaying(Sound* sound) override;
void updateSound(Sound* sound) override;
2022-09-22 21:26:05 +03:00
bool streamSound(DecoderPtr decoder, Stream* sound, bool getLoudnessData = false) override;
bool streamSound3D(DecoderPtr decoder, Stream* sound, bool getLoudnessData) override;
void finishStream(Stream* sound) override;
double getStreamDelay(Stream* sound) override;
double getStreamOffset(Stream* sound) override;
float getStreamLoudness(Stream* sound) override;
bool isStreamPlaying(Stream* sound) override;
void updateStream(Stream* sound) override;
2012-03-17 02:55:08 -07:00
void startUpdate() override;
void finishUpdate() override;
void updateListener(
const osg::Vec3f& pos, const osg::Vec3f& atdir, const osg::Vec3f& updir, Environment env) override;
void pauseSounds(int types) override;
void resumeSounds(int types) override;
void pauseActiveDevice() override;
void resumeActiveDevice() override;
OpenAL_Output(SoundManager& mgr);
virtual ~OpenAL_Output();
};
2012-10-09 17:10:25 +02:00
}
#endif