/*! \brief SpeechCreate() Dialplan Application */ static int speech_create(struct ast_channel *chan, const char *data) { struct ast_speech *speech = NULL; struct ast_datastore *datastore = NULL; /* Request a speech object */ speech = ast_speech_new(data, ast_channel_nativeformats(chan)); if (speech == NULL) { /* Not available */ pbx_builtin_setvar_helper(chan, "ERROR", "1"); return 0; } datastore = ast_datastore_alloc(&speech_datastore, NULL); if (datastore == NULL) { ast_speech_destroy(speech); pbx_builtin_setvar_helper(chan, "ERROR", "1"); return 0; } pbx_builtin_setvar_helper(chan, "ERROR", NULL); datastore->data = speech; ast_channel_lock(chan); ast_channel_datastore_add(chan, datastore); ast_channel_unlock(chan); return 0; }
/*! \brief SpeechCreate() Dialplan Application */ static int speech_create(struct ast_channel *chan, void *data) { struct ast_module_user *u = NULL; struct ast_speech *speech = NULL; struct ast_datastore *datastore = NULL; u = ast_module_user_add(chan); /* Request a speech object */ speech = ast_speech_new(data, AST_FORMAT_SLINEAR); if (speech == NULL) { /* Not available */ pbx_builtin_setvar_helper(chan, "ERROR", "1"); ast_module_user_remove(u); return 0; } datastore = ast_channel_datastore_alloc(&speech_datastore, NULL); if (datastore == NULL) { ast_speech_destroy(speech); pbx_builtin_setvar_helper(chan, "ERROR", "1"); ast_module_user_remove(u); return 0; } datastore->data = speech; ast_channel_datastore_add(chan, datastore); pbx_builtin_setvar_helper(chan, "ERROR", NULL); ast_module_user_remove(u); return 0; }