mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 22:22:54 +02:00
add better debugging for audio problems
use OS default device if settings have no values
This commit is contained in:
parent
dd3a7f7249
commit
6fe20f90a3
3 changed files with 67 additions and 9 deletions
|
@ -161,7 +161,12 @@ Rectangle {
|
||||||
text.text: devicename
|
text.text: devicename
|
||||||
onCheckBoxClicked: {
|
onCheckBoxClicked: {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
AudioDevice.setInputDeviceAsync(devicename)
|
if (devicename.length > 0) {
|
||||||
|
console.log("Audio.qml about to call AudioDevice.setInputDeviceAsync().devicename:" + devicename);
|
||||||
|
AudioDevice.setInputDeviceAsync(devicename);
|
||||||
|
} else {
|
||||||
|
console.log("Audio.qml attempted to set input device to empty device name.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +222,13 @@ Rectangle {
|
||||||
text.text: devicename
|
text.text: devicename
|
||||||
onCheckBoxClicked: {
|
onCheckBoxClicked: {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
AudioDevice.setOutputDeviceAsync(devicename)
|
if (devicename.length > 0) {
|
||||||
|
console.log("Audio.qml about to call AudioDevice.setOutputDeviceAsync().devicename:" + devicename);
|
||||||
|
AudioDevice.setOutputDeviceAsync(devicename);
|
||||||
|
} else {
|
||||||
|
console.log("Audio.qml attempted to set output device to empty device name.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "AudioClient.h"
|
#include <AudioClient.h>
|
||||||
|
#include <AudioClientLogging.h>
|
||||||
|
|
||||||
#include "AudioDeviceScriptingInterface.h"
|
#include "AudioDeviceScriptingInterface.h"
|
||||||
#include "SettingsScriptingInterface.h"
|
#include "SettingsScriptingInterface.h"
|
||||||
|
|
||||||
|
@ -44,17 +46,23 @@ AudioDeviceScriptingInterface::AudioDeviceScriptingInterface(): QAbstractListMod
|
||||||
onDeviceChanged();
|
onDeviceChanged();
|
||||||
//set up previously saved device
|
//set up previously saved device
|
||||||
SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance();
|
SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance();
|
||||||
const QString inDevice = settings->getValue("audio_input_device").toString();
|
const QString inDevice = settings->getValue("audio_input_device", _currentInputDevice).toString();
|
||||||
if (inDevice != _currentInputDevice) {
|
if (inDevice != _currentInputDevice) {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "about to call setInputDeviceAsync() device: [" << inDevice << "] _currentInputDevice:" << _currentInputDevice;
|
||||||
setInputDeviceAsync(inDevice);
|
setInputDeviceAsync(inDevice);
|
||||||
}
|
}
|
||||||
const QString outDevice = settings->getValue("audio_output_device").toString();
|
|
||||||
|
// If the audio_output_device setting is not available, use the _currentOutputDevice
|
||||||
|
auto outDevice = settings->getValue("audio_output_device", _currentOutputDevice).toString();
|
||||||
if (outDevice != _currentOutputDevice) {
|
if (outDevice != _currentOutputDevice) {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "about to call setOutputDeviceAsync() outDevice: [" << outDevice << "] _currentOutputDevice:" << _currentOutputDevice;
|
||||||
setOutputDeviceAsync(outDevice);
|
setOutputDeviceAsync(outDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioDeviceScriptingInterface::setInputDevice(const QString& deviceName) {
|
bool AudioDeviceScriptingInterface::setInputDevice(const QString& deviceName) {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName;
|
||||||
|
|
||||||
bool result;
|
bool result;
|
||||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchInputToAudioDevice",
|
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchInputToAudioDevice",
|
||||||
Qt::BlockingQueuedConnection,
|
Qt::BlockingQueuedConnection,
|
||||||
|
@ -64,6 +72,9 @@ bool AudioDeviceScriptingInterface::setInputDevice(const QString& deviceName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioDeviceScriptingInterface::setOutputDevice(const QString& deviceName) {
|
bool AudioDeviceScriptingInterface::setOutputDevice(const QString& deviceName) {
|
||||||
|
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName;
|
||||||
|
|
||||||
bool result;
|
bool result;
|
||||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchOutputToAudioDevice",
|
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchOutputToAudioDevice",
|
||||||
Qt::BlockingQueuedConnection,
|
Qt::BlockingQueuedConnection,
|
||||||
|
@ -86,8 +97,10 @@ bool AudioDeviceScriptingInterface::setDeviceFromMenu(const QString& deviceMenuN
|
||||||
for (ScriptingAudioDeviceInfo di: _devices) {
|
for (ScriptingAudioDeviceInfo di: _devices) {
|
||||||
if (mode == di.mode && deviceMenuName.contains(di.name)) {
|
if (mode == di.mode && deviceMenuName.contains(di.name)) {
|
||||||
if (mode == QAudio::AudioOutput) {
|
if (mode == QAudio::AudioOutput) {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "about to call setOutputDeviceAsync() device: [" << di.name << "]";
|
||||||
setOutputDeviceAsync(di.name);
|
setOutputDeviceAsync(di.name);
|
||||||
} else {
|
} else {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "about to call setInputDeviceAsync() device: [" << di.name << "]";
|
||||||
setInputDeviceAsync(di.name);
|
setInputDeviceAsync(di.name);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -98,12 +111,26 @@ bool AudioDeviceScriptingInterface::setDeviceFromMenu(const QString& deviceMenuN
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioDeviceScriptingInterface::setInputDeviceAsync(const QString& deviceName) {
|
void AudioDeviceScriptingInterface::setInputDeviceAsync(const QString& deviceName) {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName;
|
||||||
|
|
||||||
|
if (deviceName.isEmpty()) {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "attempt to set empty deviceName:" << deviceName << "... ignoring!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchInputToAudioDevice",
|
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchInputToAudioDevice",
|
||||||
Qt::QueuedConnection,
|
Qt::QueuedConnection,
|
||||||
Q_ARG(const QString&, deviceName));
|
Q_ARG(const QString&, deviceName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioDeviceScriptingInterface::setOutputDeviceAsync(const QString& deviceName) {
|
void AudioDeviceScriptingInterface::setOutputDeviceAsync(const QString& deviceName) {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName;
|
||||||
|
|
||||||
|
if (deviceName.isEmpty()) {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "attempt to set empty deviceName:" << deviceName << "... ignoring!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchOutputToAudioDevice",
|
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchOutputToAudioDevice",
|
||||||
Qt::QueuedConnection,
|
Qt::QueuedConnection,
|
||||||
Q_ARG(const QString&, deviceName));
|
Q_ARG(const QString&, deviceName));
|
||||||
|
@ -241,8 +268,11 @@ void AudioDeviceScriptingInterface::onCurrentInputDeviceChanged(const QString& n
|
||||||
void AudioDeviceScriptingInterface::onCurrentOutputDeviceChanged(const QString& name)
|
void AudioDeviceScriptingInterface::onCurrentOutputDeviceChanged(const QString& name)
|
||||||
{
|
{
|
||||||
currentDeviceUpdate(name, QAudio::AudioOutput);
|
currentDeviceUpdate(name, QAudio::AudioOutput);
|
||||||
|
|
||||||
|
// FIXME - this is kinda janky to set the setting on the result of a signal
|
||||||
//we got a signal that device changed. Save it now
|
//we got a signal that device changed. Save it now
|
||||||
SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance();
|
SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance();
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "about to call settings->setValue('audio_output_device', name); name:" << name;
|
||||||
settings->setValue("audio_output_device", name);
|
settings->setValue("audio_output_device", name);
|
||||||
emit currentOutputDeviceChanged(name);
|
emit currentOutputDeviceChanged(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,10 @@ AudioClient::AudioClient() :
|
||||||
|
|
||||||
connect(&_receivedAudioStream, &MixedProcessedAudioStream::processSamples,
|
connect(&_receivedAudioStream, &MixedProcessedAudioStream::processSamples,
|
||||||
this, &AudioClient::processReceivedSamples, Qt::DirectConnection);
|
this, &AudioClient::processReceivedSamples, Qt::DirectConnection);
|
||||||
connect(this, &AudioClient::changeDevice, this, [=](const QAudioDeviceInfo& outputDeviceInfo) { switchOutputToAudioDevice(outputDeviceInfo); });
|
connect(this, &AudioClient::changeDevice, this, [=](const QAudioDeviceInfo& outputDeviceInfo) {
|
||||||
|
qCDebug(audioclient) << "got AudioClient::changeDevice signal, about to call switchOutputToAudioDevice() outputDeviceInfo: [" << outputDeviceInfo.deviceName() << "]";
|
||||||
|
switchOutputToAudioDevice(outputDeviceInfo);
|
||||||
|
});
|
||||||
|
|
||||||
connect(&_receivedAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioClient::handleMismatchAudioFormat);
|
connect(&_receivedAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioClient::handleMismatchAudioFormat);
|
||||||
|
|
||||||
|
@ -438,7 +441,8 @@ QAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode) {
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(audioclient) << "[" << deviceName << "] [" << getNamedAudioDeviceForMode(mode, deviceName).deviceName() << "]";
|
qCDebug(audioclient) << "defaultAudioDeviceForMode mode: " << (mode == QAudio::AudioOutput ? "Output" : "Input")
|
||||||
|
<< " [" << deviceName << "] [" << getNamedAudioDeviceForMode(mode, deviceName).deviceName() << "]";
|
||||||
|
|
||||||
return getNamedAudioDeviceForMode(mode, deviceName);
|
return getNamedAudioDeviceForMode(mode, deviceName);
|
||||||
#endif
|
#endif
|
||||||
|
@ -614,8 +618,12 @@ void AudioClient::start() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioClient::stop() {
|
void AudioClient::stop() {
|
||||||
|
|
||||||
// "switch" to invalid devices in order to shut down the state
|
// "switch" to invalid devices in order to shut down the state
|
||||||
|
qCDebug(audioclient) << "AudioClient::stop(), about to call switchInputToAudioDevice(null)";
|
||||||
switchInputToAudioDevice(QAudioDeviceInfo());
|
switchInputToAudioDevice(QAudioDeviceInfo());
|
||||||
|
|
||||||
|
qCDebug(audioclient) << "AudioClient::stop(), about to call switchOutputToAudioDevice(null)";
|
||||||
switchOutputToAudioDevice(QAudioDeviceInfo());
|
switchOutputToAudioDevice(QAudioDeviceInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,12 +815,12 @@ QVector<QString> AudioClient::getDeviceNames(QAudio::Mode mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioClient::switchInputToAudioDevice(const QString& inputDeviceName) {
|
bool AudioClient::switchInputToAudioDevice(const QString& inputDeviceName) {
|
||||||
qCDebug(audioclient) << "[" << inputDeviceName << "] [" << getNamedAudioDeviceForMode(QAudio::AudioInput, inputDeviceName).deviceName() << "]";
|
qCDebug(audioclient) << "switchInputToAudioDevice [" << inputDeviceName << "] [" << getNamedAudioDeviceForMode(QAudio::AudioInput, inputDeviceName).deviceName() << "]";
|
||||||
return switchInputToAudioDevice(getNamedAudioDeviceForMode(QAudio::AudioInput, inputDeviceName));
|
return switchInputToAudioDevice(getNamedAudioDeviceForMode(QAudio::AudioInput, inputDeviceName));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioClient::switchOutputToAudioDevice(const QString& outputDeviceName) {
|
bool AudioClient::switchOutputToAudioDevice(const QString& outputDeviceName) {
|
||||||
qCDebug(audioclient) << "[" << outputDeviceName << "] [" << getNamedAudioDeviceForMode(QAudio::AudioOutput, outputDeviceName).deviceName() << "]";
|
qCDebug(audioclient) << "switchOutputToAudioDevice [" << outputDeviceName << "] [" << getNamedAudioDeviceForMode(QAudio::AudioOutput, outputDeviceName).deviceName() << "]";
|
||||||
return switchOutputToAudioDevice(getNamedAudioDeviceForMode(QAudio::AudioOutput, outputDeviceName));
|
return switchOutputToAudioDevice(getNamedAudioDeviceForMode(QAudio::AudioOutput, outputDeviceName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1357,6 +1365,7 @@ void AudioClient::setIsStereoInput(bool isStereoInput) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// change in channel count for desired input format, restart the input device
|
// change in channel count for desired input format, restart the input device
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "about to call switchInputToAudioDevice:" << _inputAudioDeviceName;
|
||||||
switchInputToAudioDevice(_inputAudioDeviceName);
|
switchInputToAudioDevice(_inputAudioDeviceName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1395,6 +1404,7 @@ void AudioClient::outputFormatChanged() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioClient::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceInfo) {
|
bool AudioClient::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceInfo) {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "inputDeviceInfo: [" << inputDeviceInfo.deviceName() << "]";
|
||||||
bool supportedFormat = false;
|
bool supportedFormat = false;
|
||||||
|
|
||||||
// cleanup any previously initialized device
|
// cleanup any previously initialized device
|
||||||
|
@ -1509,6 +1519,8 @@ void AudioClient::outputNotify() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioClient::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDeviceInfo) {
|
bool AudioClient::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDeviceInfo) {
|
||||||
|
qCDebug(audioclient) << "AudioClient::switchOutputToAudioDevice() outputDeviceInfo: [" << outputDeviceInfo.deviceName() << "]";
|
||||||
|
|
||||||
bool supportedFormat = false;
|
bool supportedFormat = false;
|
||||||
|
|
||||||
Lock localAudioLock(_localAudioMutex);
|
Lock localAudioLock(_localAudioMutex);
|
||||||
|
@ -1643,7 +1655,11 @@ bool AudioClient::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDevice
|
||||||
}
|
}
|
||||||
|
|
||||||
int AudioClient::setOutputBufferSize(int numFrames, bool persist) {
|
int AudioClient::setOutputBufferSize(int numFrames, bool persist) {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "numFrames:" << numFrames << "persist:" << persist;
|
||||||
|
|
||||||
numFrames = std::min(std::max(numFrames, MIN_BUFFER_FRAMES), MAX_BUFFER_FRAMES);
|
numFrames = std::min(std::max(numFrames, MIN_BUFFER_FRAMES), MAX_BUFFER_FRAMES);
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "clamped numFrames:" << numFrames << "_sessionOutputBufferSizeFrames:" << _sessionOutputBufferSizeFrames;
|
||||||
|
|
||||||
if (numFrames != _sessionOutputBufferSizeFrames) {
|
if (numFrames != _sessionOutputBufferSizeFrames) {
|
||||||
qCInfo(audioclient, "Audio output buffer set to %d frames", numFrames);
|
qCInfo(audioclient, "Audio output buffer set to %d frames", numFrames);
|
||||||
_sessionOutputBufferSizeFrames = numFrames;
|
_sessionOutputBufferSizeFrames = numFrames;
|
||||||
|
@ -1655,6 +1671,7 @@ int AudioClient::setOutputBufferSize(int numFrames, bool persist) {
|
||||||
// The buffer size can't be adjusted after QAudioOutput::start() has been called, so
|
// The buffer size can't be adjusted after QAudioOutput::start() has been called, so
|
||||||
// recreate the device by switching to the default.
|
// recreate the device by switching to the default.
|
||||||
QAudioDeviceInfo outputDeviceInfo = defaultAudioDeviceForMode(QAudio::AudioOutput);
|
QAudioDeviceInfo outputDeviceInfo = defaultAudioDeviceForMode(QAudio::AudioOutput);
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "about to send changeDevice signal outputDeviceInfo: [" << outputDeviceInfo.deviceName() << "]";
|
||||||
emit changeDevice(outputDeviceInfo); // On correct thread, please, as setOutputBufferSize can be called from main thread.
|
emit changeDevice(outputDeviceInfo); // On correct thread, please, as setOutputBufferSize can be called from main thread.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue