2017-10-31 17:12:50 +00:00
|
|
|
#pragma once
|
|
|
|
#ifndef ES_CORE_AUDIO_MANAGER_H
|
|
|
|
#define ES_CORE_AUDIO_MANAGER_H
|
2012-10-13 18:29:53 +00:00
|
|
|
|
2017-11-01 22:21:10 +00:00
|
|
|
#include <SDL_audio.h>
|
2013-05-14 19:31:39 +00:00
|
|
|
#include <memory>
|
2017-11-01 22:21:10 +00:00
|
|
|
#include <vector>
|
2012-10-13 18:29:53 +00:00
|
|
|
|
2017-11-01 22:21:10 +00:00
|
|
|
class Sound;
|
2013-05-14 19:31:39 +00:00
|
|
|
|
|
|
|
class AudioManager
|
2012-10-13 18:29:53 +00:00
|
|
|
{
|
2013-05-14 19:31:39 +00:00
|
|
|
static SDL_AudioSpec sAudioFormat;
|
|
|
|
static std::vector<std::shared_ptr<Sound>> sSoundVector;
|
|
|
|
static std::shared_ptr<AudioManager> sInstance;
|
|
|
|
|
|
|
|
static void mixAudio(void *unused, Uint8 *stream, int len);
|
|
|
|
|
|
|
|
AudioManager();
|
|
|
|
|
|
|
|
public:
|
2013-05-21 08:40:01 +00:00
|
|
|
static std::shared_ptr<AudioManager> & getInstance();
|
|
|
|
|
|
|
|
void init();
|
|
|
|
void deinit();
|
|
|
|
|
2013-05-22 17:11:10 +00:00
|
|
|
void registerSound(std::shared_ptr<Sound> & sound);
|
|
|
|
void unregisterSound(std::shared_ptr<Sound> & sound);
|
2012-10-13 18:29:53 +00:00
|
|
|
|
2013-05-22 17:11:10 +00:00
|
|
|
void play();
|
|
|
|
void stop();
|
2012-10-13 18:29:53 +00:00
|
|
|
|
2013-05-14 19:31:39 +00:00
|
|
|
virtual ~AudioManager();
|
|
|
|
};
|
2012-10-13 18:29:53 +00:00
|
|
|
|
2017-10-31 17:12:50 +00:00
|
|
|
#endif // ES_CORE_AUDIO_MANAGER_H
|