[Asterisk-cvs] asterisk/channels chan_iax2.c,1.109,1.110

markster at lists.digium.com markster at lists.digium.com
Sat Mar 20 00:24:17 CST 2004


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv9248/channels

Modified Files:
	chan_iax2.c 
Log Message:
Round offset timestamps to nearest 20ms to clean up numbers.


Index: chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -d -r1.109 -r1.110
--- chan_iax2.c	19 Mar 2004 08:16:19 -0000	1.109
+++ chan_iax2.c	20 Mar 2004 05:19:45 -0000	1.110
@@ -2562,6 +2562,8 @@
 	if (!iaxs[callno]->rxcore.tv_sec && !iaxs[callno]->rxcore.tv_usec) {
 		/* Initialize rxcore time if appropriate */
 		gettimeofday(&iaxs[callno]->rxcore, NULL);
+		/* Round to nearest 20ms */
+		iaxs[callno]->rxcore.tv_usec -= iaxs[callno]->rxcore.tv_usec % 20000;
 	}
 	/* Calculate difference between trunk and channel */
 	ms = (peer->rxtrunktime.tv_sec - iaxs[callno]->rxcore.tv_sec) * 1000 + 
@@ -2574,8 +2576,11 @@
 {
 	struct timeval tv;
 	unsigned int ms;
-	if (!p->offset.tv_sec && !p->offset.tv_usec)
+	if (!p->offset.tv_sec && !p->offset.tv_usec) {
 		gettimeofday(&p->offset, NULL);
+		/* Round to nearest 20ms */
+		p->offset.tv_usec -= p->offset.tv_usec % 20000;
+	}
 	/* If the timestamp is specified, just send it as is */
 	if (ts)
 		return ts;
@@ -2586,8 +2591,9 @@
 		ms = (tv.tv_sec - p->offset.tv_sec) * 1000 + (tv.tv_usec - p->offset.tv_usec) / 1000;
 	}
 	/* We never send the same timestamp twice, so fudge a little if we must */
-	if (ms <= p->lastsent)
+	if (ms <= p->lastsent) {
 		ms = p->lastsent + 1;
+	}
 	p->lastsent = ms;
 	return ms;
 }




More information about the svn-commits mailing list