aboutsummaryrefslogtreecommitdiffstats
path: root/channel.c
diff options
context:
space:
mode:
authoroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-30 06:07:04 +0000
committeroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-30 06:07:04 +0000
commit60636c259914d27a04b43c8bc26dece1871d876a (patch)
tree57c1cb7f263e43e28f5b083076ff222662216773 /channel.c
parenta9a990c34439999f57a0993ddf1b81c8501bae91 (diff)
Issue #5374 - Enable internal timing of generators (cmantunes)
Thanks everyone involved for hard work, testing and testing! git-svn-id: http://svn.digium.com/svn/asterisk/trunk@16473 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channel.c')
-rw-r--r--channel.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/channel.c b/channel.c
index fdf2c97c1..717a92de0 100644
--- a/channel.c
+++ b/channel.c
@@ -1976,30 +1976,34 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
f = &ast_null_frame;
}
- /* Run any generator sitting on the channel */
- if (chan->generatordata) {
- /* Mask generator data temporarily and apply. If there is a timing function, it
- will be calling the generator instead */
+ /* Run generator sitting on the line if timing device not available
+ * and synchronous generation of outgoing frames is necessary */
+ if (chan->generatordata && !ast_internal_timing_enabled(chan)) {
void *tmp;
int res;
int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples);
-
+
if (chan->timingfunc) {
- ast_log(LOG_DEBUG, "Generator got voice, switching to phase locked mode\n");
+ if (option_debug > 1)
+ ast_log(LOG_DEBUG, "Generator got voice, switching to phase locked mode\n");
ast_settimeout(chan, 0, NULL, NULL);
}
+
tmp = chan->generatordata;
chan->generatordata = NULL;
generate = chan->generator->generate;
res = generate(chan, tmp, f->datalen, f->samples);
chan->generatordata = tmp;
if (res) {
- ast_log(LOG_DEBUG, "Auto-deactivating generator\n");
+ if (option_debug > 1)
+ ast_log(LOG_DEBUG, "Auto-deactivating generator\n");
ast_deactivate_generator(chan);
}
+
} else if (f->frametype == AST_FRAME_CNG) {
if (chan->generator && !chan->timingfunc && (chan->timingfd > -1)) {
- ast_log(LOG_DEBUG, "Generator got CNG, switching to timed mode\n");
+ if (option_debug > 1)
+ ast_log(LOG_DEBUG, "Generator got CNG, switching to timed mode\n");
ast_settimeout(chan, 160, generator_force, chan);
}
}
@@ -2027,6 +2031,14 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
return f;
}
+int ast_internal_timing_enabled(struct ast_channel *chan)
+{
+ int ret = option_internal_timing && chan->timingfd > -1;
+ if (option_verbose > 2)
+ ast_verbose(VERBOSE_PREFIX_3 "Internal timing is %s (option_internal_timing=%d chan->timingfd=%d)\n", ret? "enabled": "disabled", option_internal_timing, chan->timingfd);
+ return ret;
+}
+
struct ast_frame *ast_read(struct ast_channel *chan)
{
return __ast_read(chan, 0);