提交 1248e6c6 authored 作者: Anthony Minessale's avatar Anthony Minessale

dont let value dip below 0

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16409 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 2ddd9904
......@@ -181,7 +181,7 @@ SWITCH_DECLARE(void) switch_time_calibrate_clock(void)
{
int x;
switch_interval_time_t avg, val = 1000, want = 1000;
int over = 0, under = 0, good = 0, step = 50, diff = 0;
int over = 0, under = 0, good = 0, step = 50, diff = 0, retry = 0;
#ifdef HAVE_CLOCK_GETRES
struct timespec ts;
......@@ -196,6 +196,10 @@ SWITCH_DECLARE(void) switch_time_calibrate_clock(void)
}
#endif
top:
val = 1000;
step = 50;
over = under = good = 0;
OFFSET = 0;
for (x = 0; x < 100; x++) {
......@@ -221,11 +225,19 @@ SWITCH_DECLARE(void) switch_time_calibrate_clock(void)
} else if (avg > want) {
if (under) {calc_step();}
under = good = 0;
if ((val - step) < 0) {
if (++retry > 2) break;
goto top;
}
val -= step;
over++;
} else if (avg < want) {
if (over) {calc_step();}
over = good = 0;
if ((val - step) < 0) {
if (++retry > 2) break;
goto top;
}
val += step;
under++;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论