mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Merge pull request #10705 from ZappoMan/moreAudioFixes
fix no audio device from previously removed audio device
This commit is contained in:
commit
0597c3105f
3 changed files with 27 additions and 4 deletions
|
@ -48,15 +48,31 @@ AudioDeviceScriptingInterface::AudioDeviceScriptingInterface(): QAbstractListMod
|
||||||
SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance();
|
SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance();
|
||||||
const QString inDevice = settings->getValue("audio_input_device", _currentInputDevice).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;
|
// before using the old setting, check to make sure the device still exists....
|
||||||
setInputDeviceAsync(inDevice);
|
bool inDeviceExists = DependencyManager::get<AudioClient>()->getNamedAudioDeviceForModeExists(QAudio::AudioInput, inDevice);
|
||||||
|
|
||||||
|
if (inDeviceExists) {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "about to call setInputDeviceAsync() device: [" << inDevice << "] _currentInputDevice:" << _currentInputDevice;
|
||||||
|
setInputDeviceAsync(inDevice);
|
||||||
|
} else {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "previously selected device no longer exists inDevice: [" << inDevice << "] keeping device _currentInputDevice:" << _currentInputDevice;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the audio_output_device setting is not available, use the _currentOutputDevice
|
// If the audio_output_device setting is not available, use the _currentOutputDevice
|
||||||
auto outDevice = settings->getValue("audio_output_device", _currentOutputDevice).toString();
|
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;
|
// before using the old setting, check to make sure the device still exists....
|
||||||
setOutputDeviceAsync(outDevice);
|
bool outDeviceExists = DependencyManager::get<AudioClient>()->getNamedAudioDeviceForModeExists(QAudio::AudioOutput, outDevice);
|
||||||
|
|
||||||
|
if (outDeviceExists) {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "about to call setOutputDeviceAsync() outDevice: [" << outDevice << "] _currentOutputDevice:" << _currentOutputDevice;
|
||||||
|
setOutputDeviceAsync(outDevice);
|
||||||
|
} else {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "previously selected device no longer exists outDevice: [" << outDevice << "] keeping device _currentOutputDevice:" << _currentOutputDevice;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -395,6 +395,11 @@ QAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode) {
|
||||||
return (mode == QAudio::AudioInput) ? QAudioDeviceInfo::defaultInputDevice() : QAudioDeviceInfo::defaultOutputDevice();
|
return (mode == QAudio::AudioInput) ? QAudioDeviceInfo::defaultInputDevice() : QAudioDeviceInfo::defaultOutputDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AudioClient::getNamedAudioDeviceForModeExists(QAudio::Mode mode, const QString& deviceName) {
|
||||||
|
return (getNamedAudioDeviceForMode(mode, deviceName).deviceName() == deviceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// attempt to use the native sample rate and channel count
|
// attempt to use the native sample rate and channel count
|
||||||
bool nativeFormatForAudioDevice(const QAudioDeviceInfo& audioDevice,
|
bool nativeFormatForAudioDevice(const QAudioDeviceInfo& audioDevice,
|
||||||
QAudioFormat& audioFormat) {
|
QAudioFormat& audioFormat) {
|
||||||
|
|
|
@ -149,6 +149,8 @@ public:
|
||||||
|
|
||||||
static const float CALLBACK_ACCELERATOR_RATIO;
|
static const float CALLBACK_ACCELERATOR_RATIO;
|
||||||
|
|
||||||
|
bool getNamedAudioDeviceForModeExists(QAudio::Mode mode, const QString& deviceName);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
static QString friendlyNameForAudioDevice(wchar_t* guid);
|
static QString friendlyNameForAudioDevice(wchar_t* guid);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue