#pragma once #ifdef AUDIO #include #include #include #include #include #include #include "cmakeaudioplayer/include/AudioPlayer.hpp" class AudioPlayerAsync { public: AudioPlayerAsync(); ~AudioPlayerAsync(); void resetAsync(); void playSoundAsync(std::string soundName); void playMusicAsync(std::string musicName); void stopAsync(); void exit() { stop = true; } std::thread worker; private: std::unique_ptr audioPlayer; //std::mutex audioPlayerMutex; std::mutex soundNameMutex; std::mutex musicNameMutex; std::string latestSoundName; std::string latestMusicName; std::mutex mtx; std::condition_variable cv; std::queue> taskQueue; bool stop = false; void workerThread(); }; #endif