mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-01 08:20:00 +02:00
Trying to resolve QML / Audio deadlocks
This commit is contained in:
parent
b35d696077
commit
aab56cf2a9
4 changed files with 51 additions and 24 deletions
|
@ -117,26 +117,28 @@ Rectangle {
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
width: parent.width;
|
width: parent.width;
|
||||||
height: 36;
|
height: 36;
|
||||||
|
|
||||||
|
AudioControls.CheckBox {
|
||||||
|
id: checkbox
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.left: parent.left
|
||||||
|
text: display;
|
||||||
|
wrap: false;
|
||||||
|
checked: selected;
|
||||||
|
enabled: false;
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout {
|
MouseArea {
|
||||||
width: parent.width;
|
anchors.fill: checkbox
|
||||||
|
onClicked: Audio.setInputDevice(info);
|
||||||
|
}
|
||||||
|
|
||||||
AudioControls.CheckBox {
|
InputLevel {
|
||||||
Layout.maximumWidth: parent.width - level.width - 40;
|
id: level;
|
||||||
text: display;
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
wrap: false;
|
anchors.right: parent.right
|
||||||
checked: selected;
|
anchors.rightMargin: 30
|
||||||
onClicked: {
|
visible: selected;
|
||||||
selected = checked;
|
|
||||||
checked = Qt.binding(function() { return selected; }); // restore binding
|
|
||||||
}
|
|
||||||
}
|
|
||||||
InputLevel {
|
|
||||||
id: level;
|
|
||||||
Layout.alignment: Qt.AlignRight;
|
|
||||||
Layout.rightMargin: 30;
|
|
||||||
visible: selected;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,13 +176,19 @@ Rectangle {
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
width: parent.width;
|
width: parent.width;
|
||||||
height: 36;
|
height: 36;
|
||||||
|
|
||||||
AudioControls.CheckBox {
|
AudioControls.CheckBox {
|
||||||
|
id: checkbox
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.left: parent.left
|
||||||
text: display;
|
text: display;
|
||||||
checked: selected;
|
checked: selected;
|
||||||
onClicked: {
|
enabled: false;
|
||||||
selected = checked;
|
}
|
||||||
checked = Qt.binding(function() { return selected; }); // restore binding
|
|
||||||
}
|
MouseArea {
|
||||||
|
anchors.fill: checkbox
|
||||||
|
onClicked: Audio.setOutputDevice(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,4 +133,18 @@ void Audio::setReverb(bool enable) {
|
||||||
|
|
||||||
void Audio::setReverbOptions(const AudioEffectOptions* options) {
|
void Audio::setReverbOptions(const AudioEffectOptions* options) {
|
||||||
DependencyManager::get<AudioClient>()->setReverbOptions(options);
|
DependencyManager::get<AudioClient>()->setReverbOptions(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Audio::setInputDevice(const QAudioDeviceInfo& device) {
|
||||||
|
auto client = DependencyManager::get<AudioClient>();
|
||||||
|
QMetaObject::invokeMethod(client.data(), "switchAudioDevice",
|
||||||
|
Q_ARG(QAudio::Mode, QAudio::AudioInput),
|
||||||
|
Q_ARG(const QAudioDeviceInfo&, device));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Audio::setOutputDevice(const QAudioDeviceInfo& device) {
|
||||||
|
auto client = DependencyManager::get<AudioClient>();
|
||||||
|
QMetaObject::invokeMethod(client.data(), "switchAudioDevice",
|
||||||
|
Q_ARG(QAudio::Mode, QAudio::AudioOutput),
|
||||||
|
Q_ARG(const QAudioDeviceInfo&, device));
|
||||||
|
}
|
||||||
|
|
|
@ -50,6 +50,8 @@ public:
|
||||||
void showMicMeter(bool show);
|
void showMicMeter(bool show);
|
||||||
void setInputVolume(float volume);
|
void setInputVolume(float volume);
|
||||||
|
|
||||||
|
Q_INVOKABLE void setInputDevice(const QAudioDeviceInfo& device);
|
||||||
|
Q_INVOKABLE void setOutputDevice(const QAudioDeviceInfo& device);
|
||||||
Q_INVOKABLE void setReverb(bool enable);
|
Q_INVOKABLE void setReverb(bool enable);
|
||||||
Q_INVOKABLE void setReverbOptions(const AudioEffectOptions* options);
|
Q_INVOKABLE void setReverbOptions(const AudioEffectOptions* options);
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,8 @@ Setting::Handle<QString>& getSetting(bool contextIsHMD, QAudio::Mode mode) {
|
||||||
|
|
||||||
QHash<int, QByteArray> AudioDeviceList::_roles {
|
QHash<int, QByteArray> AudioDeviceList::_roles {
|
||||||
{ Qt::DisplayRole, "display" },
|
{ Qt::DisplayRole, "display" },
|
||||||
{ Qt::CheckStateRole, "selected" }
|
{ Qt::CheckStateRole, "selected" },
|
||||||
|
{ Qt::UserRole, "info" }
|
||||||
};
|
};
|
||||||
Qt::ItemFlags AudioDeviceList::_flags { Qt::ItemIsSelectable | Qt::ItemIsEnabled };
|
Qt::ItemFlags AudioDeviceList::_flags { Qt::ItemIsSelectable | Qt::ItemIsEnabled };
|
||||||
|
|
||||||
|
@ -51,6 +52,8 @@ QVariant AudioDeviceList::data(const QModelIndex& index, int role) const {
|
||||||
return _devices.at(index.row()).display;
|
return _devices.at(index.row()).display;
|
||||||
} else if (role == Qt::CheckStateRole) {
|
} else if (role == Qt::CheckStateRole) {
|
||||||
return _devices.at(index.row()).selected;
|
return _devices.at(index.row()).selected;
|
||||||
|
} else if (role == Qt::UserRole) {
|
||||||
|
return QVariant::fromValue<QAudioDeviceInfo>(_devices.at(index.row()).info);
|
||||||
} else {
|
} else {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue