History

add better debugging for audio problems use OS default device if settings have no values

ZappoMan committed 9 years ago

Commit 6fe20f91 parent dd3a7f73 files · +67 −9Browse files

Showing the changes to interface/src/scripting/AudioDeviceScriptingInterface.cpp (1 of 3 files). Show all

Unified · Split

interface/src/scripting/AudioDeviceScriptingInterface.cpp+33−3
@@ -9,7 +9,9 @@ · 8 unmodified lines
99 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
1010 //
1111
12−#include "AudioClient.h"
12+#include <AudioClient.h>
13+#include <AudioClientLogging.h>
14+
1315 #include "AudioDeviceScriptingInterface.h"
1416 #include "SettingsScriptingInterface.h"
1517
@@ -44,17 +46,23 @@ AudioDeviceScriptingInterface::AudioDeviceScriptingInterface(): QAbstractListMod · 28 unmodified lines
4446 onDeviceChanged();
4547 //set up previously saved device
4648 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();
4850 if (inDevice != _currentInputDevice) {
51+ qCDebug(audioclient) << __FUNCTION__ << "about to call setInputDeviceAsync() device: [" << inDevice << "] _currentInputDevice:" << _currentInputDevice;
4952 setInputDeviceAsync(inDevice);
5053 }
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();
5257 if (outDevice != _currentOutputDevice) {
58+ qCDebug(audioclient) << __FUNCTION__ << "about to call setOutputDeviceAsync() outDevice: [" << outDevice << "] _currentOutputDevice:" << _currentOutputDevice;
5359 setOutputDeviceAsync(outDevice);
5460 }
5561 }
5662
5763 bool AudioDeviceScriptingInterface::setInputDevice(const QString& deviceName) {
64+ qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName;
65+
5866 bool result;
5967 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchInputToAudioDevice",
6068 Qt::BlockingQueuedConnection,
@@ -64,6 +72,9 @@ bool AudioDeviceScriptingInterface::setInputDevice(const QString& deviceName) { · 3 unmodified lines
6472 }
6573
6674 bool AudioDeviceScriptingInterface::setOutputDevice(const QString& deviceName) {
75+
76+ qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName;
77+
6778 bool result;
6879 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchOutputToAudioDevice",
6980 Qt::BlockingQueuedConnection,
@@ -86,8 +97,10 @@ bool AudioDeviceScriptingInterface::setDeviceFromMenu(const QString& deviceMenuN · 16 unmodified lines
8697 for (ScriptingAudioDeviceInfo di: _devices) {
8798 if (mode == di.mode && deviceMenuName.contains(di.name)) {
8899 if (mode == QAudio::AudioOutput) {
100+ qCDebug(audioclient) << __FUNCTION__ << "about to call setOutputDeviceAsync() device: [" << di.name << "]";
89101 setOutputDeviceAsync(di.name);
90102 } else {
103+ qCDebug(audioclient) << __FUNCTION__ << "about to call setInputDeviceAsync() device: [" << di.name << "]";
91104 setInputDeviceAsync(di.name);
92105 }
93106 return true;
@@ -98,12 +111,26 @@ bool AudioDeviceScriptingInterface::setDeviceFromMenu(const QString& deviceMenuN · 4 unmodified lines
98111 }
99112
100113 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+
101121 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchInputToAudioDevice",
102122 Qt::QueuedConnection,
103123 Q_ARG(const QString&, deviceName));
104124 }
105125
106126 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+
107134 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchOutputToAudioDevice",
108135 Qt::QueuedConnection,
109136 Q_ARG(const QString&, deviceName));
@@ -241,8 +268,11 @@ void AudioDeviceScriptingInterface::onCurrentInputDeviceChanged(const QString& n · 131 unmodified lines
241268 void AudioDeviceScriptingInterface::onCurrentOutputDeviceChanged(const QString& name)
242269 {
243270 currentDeviceUpdate(name, QAudio::AudioOutput);
271+
272+ // FIXME - this is kinda janky to set the setting on the result of a signal
244273 //we got a signal that device changed. Save it now
245274 SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance();
275+ qCDebug(audioclient) << __FUNCTION__ << "about to call settings->setValue('audio_output_device', name); name:" << name;
246276 settings->setValue("audio_output_device", name);
247277 emit currentOutputDeviceChanged(name);
248278 }