diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-08-27 03:28:32 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-08-27 03:28:32 +0000 |
commit | 21b0db7e2b78e4716a9aa4995c40db38ac295525 (patch) | |
tree | f581a7297ba6a1529c1760036929e66a3d8e36dc | |
parent | 671a8fee863d01c0588b889e0b0aff309c300615 (diff) |
Run generators from zap timers when available so as to interop with VAD
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3663 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-x | asterisk.c | 4 | ||||
-rwxr-xr-x | channel.c | 30 |
2 files changed, 28 insertions, 6 deletions
diff --git a/asterisk.c b/asterisk.c index 691a3e414..50dbedeae 100755 --- a/asterisk.c +++ b/asterisk.c @@ -3,9 +3,9 @@ * * Top level source file for asterisk * - * Copyright (C) 1999, Mark Spencer + * Copyright (C) 1999-2004, Digium, Inc. * - * Mark Spencer <markster@linux-support.net> + * Mark Spencer <markster@digium.com> * * This program is free software, distributed under the terms of * the GNU General Public License @@ -3,9 +3,9 @@ * * Channel Management * - * Copyright (C) 1999, Mark Spencer + * Copyright (C) 1999-2004, Digium, Inc. * - * Mark Spencer <markster@linux-support.net> + * Mark Spencer <markster@digium.com> * * This program is free software, distributed under the terms of * the GNU General Public License @@ -816,10 +816,30 @@ void ast_deactivate_generator(struct ast_channel *chan) chan->generatordata = NULL; chan->generator = NULL; chan->writeinterrupt = 0; + ast_settimeout(chan, 0, NULL, NULL); } ast_mutex_unlock(&chan->lock); } +static int generator_force(void *data) +{ + /* Called if generator doesn't have data */ + void *tmp; + int res; + int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples); + struct ast_channel *chan = data; + tmp = chan->generatordata; + chan->generatordata = NULL; + generate = chan->generator->generate; + res = generate(chan, tmp, 0, 160); + chan->generatordata = tmp; + if (res) { + ast_log(LOG_DEBUG, "Auto-deactivating generator\n"); + ast_deactivate_generator(chan); + } + return 0; +} + int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params) { int res = 0; @@ -831,6 +851,7 @@ int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, } ast_prod(chan); if ((chan->generatordata = gen->alloc(chan, params))) { + ast_settimeout(chan, 160, generator_force, chan); chan->generator = gen; } else { res = -1; @@ -1338,8 +1359,9 @@ struct ast_frame *ast_read(struct ast_channel *chan) } /* Run any generator sitting on the line */ - if (f && (f->frametype == AST_FRAME_VOICE) && chan->generatordata) { - /* Mask generator data temporarily */ + if (f && (f->frametype == AST_FRAME_VOICE) && chan->generatordata && !chan->timingfunc) { + /* Mask generator data temporarily and apply. If there is a timing function, it + will be calling the generator instead */ void *tmp; int res; int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples); |