#pragma once #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 exit() { stop = true; } private: std::unique_ptr audioPlayer; //std::mutex audioPlayerMutex; std::mutex soundNameMutex; std::mutex musicNameMutex; std::string latestSoundName; std::string latestMusicName; std::thread worker; std::mutex mtx; std::condition_variable cv; std::queue> taskQueue; bool stop = false; void workerThread(); };