fix freetdm win compilation
This commit is contained in:
parent
48ec0c2831
commit
1a4b6d5440
|
@ -326,10 +326,34 @@
|
|||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\src\include\freetdm.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\fsk.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\ftdm_buffer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\ftdm_config.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\ftdm_dso.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\ftdm_threadmutex.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\ftdm_types.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\g711.h"
|
||||
>
|
||||
|
@ -358,34 +382,10 @@
|
|||
RelativePath="..\src\include\libteletone_generate.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\freetdm.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\uart.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\ftdm_buffer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\ftdm_config.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\ftdm_dso.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\ftdm_threadmutex.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\ftdm_types.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
|
@ -396,6 +396,38 @@
|
|||
RelativePath="..\src\fsk.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_buffer.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_callerid.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_config.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_cpu_monitor.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_dso.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_io.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_queue.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_threadmutex.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\g711.c"
|
||||
>
|
||||
|
@ -420,34 +452,6 @@
|
|||
RelativePath="..\src\uart.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_buffer.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_callerid.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_config.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_dso.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_io.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_queue.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_threadmutex.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
|
|
@ -201,28 +201,31 @@ FT_DECLARE(ftdm_status_t) ftdm_cpu_get_system_idle_time (struct ftdm_cpu_monitor
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
#elif defined (WIN32) || defined (WIN64)
|
||||
#elif defined (__WINDOWS__)
|
||||
FT_DECLARE(ftdm_status_t) ftdm_cpu_get_system_idle_time(struct ftdm_cpu_monitor_stats *p, double *idle_percentage)
|
||||
{
|
||||
FILETIME idleTime;
|
||||
FILETIME kernelTime;
|
||||
FILETIME userTime;
|
||||
int64_t i64UserTime;
|
||||
int64_t i64KernelTime;
|
||||
int64_t i64IdleTime;
|
||||
|
||||
if (!::GetSystemTimes(&idleTime, &kernelTime, &userTime)) {
|
||||
return false;
|
||||
if (!GetSystemTimes(&idleTime, &kernelTime, &userTime)) {
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
__int64 i64UserTime = (__int64)userTime.dwLowDateTime | ((__int64)userTime.dwHighDateTime << 32);
|
||||
i64UserTime = (int64_t)userTime.dwLowDateTime | ((int64_t)userTime.dwHighDateTime << 32);
|
||||
|
||||
__int64 i64KernelTime = (__int64)kernelTime.dwLowDateTime | ((__int64)kernelTime.dwHighDateTime << 32);
|
||||
i64KernelTime = (int64_t)kernelTime.dwLowDateTime | ((int64_t)kernelTime.dwHighDateTime << 32);
|
||||
|
||||
__int64 i64IdleTime = (__int64)idleTime.dwLowDateTime | ((__int64)idleTime.dwHighDateTime << 32);
|
||||
i64IdleTime = (int64_t)idleTime.dwLowDateTime | ((int64_t)idleTime.dwHighDateTime << 32);
|
||||
|
||||
if (p->valid_last_times) {
|
||||
__int64 i64User = i64UserTime - p->i64LastUserTime;
|
||||
__int64 i64Kernel = i64KernelTime - p->i64LastKernelTime;
|
||||
__int64 i64Idle = i64IdleTime - p->i64LastIdleTime;
|
||||
__int64 i64System = i64User + i64Kernel;
|
||||
int64_t i64User = i64UserTime - p->i64LastUserTime;
|
||||
int64_t i64Kernel = i64KernelTime - p->i64LastKernelTime;
|
||||
int64_t i64Idle = i64IdleTime - p->i64LastIdleTime;
|
||||
int64_t i64System = i64User + i64Kernel;
|
||||
*idle_percentage = 100.0 * i64Idle / i64System;
|
||||
} else {
|
||||
*idle_percentage = 100.0;
|
||||
|
|
|
@ -2855,6 +2855,7 @@ static ftdm_status_t load_config(void)
|
|||
ftdm_config_t cfg;
|
||||
char *var, *val;
|
||||
int catno = -1;
|
||||
int intparam = 0;
|
||||
int currindex = 0;
|
||||
ftdm_span_t *span = NULL;
|
||||
unsigned configured = 0, d = 0;
|
||||
|
@ -3059,14 +3060,16 @@ static ftdm_status_t load_config(void)
|
|||
ftdm_log(FTDM_LOG_ERROR, "Invalid cpu monitoring interval %s\n", val);
|
||||
}
|
||||
} else if (!strncasecmp(var, "cpu_set_alarm_threshold", sizeof("cpu_set_alarm_threshold")-1)) {
|
||||
if (atoi(val) > 0 && atoi(val) < 100) {
|
||||
globals.cpu_monitor.set_alarm_threshold = atoi(val);
|
||||
intparam = atoi(val);
|
||||
if (intparam > 0 && intparam < 100) {
|
||||
globals.cpu_monitor.set_alarm_threshold = (uint8_t)intparam;
|
||||
} else {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Invalid cpu alarm set threshold %s\n", val);
|
||||
}
|
||||
} else if (!strncasecmp(var, "cpu_reset_alarm_threshold", sizeof("cpu_reset_alarm_threshold")-1)) {
|
||||
if (atoi(val) > 0 && atoi(val) < 100) {
|
||||
globals.cpu_monitor.reset_alarm_threshold = atoi(val);
|
||||
intparam = atoi(val);
|
||||
if (intparam > 0 && intparam < 100) {
|
||||
globals.cpu_monitor.reset_alarm_threshold = (uint8_t)intparam;
|
||||
if (globals.cpu_monitor.reset_alarm_threshold > globals.cpu_monitor.set_alarm_threshold) {
|
||||
globals.cpu_monitor.reset_alarm_threshold = globals.cpu_monitor.set_alarm_threshold - 10;
|
||||
ftdm_log(FTDM_LOG_ERROR, "Cpu alarm reset threshold must be lower than set threshold"
|
||||
|
@ -3652,6 +3655,9 @@ static void *ftdm_cpu_monitor_run(ftdm_thread_t *me, void *obj)
|
|||
ftdm_delete_cpu_monitor(cpu_stats);
|
||||
monitor->running = 0;
|
||||
return NULL;
|
||||
#ifdef __WINDOWS__
|
||||
UNREFERENCED_PARAMETER(me);
|
||||
#endif
|
||||
}
|
||||
|
||||
static ftdm_status_t ftdm_cpu_monitor_start(void)
|
||||
|
|
|
@ -314,7 +314,7 @@ FT_DECLARE(ftdm_status_t) ftdm_interrupt_wait(ftdm_interrupt_t *interrupt, int m
|
|||
num++;
|
||||
ints[1] = interrupt->device;
|
||||
}
|
||||
res = WaitForMultipleObjects(num, &ints, FALSE, ms >= 0 ? ms : INFINITE);
|
||||
res = WaitForMultipleObjects(num, ints, FALSE, ms >= 0 ? ms : INFINITE);
|
||||
switch (res) {
|
||||
case WAIT_TIMEOUT:
|
||||
return FTDM_TIMEOUT;
|
||||
|
@ -366,7 +366,7 @@ FT_DECLARE(ftdm_status_t) ftdm_interrupt_signal(ftdm_interrupt_t *interrupt)
|
|||
{
|
||||
ftdm_assert_return(interrupt != NULL, FTDM_FAIL, "Interrupt is null!\n");
|
||||
#ifdef WIN32
|
||||
if (!SetEvent(interrupt->interrupt)) {
|
||||
if (!SetEvent(interrupt->event)) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Failed to signal interrupt\n");
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
@ -400,10 +400,42 @@ FT_DECLARE(ftdm_status_t) ftdm_interrupt_destroy(ftdm_interrupt_t **ininterrupt)
|
|||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_interrupt_multiple_wait(ftdm_interrupt_t *interrupts[], ftdm_size_t size, int ms)
|
||||
{
|
||||
#ifndef WIN32
|
||||
int i;
|
||||
int res = 0;
|
||||
int numdevices = 0;
|
||||
unsigned i;
|
||||
#if defined(__WINDOWS__)
|
||||
DWORD res = 0;
|
||||
HANDLE ints[20];
|
||||
if (size > (ftdm_array_len(ints)/2)) {
|
||||
/* improve if needed: dynamically allocate the list of interrupts *only* when exceeding the default size */
|
||||
ftdm_log(FTDM_LOG_CRIT, "Unsupported size of interrupts: %d, implement me!\n", size);
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
ints[i] = interrupts[i]->event;
|
||||
if (interrupts[i]->device != FTDM_INVALID_SOCKET) {
|
||||
ints[i+numdevices] = interrupts[i]->device;
|
||||
numdevices++;
|
||||
}
|
||||
}
|
||||
|
||||
res = WaitForMultipleObjects(size+numdevices, ints, FALSE, ms >= 0 ? ms : INFINITE);
|
||||
|
||||
switch (res) {
|
||||
case WAIT_TIMEOUT:
|
||||
return FTDM_TIMEOUT;
|
||||
case WAIT_FAILED:
|
||||
case WAIT_ABANDONED: /* is it right to fail with abandoned? */
|
||||
return FTDM_FAIL;
|
||||
default:
|
||||
if (res >= (size+numdevices)) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Error waiting for freetdm interrupt event (WaitForSingleObject returned %d)\n", res);
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
/* fall-through to FTDM_SUCCESS at the end of the function */
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
int res = 0;
|
||||
char pipebuf[255];
|
||||
struct pollfd ints[size*2];
|
||||
|
||||
|
@ -432,6 +464,7 @@ FT_DECLARE(ftdm_status_t) ftdm_interrupt_multiple_wait(ftdm_interrupt_t *interru
|
|||
return FTDM_TIMEOUT;
|
||||
}
|
||||
|
||||
/* check for events in the pipes, NOT in the devices */
|
||||
for (i = 0; i < size; i++) {
|
||||
if (ints[i].revents & POLLIN) {
|
||||
res = read(ints[i].fd, pipebuf, sizeof(pipebuf));
|
||||
|
@ -440,7 +473,7 @@ FT_DECLARE(ftdm_status_t) ftdm_interrupt_multiple_wait(ftdm_interrupt_t *interru
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#endif
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -101,8 +101,6 @@ static struct {
|
|||
FIO_SPAN_POLL_EVENT_FUNCTION(wanpipe_poll_event);
|
||||
FIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_next_event);
|
||||
|
||||
#define WP_INVALID_SOCKET -1
|
||||
|
||||
/**
|
||||
* \brief Poll for event on a wanpipe socket
|
||||
* \param fd Wanpipe socket descriptor
|
||||
|
@ -224,7 +222,7 @@ static unsigned wp_open_range(ftdm_span_t *span, unsigned spanno, unsigned start
|
|||
}
|
||||
for(x = start; x < end; x++) {
|
||||
ftdm_channel_t *chan;
|
||||
ftdm_socket_t sockfd = WP_INVALID_SOCKET;
|
||||
ftdm_socket_t sockfd = FTDM_INVALID_SOCKET;
|
||||
const char *dtmf = "none";
|
||||
if (!strncasecmp(span->name, "smg_prid_nfas", 8) && span->trunk_type == FTDM_TRUNK_T1 && x == 24) {
|
||||
#ifdef LIBSANGOMA_VERSION
|
||||
|
@ -236,7 +234,7 @@ static unsigned wp_open_range(ftdm_span_t *span, unsigned spanno, unsigned start
|
|||
sockfd = tdmv_api_open_span_chan(spanno, x);
|
||||
}
|
||||
|
||||
if (sockfd == WP_INVALID_SOCKET) {
|
||||
if (sockfd == FTDM_INVALID_SOCKET) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Failed to open wanpipe device span %d channel %d\n", spanno, x);
|
||||
continue;
|
||||
}
|
||||
|
@ -1166,9 +1164,8 @@ static FIO_CHANNEL_DESTROY_FUNCTION(wanpipe_channel_destroy)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (ftdmchan->sockfd > -1) {
|
||||
close(ftdmchan->sockfd);
|
||||
ftdmchan->sockfd = WP_INVALID_SOCKET;
|
||||
if (ftdmchan->sockfd != FTDM_INVALID_SOCKET) {
|
||||
sangoma_close(&ftdmchan->sockfd);
|
||||
}
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
|
|
Loading…
Reference in New Issue