Merged revisions 89536 via svnmerge from
[asterisk/asterisk.git] / res / res_speech.c
index cf83034..902955d 100644 (file)
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
 #include "asterisk/channel.h"
 #include "asterisk/module.h"
 #include "asterisk/lock.h"
 #include "asterisk/linkedlists.h"
 #include "asterisk/cli.h"
 #include "asterisk/term.h"
-#include "asterisk/options.h"
 #include "asterisk/speech.h"
 
 
@@ -128,6 +122,7 @@ void ast_speech_start(struct ast_speech *speech)
        /* Clear any flags that may affect things */
        ast_clear_flag(speech, AST_SPEECH_SPOKE);
        ast_clear_flag(speech, AST_SPEECH_QUIET);
+       ast_clear_flag(speech, AST_SPEECH_HAVE_RESULTS);
 
        /* If results are on the structure, free them since we are starting again */
        if (speech->results) {
@@ -152,6 +147,21 @@ int ast_speech_write(struct ast_speech *speech, void *data, int len)
        return speech->engine->write(speech, data, len);
 }
 
+/*! \brief Signal to the engine that DTMF was received */
+int ast_speech_dtmf(struct ast_speech *speech, const char *dtmf)
+{
+       int res = 0;
+
+       if (speech->state != AST_SPEECH_STATE_READY)
+               return -1;
+
+       if (speech->engine->dtmf != NULL) {
+               res = speech->engine->dtmf(speech, dtmf);
+       }
+
+       return res;
+}
+
 /*! \brief Change an engine specific attribute */
 int ast_speech_change(struct ast_speech *speech, char *name, const char *value)
 {
@@ -301,7 +311,7 @@ int ast_speech_unregister(char *engine_name)
        AST_RWLIST_TRAVERSE_SAFE_BEGIN(&engines, engine, list) {
                if (!strcasecmp(engine->name, engine_name)) {
                        /* We have our engine... removed it */
-                       AST_RWLIST_REMOVE_CURRENT(&engines, list);
+                       AST_RWLIST_REMOVE_CURRENT(list);
                        /* If this was the default engine, we need to pick a new one */
                        if (!default_engine)
                                default_engine = AST_RWLIST_FIRST(&engines);
@@ -311,7 +321,7 @@ int ast_speech_unregister(char *engine_name)
                        break;
                }
        }
-       AST_RWLIST_TRAVERSE_SAFE_END
+       AST_RWLIST_TRAVERSE_SAFE_END;
        AST_RWLIST_UNLOCK(&engines);
 
        return res;
@@ -325,7 +335,7 @@ static int unload_module(void)
 
 static int load_module(void)
 {
-       return 0;
+       return AST_MODULE_LOAD_SUCCESS;
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Generic Speech Recognition API",