diff options
author | oej <oej@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-03-30 06:07:04 +0000 |
---|---|---|
committer | oej <oej@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-03-30 06:07:04 +0000 |
commit | 60636c259914d27a04b43c8bc26dece1871d876a (patch) | |
tree | 57c1cb7f263e43e28f5b083076ff222662216773 /channel.c | |
parent | a9a990c34439999f57a0993ddf1b81c8501bae91 (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.c | 28 |
1 files changed, 20 insertions, 8 deletions
@@ -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); |