From 5baf2f21d84d5d3a481242e5800ad97ac2b1afad Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 18 Apr 2019 07:48:59 -0700 Subject: [PATCH 1/6] adding settingsLoaded bool check --- interface/src/scripting/Audio.cpp | 5 +++-- interface/src/scripting/Audio.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/interface/src/scripting/Audio.cpp b/interface/src/scripting/Audio.cpp index caae946116..0a29152c7c 100644 --- a/interface/src/scripting/Audio.cpp +++ b/interface/src/scripting/Audio.cpp @@ -174,7 +174,7 @@ void Audio::setPTTDesktop(bool enabled) { _pttDesktop = enabled; } }); - if (!enabled) { + if (!enabled && _settingsLoaded) { // Set to default behavior (unmuted for Desktop) on Push-To-Talk disable. setMutedDesktop(true); } else { @@ -202,7 +202,7 @@ void Audio::setPTTHMD(bool enabled) { _pttHMD = enabled; } }); - if (!enabled) { + if (!enabled && _settingsLoaded) { // Set to default behavior (unmuted for HMD) on Push-To-Talk disable. setMutedHMD(false); } else { @@ -231,6 +231,7 @@ void Audio::loadData() { auto client = DependencyManager::get().data(); QMetaObject::invokeMethod(client, "setMuted", Q_ARG(bool, isMuted()), Q_ARG(bool, false)); + _settingsLoaded = true; } bool Audio::getPTTHMD() const { diff --git a/interface/src/scripting/Audio.h b/interface/src/scripting/Audio.h index 00da566b30..f7116ced3a 100644 --- a/interface/src/scripting/Audio.h +++ b/interface/src/scripting/Audio.h @@ -409,6 +409,7 @@ protected: private: + bool _settingsLoaded { false }; float _inputVolume { 1.0f }; float _inputLevel { 0.0f }; float _localInjectorGain { 0.0f }; // in dB From da8f8e0873e9371212e36694798b87bdd9a529fe Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 18 Apr 2019 14:46:08 -0700 Subject: [PATCH 2/6] real fix --- interface/src/scripting/Audio.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/interface/src/scripting/Audio.cpp b/interface/src/scripting/Audio.cpp index 0a29152c7c..ce340f2665 100644 --- a/interface/src/scripting/Audio.cpp +++ b/interface/src/scripting/Audio.cpp @@ -174,9 +174,11 @@ void Audio::setPTTDesktop(bool enabled) { _pttDesktop = enabled; } }); - if (!enabled && _settingsLoaded) { - // Set to default behavior (unmuted for Desktop) on Push-To-Talk disable. - setMutedDesktop(true); + if (!enabled) { + if (_settingsLoaded) { + // Set to default behavior (unmuted for Desktop) on Push-To-Talk disable. + setMutedDesktop(true); + } } else { // Should be muted when not pushing to talk while PTT is enabled. setMutedDesktop(true); @@ -202,9 +204,11 @@ void Audio::setPTTHMD(bool enabled) { _pttHMD = enabled; } }); - if (!enabled && _settingsLoaded) { - // Set to default behavior (unmuted for HMD) on Push-To-Talk disable. - setMutedHMD(false); + if (!enabled) { + if (_settingsLoaded) { + // Set to default behavior (unmuted for HMD) on Push-To-Talk disable. + setMutedHMD(false); + } } else { // Should be muted when not pushing to talk while PTT is enabled. setMutedHMD(true); @@ -358,11 +362,6 @@ void Audio::onContextChanged() { changed = true; } }); - if (isHMD) { - setMuted(getMutedHMD()); - } else { - setMuted(getMutedDesktop()); - } if (changed) { emit contextChanged(isHMD ? Audio::HMD : Audio::DESKTOP); } From 9065a032bde58b816aa688c594b7e7f2af152a76 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 18 Apr 2019 14:46:08 -0700 Subject: [PATCH 3/6] real fix From 38115b0c09461fe7b1f8572c070dc72fc9df653a Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 18 Apr 2019 21:00:15 -0700 Subject: [PATCH 4/6] simplify PTT logic --- interface/src/scripting/Audio.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/interface/src/scripting/Audio.cpp b/interface/src/scripting/Audio.cpp index ce340f2665..bceafc3c42 100644 --- a/interface/src/scripting/Audio.cpp +++ b/interface/src/scripting/Audio.cpp @@ -174,16 +174,10 @@ void Audio::setPTTDesktop(bool enabled) { _pttDesktop = enabled; } }); - if (!enabled) { - if (_settingsLoaded) { - // Set to default behavior (unmuted for Desktop) on Push-To-Talk disable. - setMutedDesktop(true); - } - } else { - // Should be muted when not pushing to talk while PTT is enabled. + if (enabled || _settingsLoaded) { + // Set to default behavior (muted for Desktop) on Push-To-Talk disable or when enabled. Settings also need to be loaded. setMutedDesktop(true); } - if (changed) { emit pushToTalkChanged(enabled); emit pushToTalkDesktopChanged(enabled); @@ -204,14 +198,9 @@ void Audio::setPTTHMD(bool enabled) { _pttHMD = enabled; } }); - if (!enabled) { - if (_settingsLoaded) { - // Set to default behavior (unmuted for HMD) on Push-To-Talk disable. - setMutedHMD(false); - } - } else { - // Should be muted when not pushing to talk while PTT is enabled. - setMutedHMD(true); + if (enabled || _settingsLoaded) { + // Set to default behavior (unmuted for HMD) on Push-To-Talk disable or muted for when PTT is enabled. + setMutedHMD(enabled); } if (changed) { From 55f3c3a11a6e5176588a69959f3e137c3dcd7501 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 19 Apr 2019 18:21:31 -0700 Subject: [PATCH 5/6] allowing context change to change mute state --- interface/src/scripting/Audio.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/interface/src/scripting/Audio.cpp b/interface/src/scripting/Audio.cpp index bceafc3c42..5dd1488606 100644 --- a/interface/src/scripting/Audio.cpp +++ b/interface/src/scripting/Audio.cpp @@ -351,6 +351,13 @@ void Audio::onContextChanged() { changed = true; } }); + if (_settingsLoaded) { + if (isHMD) { + setMuted(getMutedHMD()); + } else { + setMuted(getMutedDesktop()); + } + } if (changed) { emit contextChanged(isHMD ? Audio::HMD : Audio::DESKTOP); } From ad22af1379781f2bece4f4a6d5a8a861d2c7015a Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 22 Apr 2019 19:08:15 -0700 Subject: [PATCH 6/6] set AudioClient mute state as catch-all --- interface/src/scripting/Audio.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/interface/src/scripting/Audio.cpp b/interface/src/scripting/Audio.cpp index 5dd1488606..b406c097e7 100644 --- a/interface/src/scripting/Audio.cpp +++ b/interface/src/scripting/Audio.cpp @@ -352,11 +352,11 @@ void Audio::onContextChanged() { } }); if (_settingsLoaded) { - if (isHMD) { - setMuted(getMutedHMD()); - } else { - setMuted(getMutedDesktop()); - } + bool isMuted = isHMD ? getMutedHMD() : getMutedDesktop(); + setMuted(isMuted); + // always set audio client muted state on context changed - sometimes setMuted does not catch it. + auto client = DependencyManager::get().data(); + QMetaObject::invokeMethod(client, "setMuted", Q_ARG(bool, isMuted), Q_ARG(bool, false)); } if (changed) { emit contextChanged(isHMD ? Audio::HMD : Audio::DESKTOP);