diff options
author | Egor Nemtsev <enemtsev@luxoft.com> | 2019-08-14 12:50:26 +0300 |
---|---|---|
committer | Egor Nemtsev <enemtsev@luxoft.com> | 2019-08-14 10:02:10 +0000 |
commit | 63b4c4754945ffbdc1ec9daca740304f23c80b53 (patch) | |
tree | b5fa6120072ad66215a64be3f5482ad7dfd27d92 /plugins/alexainterface/AlexaInterface.cpp | |
parent | 209dbf8c0f60c23ae3c3438c49508e233950e4a9 (diff) |
Add QSettings property for changing capture device
- It might be needed to change default capture (microphone) device.
For this case app reads QSettings with "Luxoft Sweden AB"/"AlexaApp"
and from "capture/device_name" section reads device name.
App prints avail devices in "--verbose" mode to console upon startup.
Change-Id: I948435ecd29e7b31ed70ec0f25c2c60d155de037
Reviewed-by: Bramastyo Harimukti Santoso <bramastyo.harimukti.santoso@pelagicore.com>
Diffstat (limited to 'plugins/alexainterface/AlexaInterface.cpp')
-rw-r--r-- | plugins/alexainterface/AlexaInterface.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/plugins/alexainterface/AlexaInterface.cpp b/plugins/alexainterface/AlexaInterface.cpp index 7f37995..6577177 100644 --- a/plugins/alexainterface/AlexaInterface.cpp +++ b/plugins/alexainterface/AlexaInterface.cpp @@ -33,6 +33,7 @@ #include <ACL/Transport/HTTP2TransportFactory.h> #include <ACL/Transport/PostConnectSynchronizer.h> #include <AVSCommon/Utils/LibcurlUtils/LibcurlHTTP2ConnectionFactory.h> +#include <QSettings> #include "KeywordObserver.h" #include "AlexaInterface.h" @@ -309,7 +310,7 @@ void AlexaInterface::initAlexaQMLClient() // If avs-device-sdk is built without keyword support, kwdModelPath remains empty QString kwdModelPath; -#if KWD +#ifdef KWD if (!qEnvironmentVariableIsSet("ALEXA_KWD_MODEL_PATH")) { qCritical() << "ALEXA_KWD_MODEL_PATH not defined"; return; @@ -329,7 +330,7 @@ void AlexaInterface::initAlexaQMLClient() kwdModelPath.toStdString(), m_logLevelString.toStdString())) { qCritical() << "Failed to initialize AlexaInterface."; -#if KWD +#ifdef KWD qDebug() << "ALEXA_KWD_MODEL_PATH: " << qEnvironmentVariable("ALEXA_KWD_MODEL_PATH"); #endif qDebug() << "ALEXA_SDK_CONFIG_FILE: " << qEnvironmentVariable("ALEXA_SDK_CONFIG_FILE"); @@ -903,9 +904,15 @@ bool AlexaInterface::initialize( holdCanOverride, holdCanBeOverridden); - - std::shared_ptr<QtMicrophoneWrapper> micWrapper = QtMicrophoneWrapper::create(sharedDataStream); - if (!micWrapper) { + /* + * Read device name to change system default microphone input + */ + QSettings settings(QStringLiteral("Luxoft Sweden AB"), QStringLiteral("AlexaApp")); + QString captureDeviceName = settings.value(QStringLiteral("capture/device_name"), + QStringLiteral("default")).toString(); + std::shared_ptr<QtMicrophoneWrapper> m_micWrapper = QtMicrophoneWrapper::create(sharedDataStream, + captureDeviceName); + if (!m_micWrapper) { ACSDK_CRITICAL(LX("Failed to create QtMicrophoneWrapper!")); return false; } @@ -954,7 +961,7 @@ bool AlexaInterface::initialize( m_interactionManager = std::make_shared<InteractionManager>( this, client, - micWrapper, + m_micWrapper, m_userInterfaceManager, holdToTalkAudioProvider, tapToTalkAudioProvider, @@ -966,7 +973,7 @@ bool AlexaInterface::initialize( #else // If wake word is not enabled, then creating the interaction manager without a wake word audio provider. m_interactionManager = std::make_shared<InteractionManager>( - this, client, micWrapper, m_userInterfaceManager, holdToTalkAudioProvider, tapToTalkAudioProvider, m_guiRenderer); + this, client, m_micWrapper, m_userInterfaceManager, holdToTalkAudioProvider, tapToTalkAudioProvider, m_guiRenderer); #endif client->addAlexaDialogStateObserver(m_interactionManager); |