Merge branch 'master' of github.com:highfidelity/hifi into addRecursionToAutotester

This commit is contained in:
NissimHadar 2018-03-06 15:21:38 -08:00
commit b30934d460
18 changed files with 175 additions and 51 deletions

View file

@ -405,7 +405,7 @@ void DomainServer::restart() {
exit(DomainServer::EXIT_CODE_REBOOT);
}
const QUuid& DomainServer::getID() {
QUuid DomainServer::getID() {
return DependencyManager::get<LimitedNodeList>()->getSessionUUID();
}

View file

@ -135,7 +135,7 @@ signals:
void userDisconnected();
private:
const QUuid& getID();
QUuid getID();
void parseCommandLine();
QString getContentBackupDir();

View file

@ -112,6 +112,7 @@ Rectangle {
// mute is in its own row
RowLayout {
spacing: (margins.sizeCheckBox - 10.5) * 3;
AudioControls.CheckBox {
id: muteMic
text: qsTr("Mute microphone");
@ -123,6 +124,19 @@ Rectangle {
checked = Qt.binding(function() { return AudioScriptingInterface.muted; }); // restore binding
}
}
AudioControls.CheckBox {
id: stereoMic
spacing: muteMic.spacing;
text: qsTr("use stereo for stereo devices");
checked: false;
onClicked: {
var success = Audio.setIsStereoInput(checked);
if (!success) {
checked = !checked;
}
}
}
}
RowLayout {
@ -204,6 +218,8 @@ Rectangle {
text: devicename
onPressed: {
if (!checked) {
stereoMic.checked = false;
Audio.setIsStereoInput(false); // the next selected audio device might not support stereo
AudioScriptingInterface.setInputDevice(info, bar.currentIndex === 1);
}
}

View file

@ -6146,6 +6146,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe
scriptEngine->registerGlobalObject("Selection", DependencyManager::get<SelectionScriptingInterface>().data());
scriptEngine->registerGlobalObject("ContextOverlay", DependencyManager::get<ContextOverlayInterface>().data());
scriptEngine->registerGlobalObject("Wallet", DependencyManager::get<WalletScriptingInterface>().data());
scriptEngine->registerGlobalObject("AddressManager", DependencyManager::get<AddressManager>().data());
qScriptRegisterMetaType(scriptEngine.data(), OverlayIDtoScriptValue, OverlayIDfromScriptValue);

View file

@ -1397,9 +1397,11 @@ void AudioClient::setNoiseReduction(bool enable) {
}
void AudioClient::setIsStereoInput(bool isStereoInput) {
if (isStereoInput != _isStereoInput) {
bool AudioClient::setIsStereoInput(bool isStereoInput) {
bool stereoInputChanged = false;
if (isStereoInput != _isStereoInput && _inputDeviceInfo.supportedChannelCounts().contains(2)) {
_isStereoInput = isStereoInput;
stereoInputChanged = true;
if (_isStereoInput) {
_desiredInputFormat.setChannelCount(2);
@ -1419,6 +1421,8 @@ void AudioClient::setIsStereoInput(bool isStereoInput) {
// restart the input device
switchInputToAudioDevice(_inputDeviceInfo);
}
return stereoInputChanged;
}
bool AudioClient::outputLocalInjector(const AudioInjectorPointer& injector) {

View file

@ -192,7 +192,7 @@ public slots:
void toggleMute();
bool isMuted() { return _muted; }
virtual void setIsStereoInput(bool stereo) override;
virtual bool setIsStereoInput(bool stereo) override;
void setNoiseReduction(bool isNoiseGateEnabled);
bool isNoiseReductionEnabled() const { return _isNoiseGateEnabled; }

View file

@ -41,7 +41,7 @@ public:
public slots:
virtual bool shouldLoopbackInjectors() { return false; }
virtual void setIsStereoInput(bool stereo) = 0;
virtual bool setIsStereoInput(bool stereo) = 0;
};
Q_DECLARE_METATYPE(AbstractAudioInterface*)

View file

@ -49,19 +49,8 @@ const std::set<NodeType_t> SOLO_NODE_TYPES = {
};
LimitedNodeList::LimitedNodeList(int socketListenPort, int dtlsListenPort) :
_sessionUUID(),
_nodeHash(),
_nodeMutex(QReadWriteLock::Recursive),
_nodeSocket(this),
_dtlsSocket(NULL),
_localSockAddr(),
_publicSockAddr(),
_stunSockAddr(STUN_SERVER_HOSTNAME, STUN_SERVER_PORT),
_packetReceiver(new PacketReceiver(this)),
_numCollectedPackets(0),
_numCollectedBytes(0),
_packetStatTimer(),
_permissions(NodePermissions())
_packetReceiver(new PacketReceiver(this))
{
qRegisterMetaType<ConnectionStep>("ConnectionStep");
auto port = (socketListenPort != INVALID_PORT) ? socketListenPort : LIMITED_NODELIST_LOCAL_PORT.get();
@ -122,13 +111,22 @@ LimitedNodeList::LimitedNodeList(int socketListenPort, int dtlsListenPort) :
}
}
QUuid LimitedNodeList::getSessionUUID() const {
QReadLocker lock { &_sessionUUIDLock };
return _sessionUUID;
}
void LimitedNodeList::setSessionUUID(const QUuid& sessionUUID) {
QUuid oldUUID = _sessionUUID;
_sessionUUID = sessionUUID;
QUuid oldUUID;
{
QWriteLocker lock { &_sessionUUIDLock };
oldUUID = _sessionUUID;
_sessionUUID = sessionUUID;
}
if (sessionUUID != oldUUID) {
qCDebug(networking) << "NodeList UUID changed from" << uuidStringWithoutCurlyBraces(oldUUID)
<< "to" << uuidStringWithoutCurlyBraces(_sessionUUID);
<< "to" << uuidStringWithoutCurlyBraces(sessionUUID);
emit uuidChanged(sessionUUID, oldUUID);
}
}

View file

@ -104,7 +104,7 @@ public:
};
Q_ENUM(ConnectionStep);
const QUuid& getSessionUUID() const { return _sessionUUID; }
QUuid getSessionUUID() const;
void setSessionUUID(const QUuid& sessionUUID);
void setPermissions(const NodePermissions& newPermissions);
@ -380,20 +380,19 @@ protected:
bool sockAddrBelongsToNode(const HifiSockAddr& sockAddr) { return findNodeWithAddr(sockAddr) != SharedNodePointer(); }
QUuid _sessionUUID;
NodeHash _nodeHash;
mutable QReadWriteLock _nodeMutex;
mutable QReadWriteLock _nodeMutex { QReadWriteLock::Recursive };
udt::Socket _nodeSocket;
QUdpSocket* _dtlsSocket;
QUdpSocket* _dtlsSocket { nullptr };
HifiSockAddr _localSockAddr;
HifiSockAddr _publicSockAddr;
HifiSockAddr _stunSockAddr;
HifiSockAddr _stunSockAddr { STUN_SERVER_HOSTNAME, STUN_SERVER_PORT };
bool _hasTCPCheckedLocalSocket { false };
PacketReceiver* _packetReceiver;
std::atomic<int> _numCollectedPackets;
std::atomic<int> _numCollectedBytes;
std::atomic<int> _numCollectedPackets { 0 };
std::atomic<int> _numCollectedBytes { 0 };
QElapsedTimer _packetStatTimer;
NodePermissions _permissions;
@ -424,6 +423,10 @@ private slots:
void flagTimeForConnectionStep(ConnectionStep connectionStep, quint64 timestamp);
void possiblyTimeoutSTUNAddressLookup();
void addSTUNHandlerToUnfiltered(); // called once STUN socket known
private:
mutable QReadWriteLock _sessionUUIDLock;
QUuid _sessionUUID;
};
#endif // hifi_LimitedNodeList_h

View file

@ -798,7 +798,7 @@ void NodeList::sendIgnoreRadiusStateToNode(const SharedNodePointer& destinationN
void NodeList::ignoreNodeBySessionID(const QUuid& nodeID, bool ignoreEnabled) {
// enumerate the nodes to send a reliable ignore packet to each that can leverage it
if (!nodeID.isNull() && _sessionUUID != nodeID) {
if (!nodeID.isNull() && getSessionUUID() != nodeID) {
eachMatchingNode([](const SharedNodePointer& node)->bool {
if (node->getType() == NodeType::AudioMixer || node->getType() == NodeType::AvatarMixer) {
return true;
@ -851,7 +851,7 @@ void NodeList::ignoreNodeBySessionID(const QUuid& nodeID, bool ignoreEnabled) {
void NodeList::removeFromIgnoreMuteSets(const QUuid& nodeID) {
// don't remove yourself, or nobody
if (!nodeID.isNull() && _sessionUUID != nodeID) {
if (!nodeID.isNull() && getSessionUUID() != nodeID) {
{
QWriteLocker ignoredSetLocker{ &_ignoredSetLock };
_ignoredNodeIDs.unsafe_erase(nodeID);
@ -870,7 +870,7 @@ bool NodeList::isIgnoringNode(const QUuid& nodeID) const {
void NodeList::personalMuteNodeBySessionID(const QUuid& nodeID, bool muteEnabled) {
// cannot personal mute yourself, or nobody
if (!nodeID.isNull() && _sessionUUID != nodeID) {
if (!nodeID.isNull() && getSessionUUID() != nodeID) {
auto audioMixer = soloNodeOfType(NodeType::AudioMixer);
if (audioMixer) {
if (isIgnoringNode(nodeID)) {
@ -970,7 +970,7 @@ void NodeList::maybeSendIgnoreSetToNode(SharedNodePointer newNode) {
void NodeList::setAvatarGain(const QUuid& nodeID, float gain) {
// cannot set gain of yourself
if (_sessionUUID != nodeID) {
if (getSessionUUID() != nodeID) {
auto audioMixer = soloNodeOfType(NodeType::AudioMixer);
if (audioMixer) {
// setup the packet
@ -1013,7 +1013,7 @@ void NodeList::kickNodeBySessionID(const QUuid& nodeID) {
// send a request to domain-server to kick the node with the given session ID
// the domain-server will handle the persistence of the kick (via username or IP)
if (!nodeID.isNull() && _sessionUUID != nodeID ) {
if (!nodeID.isNull() && getSessionUUID() != nodeID ) {
if (getThisNodeCanKick()) {
// setup the packet
auto kickPacket = NLPacket::create(PacketType::NodeKickRequest, NUM_BYTES_RFC4122_UUID, true);
@ -1036,7 +1036,7 @@ void NodeList::kickNodeBySessionID(const QUuid& nodeID) {
void NodeList::muteNodeBySessionID(const QUuid& nodeID) {
// cannot mute yourself, or nobody
if (!nodeID.isNull() && _sessionUUID != nodeID ) {
if (!nodeID.isNull() && getSessionUUID() != nodeID ) {
if (getThisNodeCanKick()) {
auto audioMixer = soloNodeOfType(NodeType::AudioMixer);
if (audioMixer) {

View file

@ -60,8 +60,10 @@ ScriptAudioInjector* AudioScriptingInterface::playSound(SharedSoundPointer sound
}
}
void AudioScriptingInterface::setStereoInput(bool stereo) {
bool AudioScriptingInterface::setStereoInput(bool stereo) {
bool stereoInputChanged = false;
if (_localAudioInterface) {
_localAudioInterface->setIsStereoInput(stereo);
stereoInputChanged = _localAudioInterface->setIsStereoInput(stereo);
}
return stereoInputChanged;
}

View file

@ -35,7 +35,7 @@ protected:
// FIXME: there is no way to play a positionless sound
Q_INVOKABLE ScriptAudioInjector* playSystemSound(SharedSoundPointer sound, const QVector3D& position);
Q_INVOKABLE void setStereoInput(bool stereo);
Q_INVOKABLE bool setStereoInput(bool stereo);
signals:
void mutedByMixer(); /// the client has been muted by the mixer

View file

@ -43,6 +43,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
this.totalVariance = 0;
this.highVarianceCount = 0;
this.veryhighVarianceCount = 0;
this.orderedPluginNames = [];
this.tabletID = null;
this.blacklist = [];
this.pointerManager = new PointerManager();

View file

@ -14,7 +14,7 @@
PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,
DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic,
getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays, isPointingAtUI
Picks, makeLaserLockInfo Xform, makeLaserParams
Picks, makeLaserLockInfo Xform, makeLaserParams, AddressManager, getEntityParents
*/
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@ -375,7 +375,7 @@ Script.include("/~/system/libraries/Xform.js");
return true;
}
return false;
}
};
this.isReady = function (controllerData) {
if (HMD.active) {
@ -449,11 +449,16 @@ Script.include("/~/system/libraries/Xform.js");
if (rayPickInfo.type === Picks.INTERSECTED_ENTITY) {
if (controllerData.triggerClicks[this.hand]) {
var entityID = rayPickInfo.objectID;
var targetProps = Entities.getEntityProperties(entityID, [
"dynamic", "shapeType", "position",
"rotation", "dimensions", "density",
"userData", "locked", "type"
"userData", "locked", "type", "href"
]);
if (targetProps.href !== "") {
AddressManager.handleLookupString(targetProps.href);
return makeRunningValues(false, [], []);
}
this.targetObject = new TargetObject(entityID, targetProps);
this.targetObject.parentProps = getEntityParents(targetProps);
@ -480,7 +485,8 @@ Script.include("/~/system/libraries/Xform.js");
this.grabbedDistance = rayPickInfo.distance;
}
if (otherFarGrabModule.grabbedThingID === this.grabbedThingID && otherFarGrabModule.distanceHolding) {
if (otherFarGrabModule.grabbedThingID === this.grabbedThingID &&
otherFarGrabModule.distanceHolding) {
this.prepareDistanceRotatingData(controllerData);
this.distanceRotate(otherFarGrabModule);
} else {

View file

@ -0,0 +1,95 @@
"use strict";
// nearGrabHyperLinkEntity.js
//
// Created by Dante Ruiz on 03/02/2018
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND,
getControllerJointIndex, getGrabbableData, enableDispatcherModule, disableDispatcherModule,
propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, entityIsGrabbable,
Quat, Vec3, MSECS_PER_SEC, getControllerWorldLocation, makeDispatcherModuleParameters, makeRunningValues,
TRIGGER_OFF_VALUE, NEAR_GRAB_RADIUS, findGroupParent, entityIsCloneable, propsAreCloneDynamic, cloneEntity,
HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE, AddressManager
*/
(function() {
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
Script.include("/~/system/libraries/controllers.js");
function NearGrabHyperLinkEntity(hand) {
this.hand = hand;
this.targetEntityID = null;
this.hyperlink = "";
this.parameters = makeDispatcherModuleParameters(
485,
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
[],
100);
this.getTargetProps = function(controllerData) {
var nearbyEntitiesProperties = controllerData.nearbyEntityProperties[this.hand];
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
for (var i = 0; i < nearbyEntitiesProperties.length; i++) {
var props = nearbyEntitiesProperties[i];
if (props.distance > NEAR_GRAB_RADIUS * sensorScaleFactor) {
continue;
}
if (props.href !== "" && props.href !== undefined) {
return props;
}
}
return null;
};
this.isReady = function(controllerData) {
this.targetEntityID = null;
if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE &&
controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) {
return makeRunningValues(false, [], []);
}
var targetProps = this.getTargetProps(controllerData);
if (targetProps) {
this.hyperlink = targetProps.href;
this.targetEntityID = targetProps.id;
return makeRunningValues(true, [], []);
}
return makeRunningValues(false, [], []);
};
this.run = function(controllerData) {
if ((controllerData.triggerClicks[this.hand] < TRIGGER_OFF_VALUE &&
controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) || this.hyperlink === "") {
return makeRunningValues(false, [], []);
}
if (controllerData.triggerClicks[this.hand] ||
controllerData.secondaryValues[this.hand] > BUMPER_ON_VALUE) {
AddressManager.handleLookupString(this.hyperlink);
return makeRunningValues(false, [], []);
}
return makeRunningValues(true, [], []);
};
}
var leftNearGrabHyperLinkEntity = new NearGrabHyperLinkEntity(LEFT_HAND);
var rightNearGrabHyperLinkEntity = new NearGrabHyperLinkEntity(RIGHT_HAND);
enableDispatcherModule("LeftNearGrabHyperLink", leftNearGrabHyperLinkEntity);
enableDispatcherModule("RightNearGrabHyperLink", rightNearGrabHyperLinkEntity);
function cleanup() {
disableDispatcherModule("LeftNearGrabHyperLink");
disableDispatcherModule("RightNearGrabHyperLink");
}
Script.scriptEnding.connect(cleanup);
}());

View file

@ -31,7 +31,8 @@ var CONTOLLER_SCRIPTS = [
"controllerModules/scaleAvatar.js",
"controllerModules/hudOverlayPointer.js",
"controllerModules/mouseHMD.js",
"controllerModules/scaleEntity.js"
"controllerModules/scaleEntity.js",
"controllerModules/nearGrabHyperLinkEntity.js"
];
var DEBUG_MENU_ITEM = "Debug defaultScripts.js";

View file

@ -321,22 +321,19 @@ function multiDataUpdater(groupName, updateKeyPair, userDataElement, defaults) {
}
var keys = Object.keys(updateKeyPair);
keys.forEach(function (key) {
delete parsedData[groupName][key];
if (updateKeyPair[key] !== null && updateKeyPair[key] !== "null") {
if (updateKeyPair[key] instanceof Element) {
if (updateKeyPair[key].type === "checkbox") {
if (updateKeyPair[key].checked !== defaults[key]) {
parsedData[groupName][key] = updateKeyPair[key].checked;
}
parsedData[groupName][key] = updateKeyPair[key].checked;
} else {
var val = isNaN(updateKeyPair[key].value) ? updateKeyPair[key].value : parseInt(updateKeyPair[key].value);
if (val !== defaults[key]) {
parsedData[groupName][key] = val;
}
parsedData[groupName][key] = val;
}
} else {
parsedData[groupName][key] = updateKeyPair[key];
}
} else if (defaults[key] !== null && defaults[key] !== "null") {
parsedData[groupName][key] = defaults[key];
}
});
if (Object.keys(parsedData[groupName]).length === 0) {

View file

@ -105,7 +105,8 @@ DISPATCHER_PROPERTIES = [
"density",
"dimensions",
"userData",
"type"
"type",
"href"
];
// priority -- a lower priority means the module will be asked sooner than one with a higher priority in a given update step
@ -233,7 +234,6 @@ entityIsDistanceGrabbable = function(props) {
return true;
};
getControllerJointIndex = function (hand) {
if (HMD.isHandControllerAvailable()) {
var controllerJointIndex = -1;