mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-07-14 19:16:59 +00:00
small tweak
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16455 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
b4fecf0b4d
commit
4cb029e45f
@ -181,7 +181,7 @@ SWITCH_DECLARE(void) switch_time_calibrate_clock(void)
|
|||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
switch_interval_time_t avg, val = 1000, want = 1000;
|
switch_interval_time_t avg, val = 1000, want = 1000;
|
||||||
int over = 0, under = 0, good = 0, step = 50, diff = 0, retry = 0;
|
int over = 0, under = 0, good = 0, step = 50, diff = 0, retry = 0, lastgood = 0;
|
||||||
|
|
||||||
#ifdef HAVE_CLOCK_GETRES
|
#ifdef HAVE_CLOCK_GETRES
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
@ -207,7 +207,7 @@ SWITCH_DECLARE(void) switch_time_calibrate_clock(void)
|
|||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Test: %ld Average: %ld Step: %d\n", (long)val, (long)avg, step);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Test: %ld Average: %ld Step: %d\n", (long)val, (long)avg, step);
|
||||||
|
|
||||||
diff = abs((int)(want - avg));
|
diff = abs((int)(want - avg));
|
||||||
if (diff > 1500) {
|
if (diff > 2500) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||||
"Abnormally large timer gap %d detected!\n"
|
"Abnormally large timer gap %d detected!\n"
|
||||||
"Do you have your kernel timer set to higher than 1 kHz? You may experience audio problems.\n", diff);
|
"Do you have your kernel timer set to higher than 1 kHz? You may experience audio problems.\n", diff);
|
||||||
@ -216,9 +216,13 @@ SWITCH_DECLARE(void) switch_time_calibrate_clock(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (diff <= 100) {
|
||||||
|
lastgood = val;
|
||||||
|
}
|
||||||
|
|
||||||
if (diff <= 2) {
|
if (diff <= 2) {
|
||||||
under = over = 0;
|
under = over = 0;
|
||||||
|
lastgood = val;
|
||||||
if (++good > 10) {
|
if (++good > 10) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -246,6 +250,9 @@ SWITCH_DECLARE(void) switch_time_calibrate_clock(void)
|
|||||||
if (good >= 10) {
|
if (good >= 10) {
|
||||||
OFFSET = (int)(want - val);
|
OFFSET = (int)(want - val);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset of %d calculated\n", OFFSET);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset of %d calculated\n", OFFSET);
|
||||||
|
} else if (lastgood) {
|
||||||
|
OFFSET = (int)(want - lastgood);
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset of %d calculated (fallback)\n", OFFSET);
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset of NOT calculated\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset of NOT calculated\n");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user