alexa-voiceagent-service: Add patch to update audio device configuration
[AGL/meta-agl-devel.git] / meta-speech-framework / meta-aac / recipes-apis / alexa-voiceagent-service / alexa-voiceagent-service / 0003-update-audio-device-configuration.patch
1 Update audio device configuration
2
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
7 properties.
8
9 Upstream-Status: Pending
10
11 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
12
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
18  
19      // Output devices
20      if(!m_ttsOutputDevice.empty())
21 -      audioConfig.ttsOutputDevice = m_audio->openAHLChannel(m_ttsOutputDevice);
22 +      audioConfig.ttsOutputDevice = m_audio->openChannel(m_ttsOutputDevice);
23  
24      if(!m_musicOutputDevice.empty())
25 -      audioConfig.musicOutputDevice = m_audio->openAHLChannel(m_musicOutputDevice);
26 +      audioConfig.musicOutputDevice = m_audio->openChannel(m_musicOutputDevice);
27  
28      if(!m_notificationOutputDevice.empty())
29 -      audioConfig.notificationOutputDevice = m_audio->openAHLChannel(m_notificationOutputDevice);
30 +      audioConfig.notificationOutputDevice = m_audio->openChannel(m_notificationOutputDevice);
31  
32      if(!m_alarmOutputDevice.empty())
33 -      audioConfig.alarmOutputDevice = m_audio->openAHLChannel(m_alarmOutputDevice);
34 +      audioConfig.alarmOutputDevice = m_audio->openChannel(m_alarmOutputDevice);
35  
36      if(!m_earconOutputDevice.empty())
37 -      audioConfig.earconOutputDevice = m_audio->openAHLChannel(m_earconOutputDevice);
38 +      audioConfig.earconOutputDevice = m_audio->openChannel(m_earconOutputDevice);
39  
40      if(!m_communicationOutputDevice.empty())
41 -      audioConfig.communicationOutputDevice = m_audio->openAHLChannel(m_communicationOutputDevice);
42 +      audioConfig.communicationOutputDevice = m_audio->openChannel(m_communicationOutputDevice);
43  
44      if(!m_ringtoneOutputDevice.empty())
45 -      audioConfig.ringtoneOutputDevice = m_audio->openAHLChannel(m_ringtoneOutputDevice);
46 +      audioConfig.ringtoneOutputDevice = m_audio->openChannel(m_ringtoneOutputDevice);
47  
48      return audioConfig;
49  }
50 @@ -585,4 +585,4 @@ void AASBConfigProviderImpl::logCurrentConfiguration() {
51  }
52  
53  }  // namespace alexa
54 -}  // namespace agl
55 \ No newline at end of file
56 +}  // namespace agl
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
61 @@ -13,8 +13,6 @@
62   * permissions and limitations under the License.
63   */
64  
65 -#include <json.h>
66 -
67  #include <AACE/Engine/Core/EngineMacros.h>
68  
69  #include "Audio.h"
70 @@ -22,7 +20,7 @@
71  namespace agl {
72  namespace audio {
73  
74 -/// Shortcut to reach logging level.
75 +// Shortcut to reach logging level.
76  using Level = agl::common::interfaces::ILogger::Level;
77  
78  using namespace agl::common::interfaces;
79 @@ -31,68 +29,30 @@ static std::string TAG = "agl::audio::Audio";
80  
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)
85 +{
86      return std::shared_ptr<Audio>(new Audio(logger, api));
87  }
88  
89  Audio::Audio(std::shared_ptr<ILogger> logger,
90      std::shared_ptr<IAFBApi> api) :
91          m_logger(logger),
92 -        m_api(api) {
93 -
94 -}
95 -
96 -std::string Audio::openAHLChannel(const std::string &role)
97 +        m_api(api)
98  {
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));
108 -                       result = device;
109 -               }
110 -               json_object_put(response);
111 -               return result;
112 -       }
113 -       return "";
114  }
115  
116 -bool Audio::setAHLChannelVolume(const std::string &role, int volume)
117 +std::string Audio::openChannel(const std::string &role)
118  {
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.
126 +       return role;
127  }
128  
129 -bool Audio::callAHL(const std::string &role, json_object *request, json_object **response)
130 +bool Audio::setChannelVolume(const std::string &role, int volume)
131  {
132 -       json_object *object = NULL;
133 -    std::string error, info;
134 -       bool result = false;
135 -
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);
138 -               goto exit;
139 -       }
140 -
141 -    m_logger->log(Level::DEBUG, TAG, "callAHL, response=" + std::string(json_object_get_string(object)));
142 -       result = true;
143 -       if (response) {
144 -               *response = object;
145 -       }
146 -
147 -exit:
148 -       if (!result && object) {
149 -               json_object_put(object);
150 -       }
151 -
152 -       return result;
153 +       return true;
154  }
155  
156 -}
157 -}
158 \ No newline at end of file
159 +} // namespace audio
160 +} // namespace agl
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);
168  
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);
173  
174  private:
175         Audio(std::shared_ptr<agl::common::interfaces::ILogger> logger,
176                   shared_ptr<agl::common::interfaces::IAFBApi> api);
177  
178 -       bool callAHL(const std::string &role, json_object *request, json_object **response);
179 -
180 -    // Logger.
181 -    std::shared_ptr<agl::common::interfaces::ILogger> m_logger;
182 +       // Logger.
183 +       std::shared_ptr<agl::common::interfaces::ILogger> m_logger;
184  
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;
188  };
189  
190 -}
191 -}
192 +} // namespace audio
193 +} // namespace agl
194  
195 -#endif // AGL_AUDIO_AUDIO_H_
196 \ No newline at end of file
197 +#endif // AGL_AUDIO_AUDIO_H_