]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_speech_aeap: add aeap error handling
authorMike Bradeen <mbradeen@sangoma.com>
Thu, 21 Sep 2023 18:54:45 +0000 (12:54 -0600)
committerAsterisk Development Team <asteriskteam@digium.com>
Fri, 12 Jan 2024 18:32:12 +0000 (18:32 +0000)
res_speech_aeap previously did not register an error handler
with aeap, so it was not notified of a disconnect. This resulted
in SpeechBackground never exiting upon a websocket disconnect.

Resolves: #303
(cherry picked from commit e921f5e010accdb1065c4eb6139fd099b8dba93e)

res/res_speech_aeap.c

index 9da68bce39af657bb2f576a96acc6e4f348849b2..e90a4511ff863b4a2a8d4e81c5aada55fd253d7d 100644 (file)
@@ -350,11 +350,29 @@ static const struct ast_aeap_message_handler request_handlers[] = {
        { "set", handle_request_set },
 };
 
+/*!
+ * \internal
+ * \brief Handle an error from an external application by setting state to done
+ *
+ * \param aeap Pointer to an Asterisk external application object
+ */
+static void ast_aeap_speech_on_error(struct ast_aeap *aeap)
+{
+       struct ast_speech *speech = ast_aeap_user_data_object_by_id(aeap, "speech");
+       if (!speech) {
+               ast_log(LOG_ERROR, "aeap generated error with no associated speech object");
+               return;
+       }
+
+       ast_speech_change_state(speech, AST_SPEECH_STATE_DONE);
+}
+
 static struct ast_aeap_params speech_aeap_params = {
        .response_handlers = response_handlers,
        .response_handlers_size = ARRAY_LEN(response_handlers),
        .request_handlers = request_handlers,
        .request_handlers_size = ARRAY_LEN(request_handlers),
+       .on_error = ast_aeap_speech_on_error,
 };
 
 /*!