res_speech_aeap: add aeap error handling

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
This commit is contained in:
Mike Bradeen 2023-09-21 12:54:45 -06:00 committed by George Joseph
parent 15ef050d0a
commit 1885d0677c
1 changed files with 18 additions and 0 deletions

View 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,
};
/*!