Working with music
This commit is contained in:
parent
b3efd62229
commit
01e6b0e355
@ -12,12 +12,24 @@ AudioPlayerAsync::~AudioPlayerAsync() {
|
||||
worker.join();
|
||||
}
|
||||
|
||||
void AudioPlayerAsync::stopAsync() {
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
taskQueue.push([this]() {
|
||||
//audioPlayerMutex.lock();
|
||||
audioPlayer->stop();
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
//audioPlayerMutex.unlock();
|
||||
});
|
||||
cv.notify_one();
|
||||
}
|
||||
|
||||
void AudioPlayerAsync::resetAsync() {
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
taskQueue.push([this]() {
|
||||
//audioPlayerMutex.lock();
|
||||
audioPlayer.reset();
|
||||
audioPlayer = std::make_unique<AudioPlayer>();
|
||||
|
||||
//audioPlayerMutex.unlock();
|
||||
});
|
||||
cv.notify_one();
|
||||
|
||||
@ -18,6 +18,8 @@ public:
|
||||
|
||||
void playMusicAsync(std::string musicName);
|
||||
|
||||
void stopAsync();
|
||||
|
||||
void exit()
|
||||
{
|
||||
stop = true;
|
||||
|
||||
@ -28,7 +28,8 @@ void GameObjectManager::initialize() {
|
||||
testObjMeshMutable.data = testObjMesh;
|
||||
testObjMeshMutable.RefreshVBO();
|
||||
|
||||
textMesh = ZL::LoadFromTextFile("./textures/mesh_first_room.txt");
|
||||
//textMesh = ZL::LoadFromTextFile("./textures/mesh_first_room.txt");
|
||||
textMesh = ZL::LoadFromTextFile("./oneroom001.txt");
|
||||
textMesh.Scale(10);
|
||||
textMesh.SwapZandY();
|
||||
textMesh.RotateByMatrix(QuatToMatrix(QuatFromRotateAroundX(M_PI * 0.5)));
|
||||
@ -82,7 +83,7 @@ void GameObjectManager::initialize() {
|
||||
|
||||
|
||||
Room room_1;
|
||||
room_1.roomTexture = std::make_shared<Texture>(CreateTextureDataFromBmp24("./Kitchen_ceramics.bmp"));
|
||||
room_1.roomTexture = std::make_shared<Texture>(CreateTextureDataFromBmp24("./Material_Base_color_1001.bmp"));
|
||||
room_1.objects.push_back(ao1);
|
||||
room_1.sound_name = "Symphony No.6 (1st movement).ogg";
|
||||
room_1.roomLogic = createRoom1Logic();
|
||||
@ -140,6 +141,7 @@ void GameObjectManager::switch_room(int index){
|
||||
if (audioPlayer) {
|
||||
audioPlayer->playMusic(rooms[current_room_index].sound_name);
|
||||
}*/
|
||||
audioPlayerAsync.stopAsync();
|
||||
audioPlayerAsync.resetAsync();
|
||||
audioPlayerAsync.playMusicAsync(rooms[current_room_index].sound_name);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user