mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-15 16:39:14 +00:00
small timer test tweak for horribly clocked boxen
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16725 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
17176ff6fa
commit
ae2354be24
@ -181,12 +181,20 @@ 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, lastgood = 0;
|
int over = 0, under = 0, good = 0, step = 50, diff = 0, retry = 0, lastgood = 0, one_k = 0;
|
||||||
|
|
||||||
#ifdef HAVE_CLOCK_GETRES
|
#ifdef HAVE_CLOCK_GETRES
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
long res = 0;
|
||||||
clock_getres(CLOCK_MONOTONIC, &ts);
|
clock_getres(CLOCK_MONOTONIC, &ts);
|
||||||
if (ts.tv_nsec / 1000 > 1500) {
|
res = ts.tv_nsec / 1000;
|
||||||
|
|
||||||
|
|
||||||
|
if (res > 900 && res < 1100) {
|
||||||
|
one_k = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res > 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!\n"
|
"Timer resolution of %ld microseconds detected!\n"
|
||||||
"Do you have your kernel timer set to higher than 1 kHz? You may experience audio problems.\n", ts.tv_nsec / 1000);
|
"Do you have your kernel timer set to higher than 1 kHz? You may experience audio problems.\n", ts.tv_nsec / 1000);
|
||||||
@ -260,6 +268,10 @@ SWITCH_DECLARE(void) switch_time_calibrate_clock(void)
|
|||||||
OFFSET = (int) (want - lastgood);
|
OFFSET = (int) (want - lastgood);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset of %d calculated (fallback)\n", OFFSET);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset of %d calculated (fallback)\n", OFFSET);
|
||||||
switch_time_set_cond_yield(SWITCH_TRUE);
|
switch_time_set_cond_yield(SWITCH_TRUE);
|
||||||
|
} else if (one_k) {
|
||||||
|
OFFSET = 900;
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset CANNOT BE DETECTED, forcing OFFSET to 900\n");
|
||||||
|
switch_time_set_cond_yield(SWITCH_TRUE);
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset NOT calculated\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset NOT calculated\n");
|
||||||
switch_time_set_cond_yield(SWITCH_TRUE);
|
switch_time_set_cond_yield(SWITCH_TRUE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user