Skip to content
George Murdocca edited this page Jul 6, 2019 · 1 revision

Welcome to the asterisk-Softmodem wiki!

Note when compiling against Asterisk 16.2.1 and spandsp-0.0.6pre21.tgz

Compile error occurs (Asterisk 16.x compile is more strict than previous versions):

$ make apps                                                                                                                                                  
   [CC] app_softmodem.c -> app_softmodem.o                                                                                                                   
app_softmodem.c:21:23: error: expected declaration specifiers or '...' before string constant                                                                
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")                                                                                                               
                       ^~~~~~~~                                                                                                                              
app_softmodem.c:21:33: error: expected declaration specifiers or '...' before string constant                                                                
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")                                                                                                               
                                 ^~~~~~~~~~~~                                                                                                                
In file included from /home/pi/development/asterisk/asterisk-16.2.1~dfsg/include/asterisk.h:23,                                                              
                 from app_softmodem.c:19:                                                                                                                    
/usr/local/include/spandsp/fir.h: In function 'fir16_create':                                                                                                
/home/pi/development/asterisk/asterisk-16.2.1~dfsg/include/asterisk/astmm.h:160:2: error: 'Do_not_use_malloc__use_ast_malloc' undeclared (first use in this fu
nction)                                                                                                                                                      
  Do_not_use_malloc__use_ast_malloc->fail(a)                                                                                                                 
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                          
/home/pi/development/asterisk/asterisk-16.2.1~dfsg/include/asterisk/astmm.h:160:2: note: each undeclared identifier is reported only once for each function it
 appears in
/usr/local/include/spandsp/fir.h: In function 'fir16_free':
/home/pi/development/asterisk/asterisk-16.2.1~dfsg/include/asterisk/astmm.h:162:2: error: 'Do_not_use_free__use_ast_free_or_ast_std_free_for_remotely_allocate
d_memory' undeclared (first use in this function)
  Do_not_use_free__use_ast_free_or_ast_std_free_for_remotely_allocated_memory->fail(a)                                                                       
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/spandsp/fir.h: In function 'fir32_create':
/home/pi/development/asterisk/asterisk-16.2.1~dfsg/include/asterisk/astmm.h:160:2: error: 'Do_not_use_malloc__use_ast_malloc' undeclared (first use in this fu
nction)
  Do_not_use_malloc__use_ast_malloc->fail(a)
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/spandsp/fir.h: In function 'fir32_free':
/home/pi/development/asterisk/asterisk-16.2.1~dfsg/include/asterisk/astmm.h:162:2: error: 'Do_not_use_free__use_ast_free_or_ast_std_free_for_remotely_allocate
d_memory' undeclared (first use in this function)
  Do_not_use_free__use_ast_free_or_ast_std_free_for_remotely_allocated_memory->fail(a)                                                                       
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/spandsp/fir.h: In function 'fir_float_create':
/home/pi/development/asterisk/asterisk-16.2.1~dfsg/include/asterisk/astmm.h:160:2: error: 'Do_not_use_malloc__use_ast_malloc' undeclared (first use in this fu
nction)
  Do_not_use_malloc__use_ast_malloc->fail(a)
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/spandsp/fir.h: In function 'fir_float_free':
/home/pi/development/asterisk/asterisk-16.2.1~dfsg/include/asterisk/astmm.h:162:2: error: 'Do_not_use_free__use_ast_free_or_ast_std_free_for_remotely_allocate
d_memory' undeclared (first use in this function)
  Do_not_use_free__use_ast_free_or_ast_std_free_for_remotely_allocated_memory->fail(a)                                                                       
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[1]: *** [/home/pi/development/asterisk/asterisk-16.2.1~dfsg/Makefile.rules:153: app_softmodem.o] Error 1                                                
make: *** [Makefile:383: apps] Error 2
$

To fix, apply this patch to spandsp-0.0.6pre21.tgz source tree:

--- src/spandsp/fir.h.orig      2019-07-06 18:16:07.575441766 +1000
+++ src/spandsp/fir.h   2019-07-06 18:16:13.425362448 +1000
@@ -88,10 +88,10 @@
     fir->curr_pos = taps - 1;
     fir->coeffs = coeffs;
 #if defined(USE_MMX)  ||  defined(USE_SSE2)
-    if ((fir->history = malloc(2*taps*sizeof(int16_t))))
+    if ((fir->history = ast_malloc(2*taps*sizeof(int16_t))))
         memset(fir->history, 0, 2*taps*sizeof(int16_t));
 #else
-    if ((fir->history = (int16_t *) malloc(taps*sizeof(int16_t))))
+    if ((fir->history = (int16_t *) ast_malloc(taps*sizeof(int16_t))))
         memset(fir->history, 0, taps*sizeof(int16_t));
 #endif
     return fir->history;
@@ -110,7 +110,7 @@
 
 static __inline__ void fir16_free(fir16_state_t *fir)
 {
-    free(fir->history);
+    ast_free(fir->history);
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -210,7 +210,7 @@
     fir->taps = taps;
     fir->curr_pos = taps - 1;
     fir->coeffs = coeffs;
-    fir->history = (int16_t *) malloc(taps*sizeof(int16_t));
+    fir->history = (int16_t *) ast_malloc(taps*sizeof(int16_t));
     if (fir->history)
        memset(fir->history, '\0', taps*sizeof(int16_t));
     return fir->history;
@@ -225,7 +225,7 @@
 
 static __inline__ void fir32_free(fir32_state_t *fir)
 {
-    free(fir->history);
+    ast_free(fir->history);
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -258,7 +258,7 @@
     fir->taps = taps;
     fir->curr_pos = taps - 1;
     fir->coeffs = coeffs;
-    fir->history = (float *) malloc(taps*sizeof(float));
+    fir->history = (float *) ast_malloc(taps*sizeof(float));
     if (fir->history)
         memset(fir->history, '\0', taps*sizeof(float));
     return fir->history;
@@ -267,7 +267,7 @@
     
 static __inline__ void fir_float_free(fir_float_state_t *fir)
 {
-    free(fir->history);
+    ast_free(fir->history);
 }
 /*- End of function --------------------------------------------------------*/

Also comment out line 21 of app_softmodem.c to read:

//ASTERISK_FILE_VERSION(__FILE__, "$Revision$")

make apps should now work and produce apps/app_softmodem.so as per the README.

Clone this wiki locally