[asterisk-dev] res_monitor information
Russell Bryant
russell at digium.com
Wed Feb 17 08:20:01 CST 2010
On 02/16/2010 01:07 PM, Paulo Garcia wrote:
> Hi,
>
> I'm analyzing the way the Monitor application works in Asterisk 1.4. At
> first it seems very simple, however the code in channel.c (__ast_read
> function around line 2390):
>
> int jump = chan->outsmpl - chan->insmpl - 4 * f->samples;
> if (jump>= 0) {
> jump = chan->outsmpl - chan->insmpl;
> if (ast_seekstream(chan->monitor->read_stream, jump, SEEK_FORCECUR) == -1)
> ast_log(LOG_WARNING, "Failed to perform seek in monitoring read stream,
> synchronization between the files may be broken\n");
> chan->insmpl += jump + f->samples;
> } else
> chan->insmpl+= f->samples;
>
> seems confusing to me. What is being done here?
>
> Is it a way to keep the in and out files synchronized? If yes, how does it
> work? Is it possible that one file can present chunks of silence (80ms long
> for example) if this way of the call doesn't receive samples in the same
> rate of the other?
You are correct. This code is intended to keep the input and output
files in sync. It does the following:
Is the number of output samples minus the number of input samples
greater than 4 times the current frame size? (Note that frames are
usually 20ms, so an 80ms difference is where the sync would occur.) If
so, seek the input file forward by the amount of difference (as I said
before, most likely at least 80ms).
--
Russell Bryant
Digium, Inc. | Engineering Manager, Open Source Software
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
www.digium.com -=- www.asterisk.org -=- blogs.asterisk.org
More information about the asterisk-dev
mailing list