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

This commit is contained in:
Mike Moody 2017-07-24 16:50:38 -07:00
commit 697830b80b
4 changed files with 53 additions and 74 deletions

View file

@ -36,6 +36,21 @@ Setting::Handle<QString>& getSetting(bool contextIsHMD, QAudio::Mode mode) {
}
}
static QString getTargetDevice(bool hmd, QAudio::Mode mode) {
QString deviceName;
auto& setting = getSetting(hmd, mode);
if (setting.isSet()) {
deviceName = setting.get();
} else if (hmd) {
if (mode == QAudio::AudioInput) {
deviceName = qApp->getActiveDisplayPlugin()->getPreferredAudioInDevice();
} else { // if (_mode == QAudio::AudioOutput)
deviceName = qApp->getActiveDisplayPlugin()->getPreferredAudioOutDevice();
}
}
return deviceName;
}
QHash<int, QByteArray> AudioDeviceList::_roles {
{ Qt::DisplayRole, "display" },
{ Qt::CheckStateRole, "selected" },
@ -59,10 +74,15 @@ QVariant AudioDeviceList::data(const QModelIndex& index, int role) const {
}
}
void AudioDeviceList::resetDevice(bool contextIsHMD, const QString& device) {
void AudioDeviceList::resetDevice(bool contextIsHMD) {
auto client = DependencyManager::get<AudioClient>().data();
auto deviceName = getSetting(contextIsHMD, _mode).get();
QString deviceName = getTargetDevice(contextIsHMD, _mode);
// FIXME can't use blocking connections here, so we can't determine whether the switch succeeded or not
// We need to have the AudioClient emit signals on switch success / failure
QMetaObject::invokeMethod(client, "switchAudioDevice",
Q_ARG(QAudio::Mode, _mode), Q_ARG(QString, deviceName));
#if 0
bool switchResult = false;
QMetaObject::invokeMethod(client, "switchAudioDevice", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(bool, switchResult),
@ -85,6 +105,7 @@ void AudioDeviceList::resetDevice(bool contextIsHMD, const QString& device) {
QMetaObject::invokeMethod(client, "switchAudioDevice", Q_ARG(QAudio::Mode, _mode));
}
}
#endif
}
void AudioDeviceList::onDeviceChanged(const QAudioDeviceInfo& device) {
@ -137,11 +158,8 @@ AudioDevices::AudioDevices(bool& contextIsHMD) : _contextIsHMD(contextIsHMD) {
}
void AudioDevices::onContextChanged(const QString& context) {
auto input = getSetting(_contextIsHMD, QAudio::AudioInput).get();
auto output = getSetting(_contextIsHMD, QAudio::AudioOutput).get();
_inputs.resetDevice(_contextIsHMD, input);
_outputs.resetDevice(_contextIsHMD, output);
_inputs.resetDevice(_contextIsHMD);
_outputs.resetDevice(_contextIsHMD);
}
void AudioDevices::onDeviceSelected(QAudio::Mode mode, const QAudioDeviceInfo& device, const QAudioDeviceInfo& previousDevice) {
@ -182,8 +200,16 @@ void AudioDevices::onDeviceSelected(QAudio::Mode mode, const QAudioDeviceInfo& d
void AudioDevices::onDeviceChanged(QAudio::Mode mode, const QAudioDeviceInfo& device) {
if (mode == QAudio::AudioInput) {
if (_requestedInputDevice == device) {
onDeviceSelected(QAudio::AudioInput, device, _inputs._selectedDevice);
_requestedInputDevice = QAudioDeviceInfo();
}
_inputs.onDeviceChanged(device);
} else { // if (mode == QAudio::AudioOutput)
if (_requestedOutputDevice == device) {
onDeviceSelected(QAudio::AudioOutput, device, _outputs._selectedDevice);
_requestedOutputDevice = QAudioDeviceInfo();
}
_outputs.onDeviceChanged(device);
}
}
@ -201,28 +227,16 @@ void AudioDevices::onDevicesChanged(QAudio::Mode mode, const QList<QAudioDeviceI
void AudioDevices::chooseInputDevice(const QAudioDeviceInfo& device) {
auto client = DependencyManager::get<AudioClient>();
bool success = false;
_requestedInputDevice = device;
QMetaObject::invokeMethod(client.data(), "switchAudioDevice",
Qt::BlockingQueuedConnection,
Q_RETURN_ARG(bool, success),
Q_ARG(QAudio::Mode, QAudio::AudioInput),
Q_ARG(const QAudioDeviceInfo&, device));
if (success) {
onDeviceSelected(QAudio::AudioInput, device, _inputs._selectedDevice);
}
}
void AudioDevices::chooseOutputDevice(const QAudioDeviceInfo& device) {
auto client = DependencyManager::get<AudioClient>();
bool success = false;
_requestedOutputDevice = device;
QMetaObject::invokeMethod(client.data(), "switchAudioDevice",
Qt::BlockingQueuedConnection,
Q_RETURN_ARG(bool, success),
Q_ARG(QAudio::Mode, QAudio::AudioOutput),
Q_ARG(const QAudioDeviceInfo&, device));
if (success) {
onDeviceSelected(QAudio::AudioOutput, device, _outputs._selectedDevice);
}
}

View file

@ -39,7 +39,7 @@ public:
QVariant data(const QModelIndex& index, int role) const override;
// reset device to the last selected device in this context, or the default
void resetDevice(bool contextIsHMD, const QString& device);
void resetDevice(bool contextIsHMD);
signals:
void deviceChanged(const QAudioDeviceInfo& device);
@ -87,8 +87,10 @@ private:
AudioDeviceList _inputs { QAudio::AudioInput };
AudioDeviceList _outputs { QAudio::AudioOutput };
QAudioDeviceInfo _requestedOutputDevice;
QAudioDeviceInfo _requestedInputDevice;
bool& _contextIsHMD;
const bool& _contextIsHMD;
};
};

View file

@ -1074,7 +1074,7 @@ function loaded() {
elDimensionsZ.addEventListener('change', dimensionsChangeFunction);
elParentID.addEventListener('change', createEmitTextPropertyUpdateFunction('parentID'));
elParentJointIndex.addEventListener('change', createEmitNumberPropertyUpdateFunction('parentJointIndex'));
elParentJointIndex.addEventListener('change', createEmitNumberPropertyUpdateFunction('parentJointIndex', 0));
var registrationChangeFunction = createEmitVec3PropertyUpdateFunction(
'registrationPoint', elRegistrationX, elRegistrationY, elRegistrationZ);

View file

@ -1560,7 +1560,6 @@ SelectionDisplay = (function() {
visible: rotationOverlaysVisible
});
// TODO: we have not implemented the rotating handle/controls yet... so for now, these handles are hidden
Overlays.editOverlay(yawHandle, {
visible: rotateHandlesVisible,
position: yawCorner,
@ -3615,24 +3614,21 @@ SelectionDisplay = (function() {
onMove: function(event) {
var pickRay = generalComputePickRay(event.x, event.y);
Overlays.editOverlay(selectionBox, {
ignoreRayIntersection: true,
visible: false
});
Overlays.editOverlay(baseOfEntityProjectionOverlay, {
ignoreRayIntersection: true,
visible: false
});
Overlays.editOverlay(rotateOverlayTarget, {
ignoreRayIntersection: false
});
var result = Overlays.findRayIntersection(pickRay);
var result = Overlays.findRayIntersection(pickRay, true, [rotateOverlayTarget]);
if (result.intersects) {
var center = yawCenter;
var zero = yawZero;
// TODO: these vectors are backwards to their names, doesn't matter for this use case (inverted vectors still give same angle)
var centerToZero = Vec3.subtract(center, zero);
var centerToIntersect = Vec3.subtract(center, result.intersection);
// TODO: orientedAngle wants normalized centerToZero and centerToIntersect
var angleFromZero = Vec3.orientedAngle(centerToZero, centerToIntersect, rotationNormal);
var distanceFromCenter = Vec3.distance(center, result.intersection);
var snapToInner = distanceFromCenter < innerRadius;
@ -3785,17 +3781,12 @@ SelectionDisplay = (function() {
onMove: function(event) {
var pickRay = generalComputePickRay(event.x, event.y);
Overlays.editOverlay(selectionBox, {
ignoreRayIntersection: true,
visible: false
});
Overlays.editOverlay(baseOfEntityProjectionOverlay, {
ignoreRayIntersection: true,
visible: false
});
Overlays.editOverlay(rotateOverlayTarget, {
ignoreRayIntersection: false
});
var result = Overlays.findRayIntersection(pickRay);
var result = Overlays.findRayIntersection(pickRay, true, [rotateOverlayTarget]);
if (result.intersects) {
var properties = Entities.getEntityProperties(selectionManager.selections[0]);
@ -3947,17 +3938,12 @@ SelectionDisplay = (function() {
onMove: function(event) {
var pickRay = generalComputePickRay(event.x, event.y);
Overlays.editOverlay(selectionBox, {
ignoreRayIntersection: true,
visible: false
});
Overlays.editOverlay(baseOfEntityProjectionOverlay, {
ignoreRayIntersection: true,
visible: false
});
Overlays.editOverlay(rotateOverlayTarget, {
ignoreRayIntersection: false
});
var result = Overlays.findRayIntersection(pickRay);
var result = Overlays.findRayIntersection(pickRay, true, [rotateOverlayTarget]);
if (result.intersects) {
var properties = Entities.getEntityProperties(selectionManager.selections[0]);
@ -4074,21 +4060,8 @@ SelectionDisplay = (function() {
return false;
}
// before we do a ray test for grabbers, disable the ray intersection for our selection box
Overlays.editOverlay(selectionBox, {
ignoreRayIntersection: true
});
Overlays.editOverlay(yawHandle, {
ignoreRayIntersection: true
});
Overlays.editOverlay(pitchHandle, {
ignoreRayIntersection: true
});
Overlays.editOverlay(rollHandle, {
ignoreRayIntersection: true
});
result = Overlays.findRayIntersection(pickRay);
// ignore ray intersection for our selection box and yaw/pitch/roll
result = Overlays.findRayIntersection(pickRay, true, null, [ yawHandle, pitchHandle, rollHandle, selectionBox ] );
if (result.intersects) {
if (wantDebug) {
print("something intersects... ");
@ -4191,17 +4164,8 @@ SelectionDisplay = (function() {
}
// After testing our stretch handles, then check out rotate handles
Overlays.editOverlay(yawHandle, {
ignoreRayIntersection: false
});
Overlays.editOverlay(pitchHandle, {
ignoreRayIntersection: false
});
Overlays.editOverlay(rollHandle, {
ignoreRayIntersection: false
});
var result = Overlays.findRayIntersection(pickRay);
// Only intersect versus yaw/pitch/roll.
var result = Overlays.findRayIntersection(pickRay, true, [ yawHandle, pitchHandle, rollHandle ] );
var overlayOrientation;
var overlayCenter;
@ -4306,6 +4270,7 @@ SelectionDisplay = (function() {
});
// TODO: these three duplicate prior three, remove them.
Overlays.editOverlay(yawHandle, {
visible: false
});
@ -4402,10 +4367,8 @@ SelectionDisplay = (function() {
}
if (!somethingClicked) {
Overlays.editOverlay(selectionBox, {
ignoreRayIntersection: false
});
var result = Overlays.findRayIntersection(pickRay);
// Only intersect versus selectionBox.
var result = Overlays.findRayIntersection(pickRay, true, [selectionBox]);
if (result.intersects) {
switch (result.overlayID) {
case selectionBox: