mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 18:55:19 +00:00 
			
		
		
		
	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: https://origsvn.digium.com/svn/asterisk/trunk@115076 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		| @@ -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(¤t); | ||||
| 			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 */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user