[Asterisk-cvs] asterisk translate.c,1.20,1.21

markster at lists.digium.com markster at lists.digium.com
Mon Apr 5 16:47:36 CDT 2004


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

Modified Files:
	translate.c 
Log Message:
Don't translate time for packets with no delivery


Index: translate.c
===================================================================
RCS file: /usr/cvsroot/asterisk/translate.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- translate.c	5 Apr 2004 19:45:53 -0000	1.20
+++ translate.c	5 Apr 2004 20:47:44 -0000	1.21
@@ -140,42 +140,44 @@
 	p = path;
 	/* Feed the first frame into the first translator */
 	p->step->framein(p->state, f);
-	if (path->nextin.tv_sec || path->nextin.tv_usec) {
-		/* Make sure this is in line with what we were expecting */
-		if ((path->nextin.tv_sec != f->delivery.tv_sec) ||
-		    (path->nextin.tv_usec != f->delivery.tv_usec)) {
-			/* The time has changed between what we expected and this
-			   most recent time on the new packet.  Adjust our output
-			   time appropriately */
-			long sdiff;
-			long udiff;
-			sdiff = f->delivery.tv_sec - path->nextin.tv_sec;
-			udiff = f->delivery.tv_usec - path->nextin.tv_usec;
+	if (f->delivery.tv_sec || f->delivery.tv_usec) {
+		if (path->nextin.tv_sec || path->nextin.tv_usec) {
+			/* Make sure this is in line with what we were expecting */
+			if ((path->nextin.tv_sec != f->delivery.tv_sec) ||
+			    (path->nextin.tv_usec != f->delivery.tv_usec)) {
+				/* The time has changed between what we expected and this
+				   most recent time on the new packet.  Adjust our output
+				   time appropriately */
+				long sdiff;
+				long udiff;
+				sdiff = f->delivery.tv_sec - path->nextin.tv_sec;
+				udiff = f->delivery.tv_usec - path->nextin.tv_usec;
+				path->nextin.tv_sec = f->delivery.tv_sec;
+				path->nextin.tv_usec = f->delivery.tv_usec;
+				path->nextout.tv_sec += sdiff;
+				path->nextout.tv_usec += udiff;
+				if (path->nextout.tv_usec < 0) {
+					path->nextout.tv_usec += 1000000;
+					path->nextout.tv_sec--;
+				} else if (path->nextout.tv_usec >= 1000000) {
+					path->nextout.tv_usec -= 1000000;
+					path->nextout.tv_sec++;
+				}
+			}
+		} else {
+			/* This is our first pass.  Make sure the timing looks good */
 			path->nextin.tv_sec = f->delivery.tv_sec;
 			path->nextin.tv_usec = f->delivery.tv_usec;
-			path->nextout.tv_sec += sdiff;
-			path->nextout.tv_usec += udiff;
-			if (path->nextout.tv_usec < 0) {
-				path->nextout.tv_usec += 1000000;
-				path->nextout.tv_sec--;
-			} else if (path->nextout.tv_usec >= 1000000) {
-				path->nextout.tv_usec -= 1000000;
-				path->nextout.tv_sec++;
-			}
+			path->nextout.tv_sec = f->delivery.tv_sec;
+			path->nextout.tv_usec = f->delivery.tv_usec;
+		}
+		/* Predict next incoming sample */
+		path->nextin.tv_sec += (f->samples / 8000);
+		path->nextin.tv_usec += ((f->samples % 8000) * 125);
+		if (path->nextin.tv_usec >= 1000000) {
+			path->nextin.tv_usec -= 1000000;
+			path->nextin.tv_sec++;
 		}
-	} else {
-		/* This is our first pass.  Make sure the timing looks good */
-		path->nextin.tv_sec = f->delivery.tv_sec;
-		path->nextin.tv_usec = f->delivery.tv_usec;
-		path->nextout.tv_sec = f->delivery.tv_sec;
-		path->nextout.tv_usec = f->delivery.tv_usec;
-	}
-	/* Predict next incoming sample */
-	path->nextin.tv_sec += (f->samples / 8000);
-	path->nextin.tv_usec += ((f->samples % 8000) * 125);
-	if (path->nextin.tv_usec >= 1000000) {
-		path->nextin.tv_usec -= 1000000;
-		path->nextin.tv_sec++;
 	}
 	if (consume)
 		ast_frfree(f);
@@ -189,17 +191,22 @@
 		if (p->next) 
 			p->next->step->framein(p->next->state, out);
 		else {
-			/* Use next predicted outgoing timestamp */
-			out->delivery.tv_sec = path->nextout.tv_sec;
-			out->delivery.tv_usec = path->nextout.tv_usec;
-			
-			/* Predict next outgoing timestamp from samples in this
-			   frame. */
-			path->nextout.tv_sec += (out->samples / 8000);
-			path->nextout.tv_usec += ((out->samples % 8000) * 125);
-			if (path->nextout.tv_usec >= 1000000) {
-				path->nextout.tv_sec++;
-				path->nextout.tv_usec -= 1000000;
+			if (f->delivery.tv_sec || f->delivery.tv_usec) {
+				/* Use next predicted outgoing timestamp */
+				out->delivery.tv_sec = path->nextout.tv_sec;
+				out->delivery.tv_usec = path->nextout.tv_usec;
+				
+				/* Predict next outgoing timestamp from samples in this
+				   frame. */
+				path->nextout.tv_sec += (out->samples / 8000);
+				path->nextout.tv_usec += ((out->samples % 8000) * 125);
+				if (path->nextout.tv_usec >= 1000000) {
+					path->nextout.tv_sec++;
+					path->nextout.tv_usec -= 1000000;
+				}
+			} else {
+				out->delivery.tv_sec = 0;
+				out->delivery.tv_usec = 0;
 			}
 			return out;
 		}




More information about the svn-commits mailing list