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