mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
add a library of timeval manipulation functions, and change a large number of usses to use the new functions (bug #4504)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6146 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -59,7 +59,7 @@ static int background_detect_exec(struct ast_channel *chan, void *data)
|
||||
char *stringp;
|
||||
struct ast_frame *fr;
|
||||
int notsilent=0;
|
||||
struct timeval start = { 0, 0}, end = {0, 0};
|
||||
struct timeval start = { 0, 0};
|
||||
int sil = 1000;
|
||||
int min = 100;
|
||||
int max = -1;
|
||||
@@ -143,9 +143,7 @@ static int background_detect_exec(struct ast_channel *chan, void *data)
|
||||
/* We've been quiet a little while */
|
||||
if (notsilent) {
|
||||
/* We had heard some talking */
|
||||
gettimeofday(&end, NULL);
|
||||
ms = (end.tv_sec - start.tv_sec) * 1000;
|
||||
ms += (end.tv_usec - start.tv_usec) / 1000;
|
||||
ms = ast_tvdiff_ms(ast_tvnow(), start);
|
||||
ms -= sil;
|
||||
if (ms < 0)
|
||||
ms = 0;
|
||||
@@ -171,7 +169,7 @@ static int background_detect_exec(struct ast_channel *chan, void *data)
|
||||
} else {
|
||||
if (!notsilent) {
|
||||
/* Heard some audio, mark the begining of the token */
|
||||
gettimeofday(&start, NULL);
|
||||
start = ast_tvnow();
|
||||
ast_log(LOG_DEBUG, "Start of voice token!\n");
|
||||
notsilent = 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user