[Asterisk-Dev] generate inside ast_read?

Carlos Antunes cmantunes at gmail.com
Mon Oct 3 14:20:40 MST 2005


Hello!

After sifting through the code (CVS HEAD) for a couple of days, it is more
or less clear to me now that the reason RTP generally requires incoming
frames to generate outgoing ones. Outgoing frames are generally generated
inside ast_read (channel.c). However, with ZAPTEL_OPTIMIZATION on, it is
also possible to generate packets asynchronously. This already happens when
a CNG frame is received, for example. My question is whether we can simply
forget about the synchronous generation of frames inside ast_read and always
use asynchronous generation. Can we? Well, I decide to give it a try by
simply commenting out a portion of the code inside ast_read:


channel.c line 1687:
 if (f && (f->frametype == AST_FRAME_VOICE) && chan->generatordata) {
 /* 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);

 /* NO SYNCHRONOUS GENERATION, THANK YOU! channel.c line 1694

 if (chan->timingfunc) {
 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");
 ast_deactivate_generator(chan);
 } END OF NO SYNCHRONOUS GENERATION, THANK YOU! */
} else ...

I ran asterisk without synchronous generation for a couple of hours feeding
to clients music on hold and Allison samples and apparently, nothing bad
happened. So, why not eliminate the synchronous thing altogether when a
timing source is available (which should be all the time!)?

Thanks!

Carlos

--
"We hold [...] that all men are created equal; that they are
endowed [...] with certain inalienable rights; that among
these are life, liberty, and the pursuit of happiness"
-- Thomas Jefferson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20051003/ef9e6b0a/attachment.htm


More information about the asterisk-dev mailing list