addressing comments

This commit is contained in:
amerhifi 2019-10-22 07:17:57 -07:00
parent 68681fdb2e
commit a8602195d4
7 changed files with 19 additions and 24 deletions

View file

@ -62,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;
}
@ -269,13 +263,15 @@ 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) {
HifiAudioDeviceInfo& selectedDevice = isHMD ? _selectedHMDDevice : _selectedDesktopDevice;
selectedDevice = deviceInfo;
backupSelectedDeviceName.clear();
}
}
}
}

View file

@ -7,6 +7,7 @@ link_hifi_libraries(audio plugins)
include_hifi_library_headers(shared)
include_hifi_library_headers(networking)
include_hifi_library_headers(gpu)
if (ANDROID)
else ()
target_webrtc()

View file

@ -39,6 +39,7 @@
#include <QtMultimedia/QAudioInput>
#include <QtMultimedia/QAudioOutput>
#include <shared/QtHelpers.h>
#include <ThreadHelpers.h>
#include <NodeList.h>
#include <plugins/CodecPlugin.h>
@ -48,6 +49,7 @@
#include <SharedUtil.h>
#include <Transform.h>
#include <plugins/DisplayPlugin.h>
#include "AudioClientLogging.h"
#include "AudioLogging.h"
#include "AudioHelpers.h"
@ -81,7 +83,7 @@ Mutex _recordMutex;
HifiAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode);
#include <shared/QtHelpers.h>
static QString getHmdAudioDeviceName(QAudio::Mode mode) {
foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getAllDisplayPlugins()) {
if (displayPlugin && displayPlugin->isHmd()) {
@ -568,7 +570,7 @@ HifiAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode) {
HifiAudioDeviceInfo foundDevice;
foreach(QAudioDeviceInfo audioDevice, devices) {
if (audioDevice.deviceName().trimmed() == deviceName.trimmed()) {
foundDevice=HifiAudioDeviceInfo(audioDevice,true,mode, HifiAudioDeviceInfo::desktop);
foundDevice=HifiAudioDeviceInfo(audioDevice, true, mode, HifiAudioDeviceInfo::desktop);
break;
}
}
@ -594,7 +596,7 @@ HifiAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode) {
}
#endif
// fallback for failed lookup is the default device
return (mode == QAudio::AudioInput) ? HifiAudioDeviceInfo(QAudioDeviceInfo::defaultInputDevice(), true,mode, HifiAudioDeviceInfo::desktop) :
return (mode == QAudio::AudioInput) ? HifiAudioDeviceInfo(QAudioDeviceInfo::defaultInputDevice(), true, mode, HifiAudioDeviceInfo::desktop) :
HifiAudioDeviceInfo(QAudioDeviceInfo::defaultOutputDevice(), true, mode, HifiAudioDeviceInfo::desktop);
}

View file

@ -32,5 +32,4 @@ bool HifiAudioDeviceInfo::operator==(const HifiAudioDeviceInfo& rhs) const {
}
bool HifiAudioDeviceInfo::operator!=(const HifiAudioDeviceInfo& rhs) const {
return getDevice() != rhs.getDevice() || isDefault() != rhs.isDefault();
}
}

View file

@ -37,7 +37,6 @@ public:
_deviceType = deviceInfo.getDeviceType();
}
HifiAudioDeviceInfo(QAudioDeviceInfo deviceInfo, bool isDefault, QAudio::Mode mode, DeviceType devType=both) :
_audioDeviceInfo(deviceInfo),
_isDefault(isDefault),
@ -66,7 +65,6 @@ public:
bool operator==(const HifiAudioDeviceInfo& rhs) const;
bool operator!=(const HifiAudioDeviceInfo& rhs) const;
private:
QAudioDeviceInfo _audioDeviceInfo;
bool _isDefault { false };

View file

@ -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,10 +223,6 @@ const OculusPlatformPluginPointer PluginManager::getOculusPlatformPlugin() {
return oculusPlatformPlugin;
}
#include <shared/QtHelpers.h>
#include <QThreadPool>
DisplayPluginList PluginManager::getAllDisplayPlugins() {
if (thread() != QThread::currentThread()) {
DisplayPluginList list;

View file

@ -52,6 +52,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);