提交 b61bf02c authored 作者: Mike Jerris's avatar Mike Jerris

Merge pull request #829 in FS/freeswitch from…

Merge pull request #829 in FS/freeswitch from ~PIOTRGREGOR/freeswitch:bugfix/FS-9117-avmd-build-fails-on-windows to master

* commit 'f476e23c':
  FS-9117 [avmd] #fix build on Windows
#ifndef WIN32 /* currently we support fast acosf computation only on UNIX/Linux */
#include <switch.h> #include <switch.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -312,4 +315,5 @@ dump_table_summary(void) ...@@ -312,4 +315,5 @@ dump_table_summary(void)
printf("i [%d] from float [%f]\n", index_from_float(f), f); printf("i [%d] from float [%f]\n", index_from_float(f), f);
} }
#endif /* FAST_ACOSF_TESTING */ #endif /* FAST_ACOSF_TESTING */
#endif /* WIN32 */
#ifndef WIN32 /* currently we support fast acosf computation only on UNIX/Linux */
/* /*
* @brief Fast arithmetic using precomputed arc cosine table. * @brief Fast arithmetic using precomputed arc cosine table.
* Contributor(s): * Contributor(s):
...@@ -46,3 +47,4 @@ extern float fast_acosf(float x); ...@@ -46,3 +47,4 @@ extern float fast_acosf(float x);
extern int compute_table(void); extern int compute_table(void);
#endif /* __AVMD_FAST_ACOSF_H__ */ #endif /* __AVMD_FAST_ACOSF_H__ */
#endif
...@@ -483,7 +483,7 @@ avmd_parse_u8_user_input(const char *input, uint8_t *output, ...@@ -483,7 +483,7 @@ avmd_parse_u8_user_input(const char *input, uint8_t *output,
if (helper < min || helper > UINT8_MAX || helper > max || (pCh == input) || (*pCh != '\0')) { if (helper < min || helper > UINT8_MAX || helper > max || (pCh == input) || (*pCh != '\0')) {
return -1; return -1;
} }
*output= helper; *output = (uint8_t) helper;
return 0; return 0;
} }
...@@ -500,7 +500,7 @@ avmd_parse_u16_user_input(const char *input, uint16_t *output, ...@@ -500,7 +500,7 @@ avmd_parse_u16_user_input(const char *input, uint16_t *output,
if (helper < min || helper > UINT16_MAX || helper > max || (pCh == input) || (*pCh != '\0')) { if (helper < min || helper > UINT16_MAX || helper > max || (pCh == input) || (*pCh != '\0')) {
return -1; return -1;
} }
*output= helper; *output = (uint16_t) helper;
return 0; return 0;
} }
...@@ -689,8 +689,10 @@ avmd_show(switch_stream_handle_t *stream, switch_mutex_t *mutex) ...@@ -689,8 +689,10 @@ avmd_show(switch_stream_handle_t *stream, switch_mutex_t *mutex)
SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load) SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load)
{ {
#ifndef WIN32
char err[150]; char err[150];
int ret; int ret;
#endif
switch_application_interface_t *app_interface; switch_application_interface_t *app_interface;
switch_api_interface_t *api_interface; switch_api_interface_t *api_interface;
...@@ -727,6 +729,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load) ...@@ -727,6 +729,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load)
/* Not so severe to prevent further loading, well - it depends, anyway */ /* Not so severe to prevent further loading, well - it depends, anyway */
} }
#ifndef WIN32
if (avmd_globals.settings.fast_math == 1) { if (avmd_globals.settings.fast_math == 1) {
ret = init_fast_acosf(); ret = init_fast_acosf();
if (ret != 0) { if (ret != 0) {
...@@ -768,6 +771,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load) ...@@ -768,6 +771,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load)
"is [%s]\n", ACOS_TABLE_FILENAME "is [%s]\n", ACOS_TABLE_FILENAME
); );
} }
#endif
SWITCH_ADD_APP(app_interface, "avmd_start","Start avmd detection", SWITCH_ADD_APP(app_interface, "avmd_start","Start avmd detection",
"Start avmd detection", avmd_start_app, "", SAF_NONE); "Start avmd detection", avmd_start_app, "", SAF_NONE);
...@@ -1022,12 +1026,15 @@ SWITCH_STANDARD_APP(avmd_start_function) ...@@ -1022,12 +1026,15 @@ SWITCH_STANDARD_APP(avmd_start_function)
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown)
{ {
#ifndef WIN32
int res; int res;
#endif
switch_mutex_lock(avmd_globals.mutex); switch_mutex_lock(avmd_globals.mutex);
avmd_unregister_all_events(); avmd_unregister_all_events();
#ifndef WIN32
if (avmd_globals.settings.fast_math == 1) { if (avmd_globals.settings.fast_math == 1) {
res = destroy_fast_acosf(); res = destroy_fast_acosf();
if (res != 0) { if (res != 0) {
...@@ -1045,6 +1052,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown) ...@@ -1045,6 +1052,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown)
} }
} }
} }
#endif
switch_event_unbind_callback(avmd_reloadxml_event_handler); switch_event_unbind_callback(avmd_reloadxml_event_handler);
...@@ -1494,13 +1502,13 @@ static void avmd_process(avmd_session_t *s, switch_frame_t *frame) ...@@ -1494,13 +1502,13 @@ static void avmd_process(avmd_session_t *s, switch_frame_t *frame)
/* calculate variance (biased estimator) */ /* calculate variance (biased estimator) */
v = s->sqa_b.sma - (s->sma_b.sma * s->sma_b.sma); v = s->sqa_b.sma - (s->sma_b.sma * s->sma_b.sma);
#ifdef AVMD_DEBUG #ifdef AVMD_DEBUG
#ifdef AVMD_FAST_MATH #if !defined(WIN32) && defined(AVMD_FAST_MATH)
f = 0.5 * (double) fast_acosf((float)omega); f = 0.5 * (double) fast_acosf((float)omega);
sma_digital_freq = 0.5 * (double) fast_acosf((float)s->sma_b.sma); sma_digital_freq = 0.5 * (double) fast_acosf((float)s->sma_b.sma);
#else #else
f = 0.5 * acos(omega); f = 0.5 * acos(omega);
sma_digital_freq = 0.5 * acos(s->sma_b.sma); sma_digital_freq = 0.5 * acos(s->sma_b.sma);
#endif /* AVMD_FAST_MATH */ #endif /* !WIN32 && AVMD_FAST_MATH */
#ifdef AVMD_REQUIRE_CONTINUOUS_STREAK #ifdef AVMD_REQUIRE_CONTINUOUS_STREAK
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(s->session), SWITCH_LOG_DEBUG, switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(s->session), SWITCH_LOG_DEBUG,
"<<< AVMD v[%.10f]\tomega[%f]\tf[%f] [%f]Hz\t\tsma[%f][%f]Hz\t\tsqa[%f]\t" "<<< AVMD v[%.10f]\tomega[%f]\tf[%f] [%f]Hz\t\tsma[%f][%f]Hz\t\tsqa[%f]\t"
...@@ -1527,11 +1535,11 @@ static void avmd_process(avmd_session_t *s, switch_frame_t *frame) ...@@ -1527,11 +1535,11 @@ static void avmd_process(avmd_session_t *s, switch_frame_t *frame)
#else #else
if (v < VARIANCE_THRESHOLD && (s->sma_b.lpos > 1)) { if (v < VARIANCE_THRESHOLD && (s->sma_b.lpos > 1)) {
#endif #endif
#ifdef AVMD_FAST_MATH #if !defined(WIN32) && defined(AVMD_FAST_MATH)
sma_digital_freq = 0.5 * (double) fast_acosf((float)s->sma_b.sma); sma_digital_freq = 0.5 * (double) fast_acosf((float)s->sma_b.sma);
#else #else
sma_digital_freq = 0.5 * acos(s->sma_b.sma); sma_digital_freq = 0.5 * acos(s->sma_b.sma);
#endif /* AVMD_FAST_MATH */ #endif /* !WIN32 && AVMD_FAST_MATH */
switch_channel_set_variable_printf(channel, "avmd_total_time", switch_channel_set_variable_printf(channel, "avmd_total_time",
"[%d]", (int)(switch_micro_time_now() - s->start_time) / 1000); "[%d]", (int)(switch_micro_time_now() - s->start_time) / 1000);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论