Fix audio selection issue

This commit is contained in:
Karol Suprynowicz 2025-02-21 19:11:47 +01:00 committed by HifiExperiments
parent 22bd86f122
commit 343a8ac7ed
5 changed files with 17 additions and 8 deletions

View file

@ -24,6 +24,10 @@
using MutedGetter = std::function<bool()>;
using MutedSetter = std::function<void(bool)>;
#define OVERTE_AUDIO_STRING "Audio"
#define OVERTE_AUDIO_HMD_STRING "VR"
#define OVERTE_AUDIO_DESKTOP_STRING "Desktop"
namespace scripting {
class Audio : public AudioScriptingInterface, protected ReadWriteLockable {

View file

@ -22,13 +22,14 @@
#include "AudioClient.h"
#include "Audio.h"
#include "UserActivityLogger.h"
#include "HifiAudioDeviceInfo.h"
using namespace scripting;
static Setting::Handle<QString> desktopInputDeviceSetting { QStringList { Audio::AUDIO, Audio::DESKTOP, "INPUT" }};
static Setting::Handle<QString> desktopOutputDeviceSetting { QStringList { Audio::AUDIO, Audio::DESKTOP, "OUTPUT" }};
static Setting::Handle<QString> hmdInputDeviceSetting { QStringList { Audio::AUDIO, Audio::HMD, "INPUT" }};
static Setting::Handle<QString> hmdOutputDeviceSetting { QStringList { Audio::AUDIO, Audio::HMD, "OUTPUT" }};
static Setting::Handle<QString> desktopInputDeviceSetting { QStringList { OVERTE_AUDIO_STRING, OVERTE_AUDIO_DESKTOP_STRING, "INPUT" }, HIFI_AUDIO_DEVICE_INFO_DEFAULT_DEVICE_NAME};
static Setting::Handle<QString> desktopOutputDeviceSetting { QStringList { OVERTE_AUDIO_STRING, OVERTE_AUDIO_DESKTOP_STRING, "OUTPUT" }, HIFI_AUDIO_DEVICE_INFO_DEFAULT_DEVICE_NAME};
static Setting::Handle<QString> hmdInputDeviceSetting { QStringList { OVERTE_AUDIO_STRING, OVERTE_AUDIO_HMD_STRING, "INPUT" }, HIFI_AUDIO_DEVICE_INFO_DEFAULT_DEVICE_NAME};
static Setting::Handle<QString> hmdOutputDeviceSetting { QStringList { OVERTE_AUDIO_STRING, OVERTE_AUDIO_HMD_STRING, "OUTPUT" }, HIFI_AUDIO_DEVICE_INFO_DEFAULT_DEVICE_NAME};
Q_DECLARE_METATYPE(HifiAudioDeviceInfo);

View file

@ -343,6 +343,7 @@ AudioClient::AudioClient() {
defaultAudioDeviceName(QAudio::AudioInput);
defaultAudioDeviceName(QAudio::AudioOutput);
checkDevices();
// start a thread to detect any device changes
_checkDevicesTimer = new QTimer(this);
const unsigned long DEVICE_CHECK_INTERVAL_MSECS = 2 * 1000;
@ -807,9 +808,10 @@ void AudioClient::start() {
inputName = _hmdInputName;
outputName = _hmdOutputName;
}
//initialize input to the dummy device to prevent starves
switchInputToAudioDevice(HifiAudioDeviceInfo());
// Input was originally set to HifiAudioDeviceInfo(), but that was causing trouble.
//Original comment: initialize input to the dummy device to prevent starves
switchInputToAudioDevice(defaultAudioDeviceForMode(QAudio::AudioInput, QString()));
switchOutputToAudioDevice(defaultAudioDeviceForMode(QAudio::AudioOutput, QString()));
#if defined(Q_OS_ANDROID)

View file

@ -12,7 +12,7 @@
#include "HifiAudioDeviceInfo.h"
const QString HifiAudioDeviceInfo::DEFAULT_DEVICE_NAME = "default ";
const QString HifiAudioDeviceInfo::DEFAULT_DEVICE_NAME = HIFI_AUDIO_DEVICE_INFO_DEFAULT_DEVICE_NAME;
void HifiAudioDeviceInfo::setDevice(QAudioDeviceInfo devInfo) {
_audioDeviceInfo = devInfo;

View file

@ -19,6 +19,8 @@
#include <QAudio>
#include <QString>
#define HIFI_AUDIO_DEVICE_INFO_DEFAULT_DEVICE_NAME "default "
class HifiAudioDeviceInfo : public QObject {
Q_OBJECT