Revision
16294
Author
anthm
Date
2010-01-13 16:36:13 -0600 (Wed, 13 Jan 2010)

Log Message

timer calibration tweaks

Modified Paths

Diff

Modified: freeswitch/trunk/src/switch_time.c (16293 => 16294)


--- freeswitch/trunk/src/switch_time.c	2010-01-13 22:26:00 UTC (rev 16293)
+++ freeswitch/trunk/src/switch_time.c	2010-01-13 22:36:13 UTC (rev 16294)
@@ -176,7 +176,7 @@
 	
 }
 
-#define calc_step() if ((step - 10) > 10) step -= 10; else if (step > 1) step--
+#define calc_step() if (step > 11) step -= 10; else if (step > 1) step--
 static void calibrate_clock(void)
 {
 	int x;
@@ -187,8 +187,10 @@
 	struct timespec ts;
 	clock_getres(CLOCK_MONOTONIC, &ts);
 	if (ts.tv_nsec / 1000 > 1500) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, 
-						  "Timer resolution of %ld microseconds detected do you have your kernel timer set to higher than 1khz?\n", ts.tv_nsec / 1000);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						"Timer resolution of %ld microseconds detected!\n"
+						"Do you have your kernel timer set to higher than 1khz? You may experience audio problems.\n", ts.tv_nsec / 1000);
+		sleep(5);
 		return;
 	}
 #endif
@@ -200,7 +202,9 @@
 		diff = abs((int)(want - avg));
 		if (diff > 1500) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, 
-							  "Abnormally large timer gap detected, do you have your kernel timer set to higher than 1khz?\n");
+							  "Abnormally large timer gap %d detected!\n"
+							  "Do you have your kernel timer set to higher than 1khz? You may experience audio problems.\n", diff);
+			sleep(5);
 			return;
 		}
 
@@ -211,17 +215,15 @@
 				break;
 			}
 		} else if (avg > want) {
+			if (under) {calc_step();}
 			under = 0;
 			val -= step;
-			if (++over > 3) {
-				calc_step();
-			}
+			over++;
 		} else if (avg < want) {
+			if (over) {calc_step();}
 			over = 0;
 			val += step;
-			if (++under > 3) {
-				calc_step();
-			}
+			under++;
 		}
 	}