1 Update audio device configuration
3 Rework the audio output device configuration to match the expectations
4 of the PipeWire output sink configuration in the gstreamer output code.
5 Currently, this means that the role is being stored as the device name
6 so the gstreamer code can use it when setting up the output sink
9 Upstream-Status: Pending
11 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
13 diff --git a/platforms/agl/alexa-voiceagent-service/src/plugins/aasb-client/config/AASBConfigProviderImpl.cpp b/platforms/agl/alexa-voiceagent-service/src/plugins/aasb-client/config/AASBConfigProviderImpl.cpp
14 index 83d0341..b51185c 100644
15 --- a/src/plugins/aasb-client/config/AASBConfigProviderImpl.cpp
16 +++ b/src/plugins/aasb-client/config/AASBConfigProviderImpl.cpp
17 @@ -97,25 +97,25 @@ AASBConfigProviderImpl::AudioIOConfiguration AASBConfigProviderImpl::getAudioIOC
20 if(!m_ttsOutputDevice.empty())
21 - audioConfig.ttsOutputDevice = m_audio->openAHLChannel(m_ttsOutputDevice);
22 + audioConfig.ttsOutputDevice = m_audio->openChannel(m_ttsOutputDevice);
24 if(!m_musicOutputDevice.empty())
25 - audioConfig.musicOutputDevice = m_audio->openAHLChannel(m_musicOutputDevice);
26 + audioConfig.musicOutputDevice = m_audio->openChannel(m_musicOutputDevice);
28 if(!m_notificationOutputDevice.empty())
29 - audioConfig.notificationOutputDevice = m_audio->openAHLChannel(m_notificationOutputDevice);
30 + audioConfig.notificationOutputDevice = m_audio->openChannel(m_notificationOutputDevice);
32 if(!m_alarmOutputDevice.empty())
33 - audioConfig.alarmOutputDevice = m_audio->openAHLChannel(m_alarmOutputDevice);
34 + audioConfig.alarmOutputDevice = m_audio->openChannel(m_alarmOutputDevice);
36 if(!m_earconOutputDevice.empty())
37 - audioConfig.earconOutputDevice = m_audio->openAHLChannel(m_earconOutputDevice);
38 + audioConfig.earconOutputDevice = m_audio->openChannel(m_earconOutputDevice);
40 if(!m_communicationOutputDevice.empty())
41 - audioConfig.communicationOutputDevice = m_audio->openAHLChannel(m_communicationOutputDevice);
42 + audioConfig.communicationOutputDevice = m_audio->openChannel(m_communicationOutputDevice);
44 if(!m_ringtoneOutputDevice.empty())
45 - audioConfig.ringtoneOutputDevice = m_audio->openAHLChannel(m_ringtoneOutputDevice);
46 + audioConfig.ringtoneOutputDevice = m_audio->openChannel(m_ringtoneOutputDevice);
50 @@ -585,4 +585,4 @@ void AASBConfigProviderImpl::logCurrentConfiguration() {
55 \ No newline at end of file
57 diff --git a/src/plugins/audio/Audio.cpp b/src/plugins/audio/Audio.cpp
58 index d662a06..1b2fa9d 100644
59 --- a/src/plugins/audio/Audio.cpp
60 +++ b/src/plugins/audio/Audio.cpp
62 * permissions and limitations under the License.
67 #include <AACE/Engine/Core/EngineMacros.h>
74 -/// Shortcut to reach logging level.
75 +// Shortcut to reach logging level.
76 using Level = agl::common::interfaces::ILogger::Level;
78 using namespace agl::common::interfaces;
79 @@ -31,68 +29,30 @@ static std::string TAG = "agl::audio::Audio";
81 std::shared_ptr<Audio> Audio::create(
82 std::shared_ptr<agl::common::interfaces::ILogger> logger,
83 - shared_ptr<agl::common::interfaces::IAFBApi> api) {
84 + shared_ptr<agl::common::interfaces::IAFBApi> api)
86 return std::shared_ptr<Audio>(new Audio(logger, api));
89 Audio::Audio(std::shared_ptr<ILogger> logger,
90 std::shared_ptr<IAFBApi> api) :
96 -std::string Audio::openAHLChannel(const std::string &role)
99 - json_object *request = json_object_new_object();
100 - json_object *response = NULL;
101 - json_object_object_add(request, "action", json_object_new_string("open"));
102 - if (callAHL(role, request, &response)) {
103 - json_object *val = NULL;
104 - std::string result;
105 - if (json_object_object_get_ex(response, "device_uri", &val)) {
106 - const char* device = json_object_get_string(val);
107 - m_logger->log(Level::DEBUG, TAG, "openAHLChannel: device=" + std::string(device));
110 - json_object_put(response);
116 -bool Audio::setAHLChannelVolume(const std::string &role, int volume)
117 +std::string Audio::openChannel(const std::string &role)
119 - json_object *request = json_object_new_object();
120 - json_object_object_add(request, "action", json_object_new_string("volume"));
121 - json_object_object_add(request, "value", json_object_new_int(volume));
122 - return callAHL(role, request, NULL);
123 + // For now, return the given role as the device string, to match
124 + // the expectation of the PipeWire sink configuration in the
125 + // gstreamer output code.
129 -bool Audio::callAHL(const std::string &role, json_object *request, json_object **response)
130 +bool Audio::setChannelVolume(const std::string &role, int volume)
132 - json_object *object = NULL;
133 - std::string error, info;
134 - bool result = false;
136 - if (m_api->callSync("ahl-4a", role, request, &object, error, info) < 0) {
137 - m_logger->log(Level::ERROR, TAG, "VA service call=" + role + " failed, error=" + error + ", info=" + info);
141 - m_logger->log(Level::DEBUG, TAG, "callAHL, response=" + std::string(json_object_get_string(object)));
144 - *response = object;
148 - if (!result && object) {
149 - json_object_put(object);
158 \ No newline at end of file
159 +} // namespace audio
161 diff --git a/src/plugins/audio/Audio.h b/src/plugins/audio/Audio.h
162 index 14bef4d..8998242 100644
163 --- a/src/plugins/audio/Audio.h
164 +++ b/src/plugins/audio/Audio.h
165 @@ -35,23 +35,21 @@ public:
166 std::shared_ptr<agl::common::interfaces::ILogger> logger,
167 shared_ptr<agl::common::interfaces::IAFBApi> api);
169 - std::string openAHLChannel(const std::string &role);
170 - bool setAHLChannelVolume(const std::string &role, int volume);
171 + std::string openChannel(const std::string &role);
172 + bool setChannelVolume(const std::string &role, int volume);
175 Audio(std::shared_ptr<agl::common::interfaces::ILogger> logger,
176 shared_ptr<agl::common::interfaces::IAFBApi> api);
178 - bool callAHL(const std::string &role, json_object *request, json_object **response);
181 - std::shared_ptr<agl::common::interfaces::ILogger> m_logger;
183 + std::shared_ptr<agl::common::interfaces::ILogger> m_logger;
185 // AFB API object for events pub/sub, and for calling other AGL services.
186 - std::shared_ptr<agl::common::interfaces::IAFBApi> m_api;
187 + std::shared_ptr<agl::common::interfaces::IAFBApi> m_api;
192 +} // namespace audio
195 -#endif // AGL_AUDIO_AUDIO_H_
196 \ No newline at end of file
197 +#endif // AGL_AUDIO_AUDIO_H_