mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 13:59:13 +02:00
laying groundwork for audio app + fixing deadlocks
This commit is contained in:
parent
d88235a08f
commit
8b4123b5dc
4 changed files with 69 additions and 57 deletions
|
@ -134,7 +134,7 @@ Rectangle {
|
||||||
Item {
|
Item {
|
||||||
id: status;
|
id: status;
|
||||||
|
|
||||||
readonly property string color: (AudioScriptingInterface.pushingToTalk && AudioScriptingInterface.muted) ? hifi.colors.blueHighlight : AudioScriptingInterface.muted ? colors.muted : colors.unmuted;
|
readonly property string color: AudioScriptingInterface.pushToTalk ? hifi.colors.blueHighlight : AudioScriptingInterface.muted ? colors.muted : colors.unmuted;
|
||||||
|
|
||||||
visible: AudioScriptingInterface.pushingToTalk || AudioScriptingInterface.muted;
|
visible: AudioScriptingInterface.pushingToTalk || AudioScriptingInterface.muted;
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ Rectangle {
|
||||||
verticalCenter: parent.verticalCenter;
|
verticalCenter: parent.verticalCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
width: 50;
|
width: AudioScriptingInterface.pushToTalk ? (AudioScriptingInterface.pushingToTalk ? 45: 30) : 50;
|
||||||
height: 4;
|
height: 4;
|
||||||
color: parent.color;
|
color: parent.color;
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ Rectangle {
|
||||||
verticalCenter: parent.verticalCenter;
|
verticalCenter: parent.verticalCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
width: 50;
|
width: AudioScriptingInterface.pushToTalk ? (AudioScriptingInterface.pushingToTalk ? 45: 30) : 50;
|
||||||
height: 4;
|
height: 4;
|
||||||
color: parent.color;
|
color: parent.color;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,32 +66,30 @@ bool Audio::isMuted() const {
|
||||||
bool isHMD = qApp->isHMDMode();
|
bool isHMD = qApp->isHMDMode();
|
||||||
if (isHMD) {
|
if (isHMD) {
|
||||||
return getMutedHMD();
|
return getMutedHMD();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return getMutedDesktop();
|
return getMutedDesktop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::setMuted(bool isMuted) {
|
void Audio::setMuted(bool isMuted) {
|
||||||
withWriteLock([&] {
|
bool isHMD = qApp->isHMDMode();
|
||||||
bool isHMD = qApp->isHMDMode();
|
if (isHMD) {
|
||||||
if (isHMD) {
|
setMutedHMD(isMuted);
|
||||||
setMutedHMD(isMuted);
|
} else {
|
||||||
}
|
setMutedDesktop(isMuted);
|
||||||
else {
|
}
|
||||||
setMutedDesktop(isMuted);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::setMutedDesktop(bool isMuted) {
|
void Audio::setMutedDesktop(bool isMuted) {
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
if (_desktopMuted != isMuted) {
|
withWriteLock([&] {
|
||||||
changed = true;
|
if (_desktopMuted != isMuted) {
|
||||||
_desktopMuted = isMuted;
|
changed = true;
|
||||||
auto client = DependencyManager::get<AudioClient>().data();
|
_desktopMuted = isMuted;
|
||||||
QMetaObject::invokeMethod(client, "setMuted", Q_ARG(bool, isMuted), Q_ARG(bool, false));
|
auto client = DependencyManager::get<AudioClient>().data();
|
||||||
}
|
QMetaObject::invokeMethod(client, "setMuted", Q_ARG(bool, isMuted), Q_ARG(bool, false));
|
||||||
|
}
|
||||||
|
});
|
||||||
if (changed) {
|
if (changed) {
|
||||||
emit mutedChanged(isMuted);
|
emit mutedChanged(isMuted);
|
||||||
emit desktopMutedChanged(isMuted);
|
emit desktopMutedChanged(isMuted);
|
||||||
|
@ -106,12 +104,14 @@ bool Audio::getMutedDesktop() const {
|
||||||
|
|
||||||
void Audio::setMutedHMD(bool isMuted) {
|
void Audio::setMutedHMD(bool isMuted) {
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
if (_hmdMuted != isMuted) {
|
withWriteLock([&] {
|
||||||
changed = true;
|
if (_hmdMuted != isMuted) {
|
||||||
_hmdMuted = isMuted;
|
changed = true;
|
||||||
auto client = DependencyManager::get<AudioClient>().data();
|
_hmdMuted = isMuted;
|
||||||
QMetaObject::invokeMethod(client, "setMuted", Q_ARG(bool, isMuted), Q_ARG(bool, false));
|
auto client = DependencyManager::get<AudioClient>().data();
|
||||||
}
|
QMetaObject::invokeMethod(client, "setMuted", Q_ARG(bool, isMuted), Q_ARG(bool, false));
|
||||||
|
}
|
||||||
|
});
|
||||||
if (changed) {
|
if (changed) {
|
||||||
emit mutedChanged(isMuted);
|
emit mutedChanged(isMuted);
|
||||||
emit hmdMutedChanged(isMuted);
|
emit hmdMutedChanged(isMuted);
|
||||||
|
@ -128,12 +128,24 @@ bool Audio::getPTT() {
|
||||||
bool isHMD = qApp->isHMDMode();
|
bool isHMD = qApp->isHMDMode();
|
||||||
if (isHMD) {
|
if (isHMD) {
|
||||||
return getPTTHMD();
|
return getPTTHMD();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return getPTTDesktop();
|
return getPTTDesktop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void scripting::Audio::setPushingToTalk(bool pushingToTalk) {
|
||||||
|
bool changed = false;
|
||||||
|
withWriteLock([&] {
|
||||||
|
if (_pushingToTalk != pushingToTalk) {
|
||||||
|
changed = true;
|
||||||
|
_pushingToTalk = pushingToTalk;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (changed) {
|
||||||
|
emit pushingToTalkChanged(pushingToTalk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Audio::getPushingToTalk() const {
|
bool Audio::getPushingToTalk() const {
|
||||||
return resultWithReadLock<bool>([&] {
|
return resultWithReadLock<bool>([&] {
|
||||||
return _pushingToTalk;
|
return _pushingToTalk;
|
||||||
|
@ -144,8 +156,7 @@ void Audio::setPTT(bool enabled) {
|
||||||
bool isHMD = qApp->isHMDMode();
|
bool isHMD = qApp->isHMDMode();
|
||||||
if (isHMD) {
|
if (isHMD) {
|
||||||
setPTTHMD(enabled);
|
setPTTHMD(enabled);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
setPTTDesktop(enabled);
|
setPTTDesktop(enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,16 +167,16 @@ void Audio::setPTTDesktop(bool enabled) {
|
||||||
if (_pttDesktop != enabled) {
|
if (_pttDesktop != enabled) {
|
||||||
changed = true;
|
changed = true;
|
||||||
_pttDesktop = enabled;
|
_pttDesktop = enabled;
|
||||||
if (!enabled) {
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (!enabled) {
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
emit pushToTalkChanged(enabled);
|
emit pushToTalkChanged(enabled);
|
||||||
emit pushToTalkDesktopChanged(enabled);
|
emit pushToTalkDesktopChanged(enabled);
|
||||||
|
@ -184,16 +195,16 @@ void Audio::setPTTHMD(bool enabled) {
|
||||||
if (_pttHMD != enabled) {
|
if (_pttHMD != enabled) {
|
||||||
changed = true;
|
changed = true;
|
||||||
_pttHMD = enabled;
|
_pttHMD = enabled;
|
||||||
if (!enabled) {
|
|
||||||
// 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) {
|
||||||
|
// 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 (changed) {
|
if (changed) {
|
||||||
emit pushToTalkChanged(enabled);
|
emit pushToTalkChanged(enabled);
|
||||||
emit pushToTalkHMDChanged(enabled);
|
emit pushToTalkHMDChanged(enabled);
|
||||||
|
@ -318,8 +329,7 @@ void Audio::onContextChanged() {
|
||||||
});
|
});
|
||||||
if (isHMD) {
|
if (isHMD) {
|
||||||
setMuted(getMutedHMD());
|
setMuted(getMutedHMD());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
setMuted(getMutedDesktop());
|
setMuted(getMutedDesktop());
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
@ -331,14 +341,10 @@ void Audio::handlePushedToTalk(bool enabled) {
|
||||||
if (getPTT()) {
|
if (getPTT()) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
setMuted(false);
|
setMuted(false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
setMuted(true);
|
setMuted(true);
|
||||||
}
|
}
|
||||||
if (_pushingToTalk != enabled) {
|
setPushingToTalk(enabled);
|
||||||
_pushingToTalk = enabled;
|
|
||||||
emit pushingToTalkChanged(enabled);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,7 @@ public:
|
||||||
bool getMutedHMD() const;
|
bool getMutedHMD() const;
|
||||||
void setPTT(bool enabled);
|
void setPTT(bool enabled);
|
||||||
bool getPTT();
|
bool getPTT();
|
||||||
|
void setPushingToTalk(bool pushingToTalk);
|
||||||
bool getPushingToTalk() const;
|
bool getPushingToTalk() const;
|
||||||
|
|
||||||
// Push-To-Talk setters and getters
|
// Push-To-Talk setters and getters
|
||||||
|
|
|
@ -26,12 +26,15 @@ var UNMUTE_ICONS = {
|
||||||
icon: "icons/tablet-icons/mic-unmute-i.svg",
|
icon: "icons/tablet-icons/mic-unmute-i.svg",
|
||||||
activeIcon: "icons/tablet-icons/mic-unmute-a.svg"
|
activeIcon: "icons/tablet-icons/mic-unmute-a.svg"
|
||||||
};
|
};
|
||||||
|
var PTT_ICONS = {
|
||||||
|
icon: "icons/tablet-icons/mic-unmute-i.svg",
|
||||||
|
activeIcon: "icons/tablet-icons/mic-unmute-a.svg"
|
||||||
|
};
|
||||||
|
|
||||||
function onMuteToggled() {
|
function onMuteToggled() {
|
||||||
if (Audio.pushingToTalk) {
|
if (Audio.pushingToTalk) {
|
||||||
return;
|
button.editProperties(PTT_ICONS);
|
||||||
}
|
} else if (Audio.muted) {
|
||||||
if (Audio.muted) {
|
|
||||||
button.editProperties(MUTE_ICONS);
|
button.editProperties(MUTE_ICONS);
|
||||||
} else {
|
} else {
|
||||||
button.editProperties(UNMUTE_ICONS);
|
button.editProperties(UNMUTE_ICONS);
|
||||||
|
@ -71,6 +74,7 @@ onMuteToggled();
|
||||||
button.clicked.connect(onClicked);
|
button.clicked.connect(onClicked);
|
||||||
tablet.screenChanged.connect(onScreenChanged);
|
tablet.screenChanged.connect(onScreenChanged);
|
||||||
Audio.mutedChanged.connect(onMuteToggled);
|
Audio.mutedChanged.connect(onMuteToggled);
|
||||||
|
Audio.pushingToTalkChanged.connect(onMuteToggled);
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
Script.scriptEnding.connect(function () {
|
||||||
if (onAudioScreen) {
|
if (onAudioScreen) {
|
||||||
|
@ -79,6 +83,7 @@ Script.scriptEnding.connect(function () {
|
||||||
button.clicked.disconnect(onClicked);
|
button.clicked.disconnect(onClicked);
|
||||||
tablet.screenChanged.disconnect(onScreenChanged);
|
tablet.screenChanged.disconnect(onScreenChanged);
|
||||||
Audio.mutedChanged.disconnect(onMuteToggled);
|
Audio.mutedChanged.disconnect(onMuteToggled);
|
||||||
|
Audio.pushingToTalkChanged.disconnect(onMuteToggled);
|
||||||
tablet.removeButton(button);
|
tablet.removeButton(button);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue