Showing the changes to interface/src/scripting/AudioDeviceScriptingInterface.cpp (1 of 3 files). Show all
Unified · Split
| @@ -9,7 +9,9 @@ · 8 unmodified lines | ||
| 9 | 9 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 10 | 10 | // |
| 11 | 11 | |
| 12 | −#include "AudioClient.h" | |
| 12 | +#include <AudioClient.h> | |
| 13 | +#include <AudioClientLogging.h> | |
| 14 | + | |
| 13 | 15 | #include "AudioDeviceScriptingInterface.h" |
| 14 | 16 | #include "SettingsScriptingInterface.h" |
| 15 | 17 | |
| @@ -44,17 +46,23 @@ AudioDeviceScriptingInterface::AudioDeviceScriptingInterface(): QAbstractListMod · 28 unmodified lines | ||
| 44 | 46 | onDeviceChanged(); |
| 45 | 47 | //set up previously saved device |
| 46 | 48 | SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance(); |
| 47 | − const QString inDevice = settings->getValue("audio_input_device").toString(); | |
| 49 | + const QString inDevice = settings->getValue("audio_input_device", _currentInputDevice).toString(); | |
| 48 | 50 | if (inDevice != _currentInputDevice) { |
| 51 | + qCDebug(audioclient) << __FUNCTION__ << "about to call setInputDeviceAsync() device: [" << inDevice << "] _currentInputDevice:" << _currentInputDevice; | |
| 49 | 52 | setInputDeviceAsync(inDevice); |
| 50 | 53 | } |
| 51 | − const QString outDevice = settings->getValue("audio_output_device").toString(); | |
| 54 | + | |
| 55 | + // If the audio_output_device setting is not available, use the _currentOutputDevice | |
| 56 | + auto outDevice = settings->getValue("audio_output_device", _currentOutputDevice).toString(); | |
| 52 | 57 | if (outDevice != _currentOutputDevice) { |
| 58 | + qCDebug(audioclient) << __FUNCTION__ << "about to call setOutputDeviceAsync() outDevice: [" << outDevice << "] _currentOutputDevice:" << _currentOutputDevice; | |
| 53 | 59 | setOutputDeviceAsync(outDevice); |
| 54 | 60 | } |
| 55 | 61 | } |
| 56 | 62 | |
| 57 | 63 | bool AudioDeviceScriptingInterface::setInputDevice(const QString& deviceName) { |
| 64 | + qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName; | |
| 65 | + | |
| 58 | 66 | bool result; |
| 59 | 67 | QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchInputToAudioDevice", |
| 60 | 68 | Qt::BlockingQueuedConnection, |
| @@ -64,6 +72,9 @@ bool AudioDeviceScriptingInterface::setInputDevice(const QString& deviceName) { · 3 unmodified lines | ||
| 64 | 72 | } |
| 65 | 73 | |
| 66 | 74 | bool AudioDeviceScriptingInterface::setOutputDevice(const QString& deviceName) { |
| 75 | + | |
| 76 | + qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName; | |
| 77 | + | |
| 67 | 78 | bool result; |
| 68 | 79 | QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchOutputToAudioDevice", |
| 69 | 80 | Qt::BlockingQueuedConnection, |
| @@ -86,8 +97,10 @@ bool AudioDeviceScriptingInterface::setDeviceFromMenu(const QString& deviceMenuN · 16 unmodified lines | ||
| 86 | 97 | for (ScriptingAudioDeviceInfo di: _devices) { |
| 87 | 98 | if (mode == di.mode && deviceMenuName.contains(di.name)) { |
| 88 | 99 | if (mode == QAudio::AudioOutput) { |
| 100 | + qCDebug(audioclient) << __FUNCTION__ << "about to call setOutputDeviceAsync() device: [" << di.name << "]"; | |
| 89 | 101 | setOutputDeviceAsync(di.name); |
| 90 | 102 | } else { |
| 103 | + qCDebug(audioclient) << __FUNCTION__ << "about to call setInputDeviceAsync() device: [" << di.name << "]"; | |
| 91 | 104 | setInputDeviceAsync(di.name); |
| 92 | 105 | } |
| 93 | 106 | return true; |
| @@ -98,12 +111,26 @@ bool AudioDeviceScriptingInterface::setDeviceFromMenu(const QString& deviceMenuN · 4 unmodified lines | ||
| 98 | 111 | } |
| 99 | 112 | |
| 100 | 113 | void AudioDeviceScriptingInterface::setInputDeviceAsync(const QString& deviceName) { |
| 114 | + qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName; | |
| 115 | + | |
| 116 | + if (deviceName.isEmpty()) { | |
| 117 | + qCDebug(audioclient) << __FUNCTION__ << "attempt to set empty deviceName:" << deviceName << "... ignoring!"; | |
| 118 | + return; | |
| 119 | + } | |
| 120 | + | |
| 101 | 121 | QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchInputToAudioDevice", |
| 102 | 122 | Qt::QueuedConnection, |
| 103 | 123 | Q_ARG(const QString&, deviceName)); |
| 104 | 124 | } |
| 105 | 125 | |
| 106 | 126 | void AudioDeviceScriptingInterface::setOutputDeviceAsync(const QString& deviceName) { |
| 127 | + qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName; | |
| 128 | + | |
| 129 | + if (deviceName.isEmpty()) { | |
| 130 | + qCDebug(audioclient) << __FUNCTION__ << "attempt to set empty deviceName:" << deviceName << "... ignoring!"; | |
| 131 | + return; | |
| 132 | + } | |
| 133 | + | |
| 107 | 134 | QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchOutputToAudioDevice", |
| 108 | 135 | Qt::QueuedConnection, |
| 109 | 136 | Q_ARG(const QString&, deviceName)); |
| @@ -241,8 +268,11 @@ void AudioDeviceScriptingInterface::onCurrentInputDeviceChanged(const QString& n · 131 unmodified lines | ||
| 241 | 268 | void AudioDeviceScriptingInterface::onCurrentOutputDeviceChanged(const QString& name) |
| 242 | 269 | { |
| 243 | 270 | currentDeviceUpdate(name, QAudio::AudioOutput); |
| 271 | + | |
| 272 | + // FIXME - this is kinda janky to set the setting on the result of a signal | |
| 244 | 273 | //we got a signal that device changed. Save it now |
| 245 | 274 | SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance(); |
| 275 | + qCDebug(audioclient) << __FUNCTION__ << "about to call settings->setValue('audio_output_device', name); name:" << name; | |
| 246 | 276 | settings->setValue("audio_output_device", name); |
| 247 | 277 | emit currentOutputDeviceChanged(name); |
| 248 | 278 | } |