]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9117 [avmd] #fix build on Windows
authorPiotr Gregor <piotrek.gregor@gmail.com>
Fri, 29 Apr 2016 17:23:33 +0000 (18:23 +0100)
committerPiotr Gregor <piotrek.gregor@gmail.com>
Fri, 29 Apr 2016 18:27:55 +0000 (19:27 +0100)
src/mod/applications/mod_avmd/avmd_fast_acosf.c
src/mod/applications/mod_avmd/avmd_fast_acosf.h
src/mod/applications/mod_avmd/mod_avmd.c

index 1974c9852f1f83221ce6f6c4cba82c0b7649f3c2..cb0500b31556b57d75802662e08f08fa3cb9ce5b 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef WIN32   /* currently we support fast acosf computation only on UNIX/Linux */
+
+
 #include <switch.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -312,4 +315,5 @@ dump_table_summary(void)
     printf("i [%d] from float [%f]\n", index_from_float(f), f);
 }
 
-#endif /* FAST_ACOSF_TESTING */
+#endif  /* FAST_ACOSF_TESTING */
+#endif  /* WIN32 */
index 1c3b68ca1a125b9755a8ce61df9d32c5a45132f5..0b9752713fae95c83fcaae28a4216d8f1ddbbcb0 100644 (file)
@@ -1,3 +1,4 @@
+#ifndef WIN32   /* currently we support fast acosf computation only on UNIX/Linux */
 /*
  * @brief   Fast arithmetic using precomputed arc cosine table.
  * Contributor(s):
@@ -46,3 +47,4 @@ extern float fast_acosf(float x);
 extern int compute_table(void);
 
 #endif /* __AVMD_FAST_ACOSF_H__ */
+#endif
index 5e8e2a7ecc3e1566e9a4b3ba5c466d042bddc7cf..73db88916db0ebf0a24cf1d0f0841c8128c19ea2 100644 (file)
@@ -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')) {
         return -1;
     }
-    *output= helper;
+    *output = (uint8_t) helper;
     return 0;
 }
 
@@ -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')) {
         return -1;
     }
-    *output= helper;
+    *output = (uint16_t) helper;
     return 0;
 }
 
@@ -689,8 +689,10 @@ avmd_show(switch_stream_handle_t *stream, switch_mutex_t *mutex)
 
 SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load)
 {
+#ifndef WIN32
     char    err[150];
     int     ret;
+#endif
 
        switch_application_interface_t *app_interface;
        switch_api_interface_t *api_interface;
@@ -727,6 +729,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load)
                /* Not so severe to prevent further loading, well - it depends, anyway */
        }
 
+#ifndef WIN32
     if (avmd_globals.settings.fast_math == 1) {
         ret = init_fast_acosf();
         if (ret != 0) {
@@ -768,6 +771,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load)
             "is [%s]\n", ACOS_TABLE_FILENAME
                    );
     }
+#endif
 
        SWITCH_ADD_APP(app_interface, "avmd_start","Start avmd detection",
             "Start avmd detection", avmd_start_app, "", SAF_NONE);
@@ -1022,12 +1026,15 @@ SWITCH_STANDARD_APP(avmd_start_function)
 
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown)
 {
+#ifndef WIN32
        int res;
+#endif
 
     switch_mutex_lock(avmd_globals.mutex);
 
     avmd_unregister_all_events();
-       
+
+#ifndef WIN32
     if (avmd_globals.settings.fast_math == 1) {
            res = destroy_fast_acosf();
         if (res != 0) {
@@ -1045,6 +1052,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown)
             }
         }
     }
+#endif
 
        switch_event_unbind_callback(avmd_reloadxml_event_handler);
 
@@ -1494,13 +1502,13 @@ static void avmd_process(avmd_session_t *s, switch_frame_t *frame)
                                /* calculate variance (biased estimator) */
                                v = s->sqa_b.sma - (s->sma_b.sma * s->sma_b.sma);
 #ifdef AVMD_DEBUG
-    #ifdef  AVMD_FAST_MATH
+    #if !defined(WIN32) && defined(AVMD_FAST_MATH)
                 f =  0.5 * (double) fast_acosf((float)omega);
                 sma_digital_freq =  0.5 * (double) fast_acosf((float)s->sma_b.sma);
     #else
                 f = 0.5 * acos(omega);
                 sma_digital_freq =  0.5 * acos(s->sma_b.sma);
-    #endif /* AVMD_FAST_MATH */
+    #endif /* !WIN32 && AVMD_FAST_MATH */
     #ifdef AVMD_REQUIRE_CONTINUOUS_STREAK
                                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"
@@ -1527,11 +1535,11 @@ static void avmd_process(avmd_session_t *s, switch_frame_t *frame)
 #else
                        if (v < VARIANCE_THRESHOLD && (s->sma_b.lpos > 1)) {
 #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);
     #else
                 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",
                         "[%d]", (int)(switch_micro_time_now() - s->start_time) / 1000);