timer calibration tweaks

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16294 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2010-01-13 22:36:13 +00:00
parent 74fd6fb6f8
commit 11d8868b4a
1 changed files with 12 additions and 10 deletions

View File

@ -176,7 +176,7 @@ static switch_interval_time_t average_time(switch_interval_time_t t, int reps)
} }
#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) static void calibrate_clock(void)
{ {
int x; int x;
@ -188,7 +188,9 @@ static void calibrate_clock(void)
clock_getres(CLOCK_MONOTONIC, &ts); clock_getres(CLOCK_MONOTONIC, &ts);
if (ts.tv_nsec / 1000 > 1500) { if (ts.tv_nsec / 1000 > 1500) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, 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); "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; return;
} }
#endif #endif
@ -200,7 +202,9 @@ static void calibrate_clock(void)
diff = abs((int)(want - avg)); diff = abs((int)(want - avg));
if (diff > 1500) { if (diff > 1500) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, 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; return;
} }
@ -211,17 +215,15 @@ static void calibrate_clock(void)
break; break;
} }
} else if (avg > want) { } else if (avg > want) {
if (under) {calc_step();}
under = 0; under = 0;
val -= step; val -= step;
if (++over > 3) { over++;
calc_step();
}
} else if (avg < want) { } else if (avg < want) {
if (over) {calc_step();}
over = 0; over = 0;
val += step; val += step;
if (++under > 3) { under++;
calc_step();
}
} }
} }