aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_speech.c
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-11 16:19:00 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-11 16:19:00 +0000
commit13e34e0fa90fbcf6fa455a70dae7f7ea5fa0778a (patch)
tree032315fb180c3cd05bc7d3413049896897d2b403 /res/res_speech.c
parent1694b8d95fb30d493878868d07323b89f6dc9a93 (diff)
Allow the native formats of a channel to influence the audio that is going to the engine. The best format will try to be chosen with an ultimate fallback to signed linear if possible.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@74570 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_speech.c')
-rw-r--r--res/res_speech.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/res/res_speech.c b/res/res_speech.c
index b902f40d7..e848b06ca 100644
--- a/res/res_speech.c
+++ b/res/res_speech.c
@@ -159,17 +159,22 @@ int ast_speech_change(struct ast_speech *speech, char *name, const char *value)
}
/*! \brief Create a new speech structure using the engine specified */
-struct ast_speech *ast_speech_new(char *engine_name, int format)
+struct ast_speech *ast_speech_new(char *engine_name, int formats)
{
struct ast_speech_engine *engine = NULL;
struct ast_speech *new_speech = NULL;
+ int format = AST_FORMAT_SLINEAR;
/* Try to find the speech recognition engine that was requested */
if (!(engine = find_engine(engine_name)))
return NULL;
- /* Make sure the requested format fits */
- if (!(engine->formats & format))
+ /* Before even allocating the memory below do some codec negotiation, we choose the best codec possible and fall back to signed linear if possible */
+ if ((format = (engine->formats & formats)))
+ format = ast_best_codec(format);
+ else if ((engine->formats & AST_FORMAT_SLINEAR))
+ format = AST_FORMAT_SLINEAR;
+ else
return NULL;
/* Allocate our own speech structure, and try to allocate a structure from the engine too */