[Asterisk-bsd] MeetMe drift

David G Lawrence dg228 at dglawrence.com
Sun Jul 29 19:28:46 CDT 2007


> David,
> 
> >    1.4 has converted to using LIST macros to do list traversals and
> > manipulations. I'll have to rewrite the patch for that. No promises on
> > when I'll be able to get to that.
> >
> 
> I've attached my first attempt at this. It seems to be dropping a few
> initial frames during a call (announcements begin mid-word) and has
> segfaulted Asterisk a few times. My 1.4.x programming skills are
> nothing to write home about but perhaps someone can take a look both
> of our patches and see where I've gone wrong.

   Nice try, but you translated the patch a bit too literally. :-) It
needed to be re-implemented for use with the queue macros.
   Try the attached. Note that this is *completely* untested - I don't even
know for sure if it will compile - I don't run 1.4.x on any machines yet
...but nonetheless I think it will work perfectly. :-)
   Please let me know if/how it works for you.

-DG

David G. Lawrence
President
Download Technologies, Inc. - http://www.downloadtech.com - (866) 399 8500
The FreeBSD Project - http://www.freebsd.org
Pave the road of life with opportunities.
-------------- next part --------------
*** channel.c.orig	Fri Jul 20 11:22:24 2007
--- channel.c	Sun Jul 29 17:27:04 2007
***************
*** 898,903 ****
--- 898,904 ----
  	struct ast_frame *cur;
  	int blah = 1;
  	int qlen = 0;
+ 	int vqlen = 0;
  
  	/* Build us a copy and free the original one */
  	if (!(f = ast_frdup(fin))) {
***************
*** 905,910 ****
--- 906,941 ----
  		return -1;
  	}
  	ast_channel_lock(chan);
+ 	
+ 	/*
+ 	 * Drop any previous voice frames beyond the limit.
+ 	 */
+ 
+ 	/*
+ 	 * First count up how many voice frames that we have.
+ 	 */
+ 	AST_LIST_TRAVERSE(&chan->readq, cur, frame_list) {
+ 		if (cur->frametype == AST_FRAME_VOICE) {
+ 			vqlen++;
+ 		}
+ 	}
+ 
+ 	/*
+ 	 * Now drop voice frames past the limit, currently 2 voice frames.
+ 	 */
+ 
+ 	if (vqlen > 2) {
+ 		AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->readq, cur, frame_list) {
+ 			if (cur->frametype == AST_FRAME_VOICE) {
+ 				AST_LIST_REMOVE_CURRENT(&chan->readq, frame_list);
+ 				ast_frfree(cur);
+ 				vqlen--;
+ 				if (vqlen <= 2)
+ 					break;
+ 			}
+ 		}
+ 		AST_LIST_TRAVERSE_SAFE_END;
+ 	}
  
  	/* See if the last frame on the queue is a hangup, if so don't queue anything */
  	if ((cur = AST_LIST_LAST(&chan->readq)) && (cur->frametype == AST_FRAME_CONTROL) && (cur->subclass == AST_CONTROL_HANGUP)) {


More information about the Asterisk-BSD mailing list