Thanks, now what I see makes sense.<div><br></div><div>Paulo<br><br><div class="gmail_quote">On Wed, Feb 17, 2010 at 9:20 AM, Russell Bryant <span dir="ltr"><<a href="mailto:russell@digium.com">russell@digium.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On 02/16/2010 01:07 PM, Paulo Garcia wrote:<br>
</div><div><div></div><div class="h5">> Hi,<br>
><br>
> I'm analyzing the way the Monitor application works in Asterisk 1.4. At<br>
> first it seems very simple, however the code in channel.c (__ast_read<br>
> function around line 2390):<br>
><br>
> int jump = chan->outsmpl - chan->insmpl - 4 * f->samples;<br>
> if (jump>= 0) {<br>
> jump = chan->outsmpl - chan->insmpl;<br>
> if (ast_seekstream(chan->monitor->read_stream, jump, SEEK_FORCECUR) == -1)<br>
> ast_log(LOG_WARNING, "Failed to perform seek in monitoring read stream,<br>
> synchronization between the files may be broken\n");<br>
> chan->insmpl += jump + f->samples;<br>
> } else<br>
> chan->insmpl+= f->samples;<br>
><br>
> seems confusing to me. What is being done here?<br>
><br>
> Is it a way to keep the in and out files synchronized? If yes, how does it<br>
> work? Is it possible that one file can present chunks of silence (80ms long<br>
> for example) if this way of the call doesn't receive samples in the same<br>
> rate of the other?<br>
<br>
</div></div>You are correct. This code is intended to keep the input and output<br>
files in sync. It does the following:<br>
<br>
Is the number of output samples minus the number of input samples<br>
greater than 4 times the current frame size? (Note that frames are<br>
usually 20ms, so an 80ms difference is where the sync would occur.) If<br>
so, seek the input file forward by the amount of difference (as I said<br>
before, most likely at least 80ms).<br>
<div><div></div><div class="h5"><br>
<br>
--<br>
Russell Bryant<br>
Digium, Inc. | Engineering Manager, Open Source Software<br>
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA<br>
<a href="http://www.digium.com" target="_blank">www.digium.com</a> -=- <a href="http://www.asterisk.org" target="_blank">www.asterisk.org</a> -=- <a href="http://blogs.asterisk.org" target="_blank">blogs.asterisk.org</a><br>
<br>
--<br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br>
<br>
asterisk-dev mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
<a href="http://lists.digium.com/mailman/listinfo/asterisk-dev" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>--------------<br>Paulo Garcia<br>Pika Technologies Inc<br>
</div>