#pragma once #ifdef USE_OPENAL #ifdef _WIN32 #include #include #pragma comment( lib, "OpenAl32.lib" ) #elif defined(__APPLE__) #include #include #else #include #include #endif #include #include #include #include "client/sound/SoundSystem.hpp" #include #define MAX_IDLE_SOURCES 50 #define MAX_DISTANCE 16.0f class SoundSystemAL : public SoundSystem { public: SoundSystemAL(); ~SoundSystemAL(); virtual bool isAvailable(); void update(); virtual void playAt(const SoundDesc& sound, float x, float y, float z, float volume, float pitch); virtual void setListenerPos(float x, float y, float z); virtual void setListenerAngle(float yaw, float pitch); private: void delete_sources(); void delete_buffers(); ALuint get_buffer(const SoundDesc& sound); ALCdevice *device = NULL; ALCcontext *context = NULL; bool loaded = false; std::vector sources; std::vector idle_sources; std::unordered_map buffers; Vec3 lastListenerPos; }; #endif