#ifndef _H_AUDIO_ENGINE_H
#define _H_AUDIO_ENGINE_H

#include <AL/al.h>
#include <AL/alc.h>
#include <memory>
#include <glm/glm.hpp>

#include "utility/events.h"
#include "sound/audiostream.h"
#include "sound/soundmanager.h"
#include "utility/resourcemanager.h"
#include "utility/logger.h"

class AudioEngine : public std::enable_shared_from_this<AudioEngine>
{
public:
	AudioEngine(std::weak_ptr<ResourceManager> _resource);

	void hookEventManager(std::weak_ptr<EventManager> _events);
	void hookSceneManager(std::weak_ptr<EventManager> _events);
	void pushMusic(std::string _songName);
	void playMusic();
	void pauseMusic();
	void killMusic();

	void poll();
	void updateListener(const glm::vec3& pos);

	~AudioEngine();
private:
	std::unique_ptr<AudioStream> musicPlayer;
	std::unique_ptr<SoundManager> soundManager;
	std::weak_ptr<EventManager> globalEventManager;
	std::weak_ptr<EventManager> sceneEventManager;
	std::weak_ptr<ResourceManager> resourceManager;
	ALCdevice *device;
	ALCcontext *context;
};


#endif // _H_AUDIO_ENGINE_H
