mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 22:51:20 +02:00
fixed context switching issue with hmd. included additional output info for other audio crash issues
This commit is contained in:
parent
0410a45da1
commit
179f5e0873
3 changed files with 21 additions and 12 deletions
|
@ -164,8 +164,8 @@ void AudioDeviceList::resetDevice(bool contextIsHMD) {
|
||||||
QString deviceName = getTargetDevice(contextIsHMD, _mode);
|
QString deviceName = getTargetDevice(contextIsHMD, _mode);
|
||||||
// FIXME can't use blocking connections here, so we can't determine whether the switch succeeded or not
|
// 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
|
// We need to have the AudioClient emit signals on switch success / failure
|
||||||
QMetaObject::invokeMethod(client, "switchAudioDevice",
|
QMetaObject::invokeMethod(client, "switchAudioDevice",
|
||||||
Q_ARG(QAudio::Mode, _mode), Q_ARG(QString, deviceName));
|
Q_ARG(QAudio::Mode, _mode), Q_ARG(QString, deviceName), Q_ARG(bool, contextIsHMD));
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
bool switchResult = false;
|
bool switchResult = false;
|
||||||
|
|
|
@ -424,12 +424,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;
|
HifiAudioDeviceInfo result;
|
||||||
foreach (HifiAudioDeviceInfo audioDevice, getAvailableDevices(mode)) {
|
foreach (HifiAudioDeviceInfo audioDevice, getAvailableDevices(mode)) {
|
||||||
if (audioDevice.deviceName().trimmed() == deviceName.trimmed()) {
|
if (audioDevice.deviceName().trimmed() == deviceName.trimmed()) {
|
||||||
result = audioDevice;
|
if ((!isHmd && audioDevice.getDeviceType() != HifiAudioDeviceInfo::hmd) || (isHmd && audioDevice.getDeviceType() != HifiAudioDeviceInfo::desktop)) {
|
||||||
break;
|
result = audioDevice;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -986,13 +988,18 @@ void AudioClient::selectAudioFormat(const QString& selectedCodecName) {
|
||||||
|
|
||||||
void AudioClient::changeDefault(HifiAudioDeviceInfo newDefault, QAudio::Mode mode) {
|
void AudioClient::changeDefault(HifiAudioDeviceInfo newDefault, QAudio::Mode mode) {
|
||||||
HifiAudioDeviceInfo currentDevice = mode == QAudio::AudioInput ? _inputDeviceInfo : _outputDeviceInfo;
|
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);
|
switchAudioDevice(mode, newDefault);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioClient::switchAudioDevice(QAudio::Mode mode, const HifiAudioDeviceInfo& deviceInfo) {
|
bool AudioClient::switchAudioDevice(QAudio::Mode mode, const HifiAudioDeviceInfo& deviceInfo) {
|
||||||
auto device = deviceInfo;
|
auto device = deviceInfo;
|
||||||
|
if (deviceInfo.getDevice().isNull()) {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << " switching to null device :"
|
||||||
|
<< deviceInfo.deviceName() << " : " << deviceInfo.getDevice().deviceName();
|
||||||
|
}
|
||||||
|
|
||||||
if (mode == QAudio::AudioInput) {
|
if (mode == QAudio::AudioInput) {
|
||||||
return switchInputToAudioDevice(device);
|
return switchInputToAudioDevice(device);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1000,8 +1007,8 @@ bool AudioClient::switchAudioDevice(QAudio::Mode mode, const HifiAudioDeviceInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioClient::switchAudioDevice(QAudio::Mode mode, const QString& deviceName) {
|
bool AudioClient::switchAudioDevice(QAudio::Mode mode, const QString& deviceName, bool isHmd) {
|
||||||
return switchAudioDevice(mode, getNamedAudioDeviceForMode(mode, deviceName));
|
return switchAudioDevice(mode, getNamedAudioDeviceForMode(mode, deviceName, isHmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioClient::configureReverb() {
|
void AudioClient::configureReverb() {
|
||||||
|
@ -1809,7 +1816,8 @@ void AudioClient::outputFormatChanged() {
|
||||||
bool AudioClient::switchInputToAudioDevice(const HifiAudioDeviceInfo inputDeviceInfo, bool isShutdownRequest) {
|
bool AudioClient::switchInputToAudioDevice(const HifiAudioDeviceInfo inputDeviceInfo, bool isShutdownRequest) {
|
||||||
Q_ASSERT_X(QThread::currentThread() == thread(), Q_FUNC_INFO, "Function invoked on wrong thread");
|
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()
|
||||||
|
<<"-- new device: "<< inputDeviceInfo.deviceName() <<":"<< inputDeviceInfo.getDevice().deviceName() << "]";
|
||||||
bool supportedFormat = false;
|
bool supportedFormat = false;
|
||||||
|
|
||||||
// NOTE: device start() uses the Qt internal device list
|
// NOTE: device start() uses the Qt internal device list
|
||||||
|
@ -2044,8 +2052,9 @@ void AudioClient::noteAwakening() {
|
||||||
|
|
||||||
bool AudioClient::switchOutputToAudioDevice(const HifiAudioDeviceInfo outputDeviceInfo, bool isShutdownRequest) {
|
bool AudioClient::switchOutputToAudioDevice(const HifiAudioDeviceInfo outputDeviceInfo, bool isShutdownRequest) {
|
||||||
Q_ASSERT_X(QThread::currentThread() == thread(), Q_FUNC_INFO, "Function invoked on wrong thread");
|
Q_ASSERT_X(QThread::currentThread() == thread(), Q_FUNC_INFO, "Function invoked on wrong thread");
|
||||||
|
|
||||||
qCDebug(audioclient) << "AudioClient::switchOutputToAudioDevice() outputDeviceInfo: [" << outputDeviceInfo.deviceName() << "]";
|
qCDebug(audioclient) << __FUNCTION__ << "inputDeviceInfo: [" << _outputDeviceInfo.deviceName() << ":" << _outputDeviceInfo.getDevice().deviceName()
|
||||||
|
<< "-- new device: " << outputDeviceInfo.deviceName() << ":" << outputDeviceInfo.getDevice().deviceName() << "]";
|
||||||
bool supportedFormat = false;
|
bool supportedFormat = false;
|
||||||
|
|
||||||
// NOTE: device start() uses the Qt internal device list
|
// NOTE: device start() uses the Qt internal device list
|
||||||
|
|
|
@ -242,7 +242,7 @@ public slots:
|
||||||
|
|
||||||
// calling with a null QAudioDevice will use the system default
|
// 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 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
|
// Qt opensles plugin is not able to detect when the headset is plugged in
|
||||||
void setHeadsetPluggedIn(bool pluggedIn);
|
void setHeadsetPluggedIn(bool pluggedIn);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue