[asterisk-dev] ast_read and frames of type AST_FRAME_NULL?

Bryan Field-Elliot bryan+asterisk-dev at nextalarm.com
Thu Jun 24 10:15:00 CDT 2010


OK here's a follow-on question:

I've altered my code, such that if ast_waitfor returns 0, it loops around and basically issues another ast_waitfor.

My ms waitfor time is now 200. Simplified code below:

int empty_counter = 0;
for (;;) {
	r = ast_waitfor(chan, 200);
	if (r == 0) {
		empty_counter++;
		continue;
	}
	frame = ast_read(chan);
	// ... do some work
	// how long did we wait?
	ast_verb(4, "waitfor returned empty %d times\n", empty_counter);
}

I'm finding that the empty_counter is climbing into the tens and sometimes hundreds of thousands. This shouldn't be possible if it's waiting 200ms each time. So my follow-on question is -- is there some state that channels might get in, such that ast_waitfor will return immediately rathe than waiting the number of milliseconds specified in its second parameter?





On Jun 22, 2010, at 11:17 PM, Russell Bryant wrote:


----- Original Message -----
> I think Russell means you're only supposed to call ast_read() if r >
> 0, not if r == 0. Other places in the code (like app_waitforring.c and
> app_meetme.c) seem to follow this convention.

Correct.

--
Russell Bryant
Digium, Inc.  |  Engineering Manager, Open Source Software
445 Jan Davis Drive NW   -    Huntsville, AL 35806  -  USA
jabber: rbryant at digium.com    -=-    skype: russell-bryant
www.digium.com -=- www.asterisk.org -=- blogs.asterisk.org

-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-dev




More information about the asterisk-dev mailing list