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