Make Audio.cpp threadsafe
Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all
Unified · Split
| @@ -1099,10 +1099,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 1098 unmodified lines | ||
| 1099 | 1099 | auto audioScriptingInterface = DependencyManager::get<AudioScriptingInterface>(); |
| 1100 | 1100 | auto myAvatarPosition = DependencyManager::get<AvatarManager>()->getMyAvatar()->getWorldPosition(); |
| 1101 | 1101 | float distance = glm::distance(myAvatarPosition, position); |
| 1102 | − bool shouldMute = !audioClient->isMuted() && (distance < radius); | |
| 1103 | 1102 | |
| 1104 | − if (shouldMute) { | |
| 1105 | − audioClient->toggleMute(); | |
| 1103 | + if (distance < radius) { | |
| 1104 | + audioClient->setMuted(true); | |
| 1106 | 1105 | audioScriptingInterface->environmentMuted(); |
| 1107 | 1106 | } |
| 1108 | 1107 | }); |
| @@ -1527,7 +1526,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 418 unmodified lines | ||
| 1527 | 1526 | |
| 1528 | 1527 | if (state) { |
| 1529 | 1528 | if (action == controller::toInt(controller::Action::TOGGLE_MUTE)) { |
| 1530 | − DependencyManager::get<AudioClient>()->toggleMute(); | |
| 1529 | + auto audioClient = DependencyManager::get<AudioClient>(); | |
| 1530 | + audioClient->setMuted(!audioClient->isMuted()); | |
| 1531 | 1531 | } else if (action == controller::toInt(controller::Action::CYCLE_CAMERA)) { |
| 1532 | 1532 | cycleCamera(); |
| 1533 | 1533 | } else if (action == controller::toInt(controller::Action::CONTEXT_MENU)) { |
| @@ -3465,7 +3465,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 1931 unmodified lines | ||
| 3465 | 3465 | |
| 3466 | 3466 | case Qt::Key_M: |
| 3467 | 3467 | if (isMeta) { |
| 3468 | − DependencyManager::get<AudioClient>()->toggleMute(); | |
| 3468 | + auto audioClient = DependencyManager::get<AudioClient>(); | |
| 3469 | + audioClient->setMuted(!audioClient->isMuted()); | |
| 3469 | 3470 | } |
| 3470 | 3471 | break; |
| 3471 | 3472 | |
| @@ -5120,7 +5121,7 @@ void Application::update(float deltaTime) { · 1648 unmodified lines | ||
| 5120 | 5121 | if (menu->isOptionChecked(MenuOption::AutoMuteAudio) && !audioClient->isMuted()) { |
| 5121 | 5122 | if (_lastFaceTrackerUpdate > 0 |
| 5122 | 5123 | && ((usecTimestampNow() - _lastFaceTrackerUpdate) > MUTE_MICROPHONE_AFTER_USECS)) { |
| 5123 | − audioClient->toggleMute(); | |
| 5124 | + audioClient->setMuted(true); | |
| 5124 | 5125 | _lastFaceTrackerUpdate = 0; |
| 5125 | 5126 | } |
| 5126 | 5127 | } else { |