Issue #5374 - Enable internal timing of generators (cmantunes)

Thanks everyone involved for hard work, testing and testing!


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@16473 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Olle Johansson
2006-03-30 06:07:04 +00:00
parent 2c4ebe356e
commit 50f0b12880
11 changed files with 96 additions and 35 deletions

View File

@@ -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);