1 #pragma once 2 #ifndef ES_CORE_AUDIO_MANAGER_H 3 #define ES_CORE_AUDIO_MANAGER_H 4 5 #include <SDL_audio.h> 6 #include <memory> 7 #include <vector> 8 9 class Sound; 10 11 class AudioManager 12 { 13 static SDL_AudioSpec sAudioFormat; 14 static std::vector<std::shared_ptr<Sound>> sSoundVector; 15 static std::shared_ptr<AudioManager> sInstance; 16 17 static void mixAudio(void *unused, Uint8 *stream, int len); 18 19 AudioManager(); 20 21 public: 22 static std::shared_ptr<AudioManager> & getInstance(); 23 24 void init(); 25 void deinit(); 26 27 void registerSound(std::shared_ptr<Sound> & sound); 28 void unregisterSound(std::shared_ptr<Sound> & sound); 29 30 void play(); 31 void stop(); 32 33 virtual ~AudioManager(); 34 }; 35 36 #endif // ES_CORE_AUDIO_MANAGER_H 37