aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_talkdetect.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-07-15 23:00:47 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-07-15 23:00:47 +0000
commitff15e0fa53156b9994da3f726bfe91232de6195a (patch)
tree896015cada90b49858e1bf6503d9583704a56179 /apps/app_talkdetect.c
parentc05cf07847cb384ba66aa29d5eda580eda413ffb (diff)
add a library of timeval manipulation functions, and change a large number of usses to use the new functions (bug #4504)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6146 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_talkdetect.c')
-rwxr-xr-xapps/app_talkdetect.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/apps/app_talkdetect.c b/apps/app_talkdetect.c
index 117b835bd..e60f3a8e9 100755
--- a/apps/app_talkdetect.c
+++ b/apps/app_talkdetect.c
@@ -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;
}