Merge pull request #12038 from ElderOrb/audio_name_conflict_fix

Audio name conflict fix (fix for https://github.com/highfidelity/hifi/issues/11963)
This commit is contained in:
Seth Alves 2018-01-05 08:15:48 -08:00 committed by GitHub
commit fd8b521c50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 36 deletions

View file

@ -110,7 +110,7 @@ Item {
} }
function pullFreshValues() { function pullFreshValues() {
if (Audio.getRecording()) { if (AudioScriptingInterface.getRecording()) {
updateRecordingLabel(); updateRecordingLabel();
} }
@ -129,14 +129,14 @@ Item {
_wavFilePath = _wavFilePath.replace(/[\-:]|\.\d*Z$/g, "").replace("T", "-") + ".wav"; _wavFilePath = _wavFilePath.replace(/[\-:]|\.\d*Z$/g, "").replace("T", "-") + ".wav";
// Using controller recording default directory // Using controller recording default directory
_wavFilePath = Recording.getDefaultRecordingSaveDirectory() + _wavFilePath; _wavFilePath = Recording.getDefaultRecordingSaveDirectory() + _wavFilePath;
if (!Audio.startRecording(_wavFilePath)) { if (!AudioScriptingInterface.startRecording(_wavFilePath)) {
Messages.sendMessage("Hifi-Notifications", JSON.stringify({message:"Error creating: "+_wavFilePath})); Messages.sendMessage("Hifi-Notifications", JSON.stringify({message:"Error creating: "+_wavFilePath}));
updateRecordingUI(false); updateRecordingUI(false);
} }
} }
function stopRecording() { function stopRecording() {
Audio.stopRecording(); AudioScriptingInterface.stopRecording();
setRecordingLabelOpacity(0.0); setRecordingLabelOpacity(0.0);
Messages.sendMessage("Hifi-Notifications", JSON.stringify({message:"Saved: "+_wavFilePath})); Messages.sendMessage("Hifi-Notifications", JSON.stringify({message:"Saved: "+_wavFilePath}));
} }
@ -158,7 +158,7 @@ Item {
} }
function toggleRecording() { function toggleRecording() {
if (Audio.getRecording()) { if (AudioScriptingInterface.getRecording()) {
updateRecordingUI(false); updateRecordingUI(false);
stopRecording(); stopRecording();
} else { } else {

View file

@ -26,7 +26,7 @@ Rectangle {
HifiConstants { id: hifi; } HifiConstants { id: hifi; }
property var eventBridge; property var eventBridge;
property string title: "Audio Settings - " + Audio.context; property string title: "Audio Settings - " + AudioScriptingInterface.context;
signal sendToScript(var message); signal sendToScript(var message);
color: hifi.colors.baseGray; color: hifi.colors.baseGray;
@ -37,7 +37,7 @@ Rectangle {
} }
property bool isVR: Audio.context === "VR" property bool isVR: AudioScriptingInterface.context === "VR"
property real rightMostInputLevelPos: 0 property real rightMostInputLevelPos: 0
//placeholder for control sizes and paddings //placeholder for control sizes and paddings
//recalculates dynamically in case of UI size is changed //recalculates dynamically in case of UI size is changed
@ -72,17 +72,17 @@ Rectangle {
property bool showPeaks: true; property bool showPeaks: true;
function enablePeakValues() { function enablePeakValues() {
Audio.devices.input.peakValuesEnabled = true; AudioScriptingInterface.devices.input.peakValuesEnabled = true;
Audio.devices.input.peakValuesEnabledChanged.connect(function(enabled) { AudioScriptingInterface.devices.input.peakValuesEnabledChanged.connect(function(enabled) {
if (!enabled && root.showPeaks) { if (!enabled && root.showPeaks) {
Audio.devices.input.peakValuesEnabled = true; AudioScriptingInterface.devices.input.peakValuesEnabled = true;
} }
}); });
} }
function disablePeakValues() { function disablePeakValues() {
root.showPeaks = false; root.showPeaks = false;
Audio.devices.input.peakValuesEnabled = false; AudioScriptingInterface.devices.input.peakValuesEnabled = false;
} }
Component.onCompleted: enablePeakValues(); Component.onCompleted: enablePeakValues();
@ -117,10 +117,10 @@ Rectangle {
text: qsTr("Mute microphone"); text: qsTr("Mute microphone");
spacing: margins.sizeCheckBox - boxSize spacing: margins.sizeCheckBox - boxSize
isRedCheck: true; isRedCheck: true;
checked: Audio.muted; checked: AudioScriptingInterface.muted;
onClicked: { onClicked: {
Audio.muted = checked; AudioScriptingInterface.muted = checked;
checked = Qt.binding(function() { return Audio.muted; }); // restore binding checked = Qt.binding(function() { return AudioScriptingInterface.muted; }); // restore binding
} }
} }
} }
@ -130,10 +130,10 @@ Rectangle {
AudioControls.CheckBox { AudioControls.CheckBox {
spacing: muteMic.spacing spacing: muteMic.spacing
text: qsTr("Enable noise reduction"); text: qsTr("Enable noise reduction");
checked: Audio.noiseReduction; checked: AudioScriptingInterface.noiseReduction;
onClicked: { onClicked: {
Audio.noiseReduction = checked; AudioScriptingInterface.noiseReduction = checked;
checked = Qt.binding(function() { return Audio.noiseReduction; }); // restore binding checked = Qt.binding(function() { return AudioScriptingInterface.noiseReduction; }); // restore binding
} }
} }
AudioControls.CheckBox { AudioControls.CheckBox {
@ -184,7 +184,7 @@ Rectangle {
spacing: 4; spacing: 4;
snapMode: ListView.SnapToItem; snapMode: ListView.SnapToItem;
clip: true; clip: true;
model: Audio.devices.input; model: AudioScriptingInterface.devices.input;
delegate: Item { delegate: Item {
width: rightMostInputLevelPos width: rightMostInputLevelPos
height: margins.sizeCheckBox > checkBoxInput.implicitHeight ? height: margins.sizeCheckBox > checkBoxInput.implicitHeight ?
@ -204,7 +204,7 @@ Rectangle {
text: devicename text: devicename
onPressed: { onPressed: {
if (!checked) { if (!checked) {
Audio.setInputDevice(info, bar.currentIndex === 1); AudioScriptingInterface.setInputDevice(info, bar.currentIndex === 1);
} }
} }
} }
@ -215,7 +215,7 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
visible: ((bar.currentIndex === 1 && isVR) || visible: ((bar.currentIndex === 1 && isVR) ||
(bar.currentIndex === 0 && !isVR)) && (bar.currentIndex === 0 && !isVR)) &&
Audio.devices.input.peakValuesAvailable; AudioScriptingInterface.devices.input.peakValuesAvailable;
} }
} }
} }
@ -256,7 +256,7 @@ Rectangle {
spacing: 4; spacing: 4;
snapMode: ListView.SnapToItem; snapMode: ListView.SnapToItem;
clip: true; clip: true;
model: Audio.devices.output; model: AudioScriptingInterface.devices.output;
delegate: Item { delegate: Item {
width: rightMostInputLevelPos width: rightMostInputLevelPos
height: margins.sizeCheckBox > checkBoxOutput.implicitHeight ? height: margins.sizeCheckBox > checkBoxOutput.implicitHeight ?
@ -273,7 +273,7 @@ Rectangle {
text: devicename text: devicename
onPressed: { onPressed: {
if (!checked) { if (!checked) {
Audio.setOutputDevice(info, bar.currentIndex === 1); AudioScriptingInterface.setOutputDevice(info, bar.currentIndex === 1);
} }
} }
} }

View file

@ -40,7 +40,7 @@ Rectangle {
verticalCenter: parent.verticalCenter; verticalCenter: parent.verticalCenter;
} }
visible: Audio.muted; visible: AudioScriptingInterface.muted;
color: colors.muted; color: colors.muted;
text: "MUTED"; text: "MUTED";

View file

@ -17,7 +17,7 @@ import QtGraphicalEffects 1.0
import TabletScriptingInterface 1.0 import TabletScriptingInterface 1.0
Rectangle { Rectangle {
readonly property var level: Audio.inputLevel; readonly property var level: AudioScriptingInterface.inputLevel;
property bool standalone: false; property bool standalone: false;
property var dragTarget: null; property var dragTarget: null;
@ -60,7 +60,7 @@ Rectangle {
hoverEnabled: true; hoverEnabled: true;
scrollGestureEnabled: false; scrollGestureEnabled: false;
onClicked: { onClicked: {
Audio.muted = !Audio.muted; AudioScriptingInterface.muted = !AudioScriptingInterface.muted;
Tablet.playSound(TabletEnums.ButtonClick); Tablet.playSound(TabletEnums.ButtonClick);
} }
drag.target: dragTarget; drag.target: dragTarget;
@ -82,7 +82,7 @@ Rectangle {
readonly property string red: colors.muted; readonly property string red: colors.muted;
readonly property string fill: "#55000000"; readonly property string fill: "#55000000";
readonly property string border: standalone ? "#80FFFFFF" : "#55FFFFFF"; readonly property string border: standalone ? "#80FFFFFF" : "#55FFFFFF";
readonly property string icon: Audio.muted ? muted : unmuted; readonly property string icon: AudioScriptingInterface.muted ? muted : unmuted;
} }
Item { Item {
@ -103,7 +103,7 @@ Rectangle {
readonly property string mutedIcon: "../../../icons/tablet-icons/mic-mute-i.svg"; readonly property string mutedIcon: "../../../icons/tablet-icons/mic-mute-i.svg";
id: image; id: image;
source: Audio.muted ? mutedIcon : unmutedIcon; source: AudioScriptingInterface.muted ? mutedIcon : unmutedIcon;
width: 30; width: 30;
height: 30; height: 30;
@ -126,9 +126,9 @@ Rectangle {
Item { Item {
id: status; id: status;
readonly property string color: Audio.muted ? colors.muted : colors.unmuted; readonly property string color: AudioScriptingInterface.muted ? colors.muted : colors.unmuted;
visible: Audio.muted; visible: AudioScriptingInterface.muted;
anchors { anchors {
left: parent.left; left: parent.left;
@ -147,7 +147,7 @@ Rectangle {
color: parent.color; color: parent.color;
text: Audio.muted ? "MUTED" : "MUTE"; text: AudioScriptingInterface.muted ? "MUTED" : "MUTE";
font.pointSize: 12; font.pointSize: 12;
} }

View file

@ -27,9 +27,9 @@ RowLayout {
} }
function playSound() { function playSound() {
// FIXME: MyAvatar is not properly exposed to QML; MyAvatar.qmlPosition is a stopgap // FIXME: MyAvatar is not properly exposed to QML; MyAvatar.qmlPosition is a stopgap
// FIXME: Audio.playSystemSound should not require position // FIXME: AudioScriptingInterface.playSystemSound should not require position
if (sample === null && !isPlaying) { if (sample === null && !isPlaying) {
sample = Audio.playSystemSound(sound, MyAvatar.qmlPosition); sample = AudioScriptingInterface.playSystemSound(sound, MyAvatar.qmlPosition);
isPlaying = true; isPlaying = true;
sample.finished.connect(reset); sample.finished.connect(reset);
} }

View file

@ -2318,9 +2318,10 @@ void Application::initializeUi() {
setupPreferences(); setupPreferences();
// For some reason there is already an "Application" object in the QML context, // in Qt 5.10.0 there is already an "Audio" object in the QML context
// though I can't find it. Hence, "ApplicationInterface" // though I failed to find it (from QtMultimedia??). So.. let it be "AudioScriptingInterface"
surfaceContext->setContextProperty("Audio", DependencyManager::get<AudioScriptingInterface>().data()); surfaceContext->setContextProperty("AudioScriptingInterface", DependencyManager::get<AudioScriptingInterface>().data());
surfaceContext->setContextProperty("AudioStats", DependencyManager::get<AudioClient>()->getStats().data()); surfaceContext->setContextProperty("AudioStats", DependencyManager::get<AudioClient>()->getStats().data());
surfaceContext->setContextProperty("AudioScope", DependencyManager::get<AudioScope>().data()); surfaceContext->setContextProperty("AudioScope", DependencyManager::get<AudioScope>().data());

View file

@ -194,7 +194,11 @@ void Web3DOverlay::setupQmlSurface() {
_webSurface->getSurfaceContext()->setContextProperty("offscreenFlags", flags); _webSurface->getSurfaceContext()->setContextProperty("offscreenFlags", flags);
_webSurface->getSurfaceContext()->setContextProperty("AddressManager", DependencyManager::get<AddressManager>().data()); _webSurface->getSurfaceContext()->setContextProperty("AddressManager", DependencyManager::get<AddressManager>().data());
_webSurface->getSurfaceContext()->setContextProperty("Account", AccountScriptingInterface::getInstance()); _webSurface->getSurfaceContext()->setContextProperty("Account", AccountScriptingInterface::getInstance());
_webSurface->getSurfaceContext()->setContextProperty("Audio", DependencyManager::get<AudioScriptingInterface>().data());
// in Qt 5.10.0 there is already an "Audio" object in the QML context
// though I failed to find it (from QtMultimedia??). So.. let it be "AudioScriptingInterface"
_webSurface->getSurfaceContext()->setContextProperty("AudioScriptingInterface", DependencyManager::get<AudioScriptingInterface>().data());
_webSurface->getSurfaceContext()->setContextProperty("AudioStats", DependencyManager::get<AudioClient>()->getStats().data()); _webSurface->getSurfaceContext()->setContextProperty("AudioStats", DependencyManager::get<AudioClient>()->getStats().data());
_webSurface->getSurfaceContext()->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data()); _webSurface->getSurfaceContext()->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data());
_webSurface->getSurfaceContext()->setContextProperty("fileDialogHelper", new FileDialogHelper()); _webSurface->getSurfaceContext()->setContextProperty("fileDialogHelper", new FileDialogHelper());
@ -605,4 +609,4 @@ Web3DOverlay* Web3DOverlay::createClone() const {
void Web3DOverlay::emitScriptEvent(const QVariant& message) { void Web3DOverlay::emitScriptEvent(const QVariant& message) {
QMetaObject::invokeMethod(this, "scriptEventReceived", Q_ARG(QVariant, message)); QMetaObject::invokeMethod(this, "scriptEventReceived", Q_ARG(QVariant, message));
} }