aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_speech_utils.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-01 23:06:23 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-01 23:06:23 +0000
commitd1cc29c9c1c324a7421f220482d8cc4f321540ba (patch)
tree3df7d1e791a878179b45272be0b3f3cccf8eeee0 /apps/app_speech_utils.c
parent995531248a14d3ac9e88ffc12836176688bb137e (diff)
Modify TIMEOUT() to be accurate down to the millisecond.
(closes issue #10540) Reported by: spendergrass Patches: 20080417__bug10540.diff.txt uploaded by Corydon76 (license 14) Tested by: blitzrage git-svn-id: http://svn.digium.com/svn/asterisk/trunk@115076 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_speech_utils.c')
-rw-r--r--apps/app_speech_utils.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/apps/app_speech_utils.c b/apps/app_speech_utils.c
index 4677c33b6..5082478af 100644
--- a/apps/app_speech_utils.c
+++ b/apps/app_speech_utils.c
@@ -513,7 +513,7 @@ static int speech_background(struct ast_channel *chan, void *data)
struct ast_frame *f = NULL;
int oldreadformat = AST_FORMAT_SLINEAR;
char dtmf[AST_MAX_EXTENSION] = "";
- time_t start, current;
+ struct timeval start = { 0, 0 }, current;
struct ast_datastore *datastore = NULL;
char *parse, *filename_tmp = NULL, *filename = NULL, tmp[2] = "", dtmf_terminator = '#';
const char *tmp2 = NULL;
@@ -552,7 +552,7 @@ static int speech_background(struct ast_channel *chan, void *data)
/* Yay sound file */
filename_tmp = ast_strdupa(args.soundfile);
if (!ast_strlen_zero(args.timeout)) {
- if ((timeout = atoi(args.timeout)) == 0)
+ if ((timeout = atof(args.timeout) * 1000.0) == 0)
timeout = -1;
} else
timeout = 0;
@@ -612,8 +612,8 @@ static int speech_background(struct ast_channel *chan, void *data)
/* Do timeout check (shared between audio/dtmf) */
if ((!quieted || strlen(dtmf)) && started == 1) {
- time(&current);
- if ((current-start) >= timeout) {
+ current = ast_tvnow();
+ if ((ast_tvdiff_ms(start, current)) >= timeout) {
done = 1;
if (f)
ast_frfree(f);
@@ -642,7 +642,7 @@ static int speech_background(struct ast_channel *chan, void *data)
ast_frfree(f);
break;
}
- time(&start);
+ start = ast_tvnow();
started = 1;
}
/* Write audio frame out to speech engine if no DTMF has been received */
@@ -701,10 +701,10 @@ static int speech_background(struct ast_channel *chan, void *data)
}
if (!started) {
/* Change timeout to be 5 seconds for DTMF input */
- timeout = (chan->pbx && chan->pbx->dtimeout) ? chan->pbx->dtimeout : 5;
+ timeout = (chan->pbx && chan->pbx->dtimeoutms) ? chan->pbx->dtimeoutms : 5000;
started = 1;
}
- time(&start);
+ start = ast_tvnow();
snprintf(tmp, sizeof(tmp), "%c", f->subclass);
strncat(dtmf, tmp, sizeof(dtmf) - strlen(dtmf) - 1);
/* If the maximum length of the DTMF has been reached, stop now */