mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Merge pull request #16381 from amerhifi/amer-dev471-re
case Dev 471: HMD default audio behavior
This commit is contained in:
commit
42234b119f
11 changed files with 173 additions and 67 deletions
|
@ -258,13 +258,12 @@ Flickable {
|
|||
Layout.preferredHeight: contentItem.height
|
||||
Layout.topMargin: simplifiedUI.margins.settings.settingsGroupTopMargin
|
||||
interactive: false
|
||||
spacing: simplifiedUI.margins.settings.spacingBetweenRadiobuttons
|
||||
clip: true
|
||||
model: AudioScriptingInterface.devices.input
|
||||
delegate: Item {
|
||||
width: parent.width
|
||||
height: inputDeviceCheckbox.height
|
||||
|
||||
width: parent.width
|
||||
height: model.type != "hmd" ? inputDeviceCheckbox.height + simplifiedUI.margins.settings.spacingBetweenRadiobuttons : 0
|
||||
visible: model.type != "hmd"
|
||||
SimplifiedControls.RadioButton {
|
||||
id: inputDeviceCheckbox
|
||||
anchors.left: parent.left
|
||||
|
@ -354,13 +353,12 @@ Flickable {
|
|||
Layout.preferredHeight: contentItem.height
|
||||
Layout.topMargin: simplifiedUI.margins.settings.settingsGroupTopMargin
|
||||
interactive: false
|
||||
spacing: simplifiedUI.margins.settings.spacingBetweenRadiobuttons
|
||||
clip: true
|
||||
model: AudioScriptingInterface.devices.output
|
||||
delegate: Item {
|
||||
width: parent.width
|
||||
height: outputDeviceCheckbox.height
|
||||
|
||||
height: model.type != "hmd" ? outputDeviceCheckbox.height +simplifiedUI.margins.settings.spacingBetweenRadiobuttons : 0
|
||||
visible: model.type != "hmd"
|
||||
SimplifiedControls.RadioButton {
|
||||
id: outputDeviceCheckbox
|
||||
anchors.left: parent.left
|
||||
|
|
|
@ -259,13 +259,13 @@ Flickable {
|
|||
Layout.preferredHeight: contentItem.height
|
||||
Layout.topMargin: simplifiedUI.margins.settings.settingsGroupTopMargin
|
||||
interactive: false
|
||||
spacing: simplifiedUI.margins.settings.spacingBetweenRadiobuttons
|
||||
clip: true
|
||||
model: AudioScriptingInterface.devices.input
|
||||
delegate: Item {
|
||||
width: parent.width
|
||||
height: inputDeviceCheckbox.height
|
||||
|
||||
width: parent.width
|
||||
height: model.type != "desktop" ? inputDeviceCheckbox.height + simplifiedUI.margins.settings.spacingBetweenRadiobuttons : 0
|
||||
visible: model.type != "desktop"
|
||||
|
||||
SimplifiedControls.RadioButton {
|
||||
id: inputDeviceCheckbox
|
||||
anchors.left: parent.left
|
||||
|
@ -355,13 +355,12 @@ Flickable {
|
|||
Layout.preferredHeight: contentItem.height
|
||||
Layout.topMargin: simplifiedUI.margins.settings.settingsGroupTopMargin
|
||||
interactive: false
|
||||
spacing: simplifiedUI.margins.settings.spacingBetweenRadiobuttons
|
||||
clip: true
|
||||
model: AudioScriptingInterface.devices.output
|
||||
delegate: Item {
|
||||
width: parent.width
|
||||
height: outputDeviceCheckbox.height
|
||||
|
||||
height: model.type != "desktop" ? outputDeviceCheckbox.height + simplifiedUI.margins.settings.spacingBetweenRadiobuttons : 0
|
||||
visible: model.type != "desktop"
|
||||
SimplifiedControls.RadioButton {
|
||||
id: outputDeviceCheckbox
|
||||
anchors.left: parent.left
|
||||
|
|
|
@ -44,7 +44,8 @@ enum AudioDeviceRole {
|
|||
SelectedDesktopRole,
|
||||
SelectedHMDRole,
|
||||
PeakRole,
|
||||
InfoRole
|
||||
InfoRole,
|
||||
TypeRole
|
||||
};
|
||||
|
||||
QHash<int, QByteArray> AudioDeviceList::_roles {
|
||||
|
@ -52,7 +53,8 @@ QHash<int, QByteArray> AudioDeviceList::_roles {
|
|||
{ SelectedDesktopRole, "selectedDesktop" },
|
||||
{ SelectedHMDRole, "selectedHMD" },
|
||||
{ PeakRole, "peak" },
|
||||
{ InfoRole, "info" }
|
||||
{ InfoRole, "info" },
|
||||
{ TypeRole, "type"}
|
||||
};
|
||||
|
||||
static QString getTargetDevice(bool hmd, QAudio::Mode mode) {
|
||||
|
@ -60,12 +62,6 @@ static QString getTargetDevice(bool hmd, QAudio::Mode mode) {
|
|||
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();
|
||||
}
|
||||
} else {
|
||||
deviceName = HifiAudioDeviceInfo::DEFAULT_DEVICE_NAME;
|
||||
}
|
||||
|
@ -144,6 +140,8 @@ QVariant AudioDeviceList::data(const QModelIndex& index, int role) const {
|
|||
return _devices.at(index.row())->selectedHMD;
|
||||
} else if (role == InfoRole) {
|
||||
return QVariant::fromValue<HifiAudioDeviceInfo>(_devices.at(index.row())->info);
|
||||
} else if (role == TypeRole) {
|
||||
return _devices.at(index.row())->type;
|
||||
} else {
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -166,8 +164,8 @@ void AudioDeviceList::resetDevice(bool contextIsHMD) {
|
|||
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));
|
||||
QMetaObject::invokeMethod(client, "switchAudioDevice",
|
||||
Q_ARG(QAudio::Mode, _mode), Q_ARG(QString, deviceName), Q_ARG(bool, contextIsHMD));
|
||||
|
||||
#if 0
|
||||
bool switchResult = false;
|
||||
|
@ -265,13 +263,20 @@ void AudioDeviceList::onDevicesChanged(const QList<HifiAudioDeviceInfo>& devices
|
|||
bool hmdIsSelected = false;
|
||||
bool desktopIsSelected = false;
|
||||
|
||||
foreach(const HifiAudioDeviceInfo& deviceInfo, devices) {
|
||||
for (bool isHMD : {false, true}) {
|
||||
auto& backupSelectedDeviceName = isHMD ? _backupSelectedHMDDeviceName : _backupSelectedDesktopDeviceName;
|
||||
if (deviceInfo.deviceName() == backupSelectedDeviceName) {
|
||||
HifiAudioDeviceInfo& selectedDevice = isHMD ? _selectedHMDDevice : _selectedDesktopDevice;
|
||||
selectedDevice = deviceInfo;
|
||||
backupSelectedDeviceName.clear();
|
||||
if (!_backupSelectedDesktopDeviceName.isEmpty() && !_backupSelectedHMDDeviceName.isEmpty()) {
|
||||
foreach(const HifiAudioDeviceInfo& deviceInfo, devices) {
|
||||
for (bool isHMD : {false, true}) {
|
||||
auto& backupSelectedDeviceName = isHMD ? _backupSelectedHMDDeviceName : _backupSelectedDesktopDeviceName;
|
||||
if (deviceInfo.deviceName() == backupSelectedDeviceName) {
|
||||
if (isHMD && deviceInfo.getDeviceType() != HifiAudioDeviceInfo::desktop) {
|
||||
_selectedHMDDevice= deviceInfo;
|
||||
backupSelectedDeviceName.clear();
|
||||
} else if (!isHMD && deviceInfo.getDeviceType() != HifiAudioDeviceInfo::hmd) {
|
||||
_selectedDesktopDevice = deviceInfo;
|
||||
backupSelectedDeviceName.clear();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -281,10 +286,18 @@ void AudioDeviceList::onDevicesChanged(const QList<HifiAudioDeviceInfo>& devices
|
|||
device.info = deviceInfo;
|
||||
|
||||
if (deviceInfo.isDefault()) {
|
||||
if (deviceInfo.getMode() == QAudio::AudioInput) {
|
||||
device.display = "Computer's default microphone (recommended)";
|
||||
} else {
|
||||
device.display = "Computer's default audio (recommended)";
|
||||
if (deviceInfo.getDeviceType() == HifiAudioDeviceInfo::desktop) {
|
||||
if (deviceInfo.getMode() == QAudio::AudioInput) {
|
||||
device.display = "Computer's default microphone (recommended)";
|
||||
} else {
|
||||
device.display = "Computer's default audio (recommended)";
|
||||
}
|
||||
} else if (deviceInfo.getDeviceType() == HifiAudioDeviceInfo::hmd) {
|
||||
if (deviceInfo.getMode() == QAudio::AudioInput) {
|
||||
device.display = "Headset's default mic (recommended)";
|
||||
} else {
|
||||
device.display = "Headset's default audio (recommended)";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
device.display = device.info.deviceName()
|
||||
|
@ -292,6 +305,19 @@ void AudioDeviceList::onDevicesChanged(const QList<HifiAudioDeviceInfo>& devices
|
|||
.remove("Device")
|
||||
.replace(" )", ")");
|
||||
}
|
||||
|
||||
switch (deviceInfo.getDeviceType()) {
|
||||
case HifiAudioDeviceInfo::hmd:
|
||||
device.type = "hmd";
|
||||
break;
|
||||
case HifiAudioDeviceInfo::desktop:
|
||||
device.type = "desktop";
|
||||
break;
|
||||
case HifiAudioDeviceInfo::both:
|
||||
device.type = "both";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
for (bool isHMD : {false, true}) {
|
||||
HifiAudioDeviceInfo& selectedDevice = isHMD ? _selectedHMDDevice : _selectedDesktopDevice;
|
||||
|
@ -302,8 +328,14 @@ void AudioDeviceList::onDevicesChanged(const QList<HifiAudioDeviceInfo>& devices
|
|||
}
|
||||
else {
|
||||
//no selected device for context. fallback to saved
|
||||
const QString& savedDeviceName = isHMD ? _hmdSavedDeviceName : _desktopSavedDeviceName;
|
||||
isSelected = (device.info.deviceName() == savedDeviceName);
|
||||
QString& savedDeviceName = isHMD ? _hmdSavedDeviceName : _desktopSavedDeviceName;
|
||||
|
||||
if (device.info.deviceName() == savedDeviceName) {
|
||||
if ((isHMD && device.info.getDeviceType() != HifiAudioDeviceInfo::desktop) ||
|
||||
(!isHMD && device.info.getDeviceType() != HifiAudioDeviceInfo::hmd)) {
|
||||
isSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isSelected) {
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
QString display;
|
||||
bool selectedDesktop { false };
|
||||
bool selectedHMD { false };
|
||||
QString type;
|
||||
};
|
||||
|
||||
class AudioDeviceList : public QAbstractListModel {
|
||||
|
|
|
@ -6,6 +6,7 @@ setup_hifi_library(Network Multimedia ${PLATFORM_QT_COMPONENTS})
|
|||
link_hifi_libraries(audio plugins)
|
||||
include_hifi_library_headers(shared)
|
||||
include_hifi_library_headers(networking)
|
||||
include_hifi_library_headers(gpu)
|
||||
|
||||
if (ANDROID)
|
||||
else ()
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <QtMultimedia/QAudioInput>
|
||||
#include <QtMultimedia/QAudioOutput>
|
||||
|
||||
#include <shared/QtHelpers.h>
|
||||
#include <ThreadHelpers.h>
|
||||
#include <NodeList.h>
|
||||
#include <plugins/CodecPlugin.h>
|
||||
|
@ -47,6 +48,7 @@
|
|||
#include <SettingHandle.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <Transform.h>
|
||||
#include <plugins/DisplayPlugin.h>
|
||||
|
||||
#include "AudioClientLogging.h"
|
||||
#include "AudioLogging.h"
|
||||
|
@ -81,20 +83,50 @@ Mutex _recordMutex;
|
|||
|
||||
HifiAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode);
|
||||
|
||||
static QString getHmdAudioDeviceName(QAudio::Mode mode) {
|
||||
foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getAllDisplayPlugins()) {
|
||||
if (displayPlugin && displayPlugin->isHmd()) {
|
||||
if (mode == QAudio::AudioInput) {
|
||||
return displayPlugin->getPreferredAudioInDevice();
|
||||
} else {
|
||||
return displayPlugin->getPreferredAudioOutDevice();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
// thread-safe
|
||||
QList<HifiAudioDeviceInfo> getAvailableDevices(QAudio::Mode mode) {
|
||||
//get hmd device name prior to locking device mutex. in case of shutdown, this thread will be locked and audio client
|
||||
//cannot properly shut down.
|
||||
QString hmdDeviceName = getHmdAudioDeviceName(mode);
|
||||
|
||||
// NOTE: availableDevices() clobbers the Qt internal device list
|
||||
Lock lock(_deviceMutex);
|
||||
auto devices = QAudioDeviceInfo::availableDevices(mode);
|
||||
|
||||
QList<HifiAudioDeviceInfo> newDevices;
|
||||
|
||||
for (auto& device : devices) {
|
||||
newDevices.push_back(HifiAudioDeviceInfo(device, false, mode));
|
||||
}
|
||||
|
||||
newDevices.push_front(defaultAudioDeviceForMode(mode));
|
||||
|
||||
|
||||
if (!hmdDeviceName.isNull() && !hmdDeviceName.isEmpty()) {
|
||||
HifiAudioDeviceInfo hmdDevice;
|
||||
foreach(auto device, newDevices) {
|
||||
if (device.getDevice().deviceName() == hmdDeviceName) {
|
||||
hmdDevice = HifiAudioDeviceInfo(device.getDevice(), true, mode, HifiAudioDeviceInfo::hmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hmdDevice.getDevice().isNull()) {
|
||||
newDevices.push_front(hmdDevice);
|
||||
}
|
||||
}
|
||||
return newDevices;
|
||||
}
|
||||
|
||||
|
@ -110,8 +142,8 @@ void AudioClient::checkDevices() {
|
|||
auto inputDevices = getAvailableDevices(QAudio::AudioInput);
|
||||
auto outputDevices = getAvailableDevices(QAudio::AudioOutput);
|
||||
|
||||
QMetaObject::invokeMethod(this, "changeDefault", Q_ARG(HifiAudioDeviceInfo, inputDevices.first()), Q_ARG(QAudio::Mode, QAudio::AudioInput));
|
||||
QMetaObject::invokeMethod(this, "changeDefault", Q_ARG(HifiAudioDeviceInfo, outputDevices.first()), Q_ARG(QAudio::Mode, QAudio::AudioOutput));
|
||||
checkDefaultChanges(inputDevices);
|
||||
checkDefaultChanges(outputDevices);
|
||||
|
||||
Lock lock(_deviceMutex);
|
||||
if (inputDevices != _inputDevices) {
|
||||
|
@ -125,6 +157,14 @@ void AudioClient::checkDevices() {
|
|||
}
|
||||
}
|
||||
|
||||
void AudioClient::checkDefaultChanges(QList<HifiAudioDeviceInfo>& devices) {
|
||||
foreach(auto device, devices) {
|
||||
if (device.isDefault()) {
|
||||
QMetaObject::invokeMethod(this, "changeDefault", Q_ARG(HifiAudioDeviceInfo, device), Q_ARG(QAudio::Mode, device.getMode()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HifiAudioDeviceInfo AudioClient::getActiveAudioDevice(QAudio::Mode mode) const {
|
||||
Lock lock(_deviceMutex);
|
||||
|
||||
|
@ -386,12 +426,14 @@ void AudioClient::setAudioPaused(bool pause) {
|
|||
}
|
||||
}
|
||||
|
||||
HifiAudioDeviceInfo getNamedAudioDeviceForMode(QAudio::Mode mode, const QString& deviceName) {
|
||||
HifiAudioDeviceInfo getNamedAudioDeviceForMode(QAudio::Mode mode, const QString& deviceName, bool isHmd=false) {
|
||||
HifiAudioDeviceInfo result;
|
||||
foreach (HifiAudioDeviceInfo audioDevice, getAvailableDevices(mode)) {
|
||||
if (audioDevice.deviceName().trimmed() == deviceName.trimmed()) {
|
||||
result = audioDevice;
|
||||
break;
|
||||
if ((!isHmd && audioDevice.getDeviceType() != HifiAudioDeviceInfo::hmd) || (isHmd && audioDevice.getDeviceType() != HifiAudioDeviceInfo::desktop)) {
|
||||
result = audioDevice;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -477,7 +519,7 @@ HifiAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode) {
|
|||
// find a device in the list that matches the name we have and return it
|
||||
foreach(QAudioDeviceInfo audioDevice, devices){
|
||||
if (audioDevice.deviceName() == CFStringGetCStringPtr(deviceName, kCFStringEncodingMacRoman)) {
|
||||
return HifiAudioDeviceInfo(audioDevice, true, mode);
|
||||
return HifiAudioDeviceInfo(audioDevice, true, mode, HifiAudioDeviceInfo::desktop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -532,7 +574,7 @@ HifiAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode) {
|
|||
HifiAudioDeviceInfo foundDevice;
|
||||
foreach(QAudioDeviceInfo audioDevice, devices) {
|
||||
if (audioDevice.deviceName().trimmed() == deviceName.trimmed()) {
|
||||
foundDevice=HifiAudioDeviceInfo(audioDevice,true,mode);
|
||||
foundDevice = HifiAudioDeviceInfo(audioDevice, true, mode, HifiAudioDeviceInfo::desktop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -558,8 +600,8 @@ HifiAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode) {
|
|||
}
|
||||
#endif
|
||||
// fallback for failed lookup is the default device
|
||||
return (mode == QAudio::AudioInput) ? HifiAudioDeviceInfo(QAudioDeviceInfo::defaultInputDevice(), true,mode) :
|
||||
HifiAudioDeviceInfo(QAudioDeviceInfo::defaultOutputDevice(), true, mode);
|
||||
return (mode == QAudio::AudioInput) ? HifiAudioDeviceInfo(QAudioDeviceInfo::defaultInputDevice(), true, mode, HifiAudioDeviceInfo::desktop) :
|
||||
HifiAudioDeviceInfo(QAudioDeviceInfo::defaultOutputDevice(), true, mode, HifiAudioDeviceInfo::desktop);
|
||||
}
|
||||
|
||||
bool AudioClient::getNamedAudioDeviceForModeExists(QAudio::Mode mode, const QString& deviceName) {
|
||||
|
@ -763,6 +805,7 @@ void AudioClient::stop() {
|
|||
// Destruction of the pointers will occur when the parent object (this) is destroyed)
|
||||
{
|
||||
Lock lock(_checkDevicesMutex);
|
||||
_checkDevicesTimer->stop();
|
||||
_checkDevicesTimer = nullptr;
|
||||
}
|
||||
{
|
||||
|
@ -948,13 +991,18 @@ void AudioClient::selectAudioFormat(const QString& selectedCodecName) {
|
|||
|
||||
void AudioClient::changeDefault(HifiAudioDeviceInfo newDefault, QAudio::Mode mode) {
|
||||
HifiAudioDeviceInfo currentDevice = mode == QAudio::AudioInput ? _inputDeviceInfo : _outputDeviceInfo;
|
||||
if (currentDevice.isDefault() && currentDevice.getDevice() != newDefault.getDevice()) {
|
||||
if (currentDevice.isDefault() && currentDevice.getDeviceType() == newDefault.getDeviceType() && currentDevice.getDevice() != newDefault.getDevice()) {
|
||||
switchAudioDevice(mode, newDefault);
|
||||
}
|
||||
}
|
||||
|
||||
bool AudioClient::switchAudioDevice(QAudio::Mode mode, const HifiAudioDeviceInfo& deviceInfo) {
|
||||
auto device = deviceInfo;
|
||||
if (deviceInfo.getDevice().isNull()) {
|
||||
qCDebug(audioclient) << __FUNCTION__ << " switching to null device :"
|
||||
<< deviceInfo.deviceName() << " : " << deviceInfo.getDevice().deviceName();
|
||||
}
|
||||
|
||||
if (mode == QAudio::AudioInput) {
|
||||
return switchInputToAudioDevice(device);
|
||||
} else {
|
||||
|
@ -962,8 +1010,8 @@ bool AudioClient::switchAudioDevice(QAudio::Mode mode, const HifiAudioDeviceInfo
|
|||
}
|
||||
}
|
||||
|
||||
bool AudioClient::switchAudioDevice(QAudio::Mode mode, const QString& deviceName) {
|
||||
return switchAudioDevice(mode, getNamedAudioDeviceForMode(mode, deviceName));
|
||||
bool AudioClient::switchAudioDevice(QAudio::Mode mode, const QString& deviceName, bool isHmd) {
|
||||
return switchAudioDevice(mode, getNamedAudioDeviceForMode(mode, deviceName, isHmd));
|
||||
}
|
||||
|
||||
void AudioClient::configureReverb() {
|
||||
|
@ -1771,7 +1819,8 @@ void AudioClient::outputFormatChanged() {
|
|||
bool AudioClient::switchInputToAudioDevice(const HifiAudioDeviceInfo inputDeviceInfo, bool isShutdownRequest) {
|
||||
Q_ASSERT_X(QThread::currentThread() == thread(), Q_FUNC_INFO, "Function invoked on wrong thread");
|
||||
|
||||
qCDebug(audioclient) << __FUNCTION__ << "inputDeviceInfo: [" << _inputDeviceInfo.deviceName() <<"----"<<inputDeviceInfo.getDevice().deviceName() << "]";
|
||||
qCDebug(audioclient) << __FUNCTION__ << "_inputDeviceInfo: [" << _inputDeviceInfo.deviceName() << ":" << _inputDeviceInfo.getDevice().deviceName()
|
||||
<< "-- inputDeviceInfo:" << inputDeviceInfo.deviceName() << ":" << inputDeviceInfo.getDevice().deviceName() << "]";
|
||||
bool supportedFormat = false;
|
||||
|
||||
// NOTE: device start() uses the Qt internal device list
|
||||
|
@ -1823,8 +1872,9 @@ bool AudioClient::switchInputToAudioDevice(const HifiAudioDeviceInfo inputDevice
|
|||
}
|
||||
|
||||
if (!inputDeviceInfo.getDevice().isNull()) {
|
||||
qCDebug(audioclient) << "The audio input device " << inputDeviceInfo.deviceName() << "is available.";
|
||||
qCDebug(audioclient) << "The audio input device" << inputDeviceInfo.deviceName() << ":" << inputDeviceInfo.getDevice().deviceName() << "is available.";
|
||||
|
||||
//do not update UI that we're changing devices if default or same device
|
||||
bool doEmit = _inputDeviceInfo.deviceName() != inputDeviceInfo.deviceName();
|
||||
_inputDeviceInfo = inputDeviceInfo;
|
||||
if (doEmit) {
|
||||
|
@ -1959,9 +2009,9 @@ void AudioClient::setHeadsetPluggedIn(bool pluggedIn) {
|
|||
bool aecEnabled = enableAEC.get();
|
||||
|
||||
if ((pluggedIn || !aecEnabled) && _inputDeviceInfo.deviceName() != VOICE_RECOGNITION) {
|
||||
switchAudioDevice(QAudio::AudioInput, VOICE_RECOGNITION);
|
||||
switchAudioDevice(QAudio::AudioInput, VOICE_RECOGNITION, false);
|
||||
} else if (!pluggedIn && aecEnabled && _inputDeviceInfo.deviceName() != VOICE_COMMUNICATION) {
|
||||
switchAudioDevice(QAudio::AudioInput, VOICE_COMMUNICATION);
|
||||
switchAudioDevice(QAudio::AudioInput, VOICE_COMMUNICATION, false);
|
||||
}
|
||||
}
|
||||
_isHeadsetPluggedIn = pluggedIn;
|
||||
|
@ -2006,8 +2056,9 @@ void AudioClient::noteAwakening() {
|
|||
|
||||
bool AudioClient::switchOutputToAudioDevice(const HifiAudioDeviceInfo outputDeviceInfo, bool isShutdownRequest) {
|
||||
Q_ASSERT_X(QThread::currentThread() == thread(), Q_FUNC_INFO, "Function invoked on wrong thread");
|
||||
|
||||
qCDebug(audioclient) << "AudioClient::switchOutputToAudioDevice() outputDeviceInfo: [" << outputDeviceInfo.deviceName() << "]";
|
||||
|
||||
qCDebug(audioclient) << __FUNCTION__ << "_outputdeviceInfo: [" << _outputDeviceInfo.deviceName() << ":" << _outputDeviceInfo.getDevice().deviceName()
|
||||
<< "-- outputDeviceInfo:" << outputDeviceInfo.deviceName() << ":" << outputDeviceInfo.getDevice().deviceName() << "]";
|
||||
bool supportedFormat = false;
|
||||
|
||||
// NOTE: device start() uses the Qt internal device list
|
||||
|
@ -2063,7 +2114,9 @@ bool AudioClient::switchOutputToAudioDevice(const HifiAudioDeviceInfo outputDevi
|
|||
}
|
||||
|
||||
if (!outputDeviceInfo.getDevice().isNull()) {
|
||||
qCDebug(audioclient) << "The audio output device " << outputDeviceInfo.deviceName() << "is available.";
|
||||
qCDebug(audioclient) << "The audio output device" << outputDeviceInfo.deviceName() << ":" << outputDeviceInfo.getDevice().deviceName() << "is available.";
|
||||
|
||||
//do not update UI that we're changing devices if default or same device
|
||||
bool doEmit = _outputDeviceInfo.deviceName() != outputDeviceInfo.deviceName();
|
||||
_outputDeviceInfo = outputDeviceInfo;
|
||||
if (doEmit) {
|
||||
|
|
|
@ -238,10 +238,11 @@ public slots:
|
|||
|
||||
bool shouldLoopbackInjectors() override { return _shouldEchoToServer; }
|
||||
Q_INVOKABLE void changeDefault(HifiAudioDeviceInfo newDefault, QAudio::Mode mode);
|
||||
void checkDefaultChanges(QList<HifiAudioDeviceInfo>& devices);
|
||||
|
||||
// calling with a null QAudioDevice will use the system default
|
||||
bool switchAudioDevice(QAudio::Mode mode, const HifiAudioDeviceInfo& deviceInfo = HifiAudioDeviceInfo());
|
||||
bool switchAudioDevice(QAudio::Mode mode, const QString& deviceName);
|
||||
bool switchAudioDevice(QAudio::Mode mode, const QString& deviceName, bool isHmd);
|
||||
// Qt opensles plugin is not able to detect when the headset is plugged in
|
||||
void setHeadsetPluggedIn(bool pluggedIn);
|
||||
|
||||
|
|
|
@ -22,15 +22,14 @@ HifiAudioDeviceInfo& HifiAudioDeviceInfo::operator=(const HifiAudioDeviceInfo& o
|
|||
_audioDeviceInfo = other.getDevice();
|
||||
_mode = other.getMode();
|
||||
_isDefault = other.isDefault();
|
||||
_deviceType = other.getDeviceType();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool HifiAudioDeviceInfo::operator==(const HifiAudioDeviceInfo& rhs) const {
|
||||
//Does the QAudioDeviceinfo match as well as is this the default device or
|
||||
return getDevice() == rhs.getDevice() && isDefault() == rhs.isDefault();
|
||||
}
|
||||
bool HifiAudioDeviceInfo::operator!=(const HifiAudioDeviceInfo& rhs) const {
|
||||
return getDevice() != rhs.getDevice() || isDefault() != rhs.isDefault();
|
||||
}
|
||||
|
||||
}
|
|
@ -23,19 +23,27 @@ class HifiAudioDeviceInfo : public QObject {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum DeviceType {
|
||||
desktop,
|
||||
hmd,
|
||||
both
|
||||
};
|
||||
|
||||
HifiAudioDeviceInfo() : QObject() {}
|
||||
HifiAudioDeviceInfo(const HifiAudioDeviceInfo &deviceInfo) : QObject(){
|
||||
_audioDeviceInfo = deviceInfo.getDevice();
|
||||
_mode = deviceInfo.getMode();
|
||||
_isDefault = deviceInfo.isDefault();
|
||||
_deviceType = deviceInfo.getDeviceType();
|
||||
}
|
||||
|
||||
HifiAudioDeviceInfo(QAudioDeviceInfo deviceInfo, bool isDefault, QAudio::Mode mode) :
|
||||
HifiAudioDeviceInfo(QAudioDeviceInfo deviceInfo, bool isDefault, QAudio::Mode mode, DeviceType devType=both) :
|
||||
_audioDeviceInfo(deviceInfo),
|
||||
_isDefault(isDefault),
|
||||
_mode(mode){
|
||||
_mode(mode),
|
||||
_deviceType(devType){
|
||||
}
|
||||
|
||||
|
||||
void setMode(QAudio::Mode mode) { _mode = mode; }
|
||||
void setIsDefault() { _isDefault = true; }
|
||||
void setDevice(QAudioDeviceInfo devInfo);
|
||||
|
@ -52,7 +60,7 @@ public:
|
|||
QAudioDeviceInfo getDevice() const { return _audioDeviceInfo; }
|
||||
bool isDefault() const { return _isDefault; }
|
||||
QAudio::Mode getMode() const { return _mode; }
|
||||
|
||||
DeviceType getDeviceType() const { return _deviceType; }
|
||||
HifiAudioDeviceInfo& operator=(const HifiAudioDeviceInfo& other);
|
||||
bool operator==(const HifiAudioDeviceInfo& rhs) const;
|
||||
bool operator!=(const HifiAudioDeviceInfo& rhs) const;
|
||||
|
@ -61,6 +69,7 @@ private:
|
|||
QAudioDeviceInfo _audioDeviceInfo;
|
||||
bool _isDefault { false };
|
||||
QAudio::Mode _mode { QAudio::AudioInput };
|
||||
DeviceType _deviceType{ both };
|
||||
|
||||
public:
|
||||
static const QString DEFAULT_DEVICE_NAME;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <QtCore/QDir>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QPluginLoader>
|
||||
#include <shared/QtHelpers.h>
|
||||
|
||||
//#define HIFI_PLUGINMANAGER_DEBUG
|
||||
#if defined(HIFI_PLUGINMANAGER_DEBUG)
|
||||
|
@ -21,6 +22,7 @@
|
|||
|
||||
#include <DependencyManager.h>
|
||||
#include <UserActivityLogger.h>
|
||||
#include <QThreadPool>
|
||||
|
||||
#include "RuntimePlugin.h"
|
||||
#include "CodecPlugin.h"
|
||||
|
@ -221,7 +223,17 @@ const OculusPlatformPluginPointer PluginManager::getOculusPlatformPlugin() {
|
|||
return oculusPlatformPlugin;
|
||||
}
|
||||
|
||||
const DisplayPluginList& PluginManager::getDisplayPlugins() {
|
||||
DisplayPluginList PluginManager::getAllDisplayPlugins() {
|
||||
if (thread() != QThread::currentThread()) {
|
||||
DisplayPluginList list;
|
||||
QMetaObject::invokeMethod(this, "getAllDisplayPlugins", Qt::BlockingQueuedConnection, Q_RETURN_ARG(DisplayPluginList, list));
|
||||
return list;
|
||||
} else {
|
||||
return _displayPlugins;
|
||||
}
|
||||
}
|
||||
|
||||
const DisplayPluginList& PluginManager::getDisplayPlugins() {
|
||||
static std::once_flag once;
|
||||
static auto deviceAddedCallback = [](QString deviceName) {
|
||||
qCDebug(plugins) << "Added device: " << deviceName;
|
||||
|
|
|
@ -51,6 +51,7 @@ public:
|
|||
|
||||
using PluginFilter = std::function<bool(const QJsonObject&)>;
|
||||
void setPluginFilter(PluginFilter pluginFilter) { _pluginFilter = pluginFilter; }
|
||||
Q_INVOKABLE DisplayPluginList getAllDisplayPlugins();
|
||||
|
||||
signals:
|
||||
void inputDeviceRunningChanged(const QString& pluginName, bool isRunning, const QStringList& runningDevices);
|
||||
|
|
Loading…
Reference in a new issue