shithub: sox

Download patch

ref: b0460afbdbde30abfaeb11e5fc50e3ff862b8839
parent: 9abe8822ba60526b4f02fb0fbf4634f4eb9bf51d
author: Mans Rullgard <mans@mansr.com>
date: Fri Aug 14 08:35:17 EDT 2020

amr: make dlopen options per library

--- a/configure.ac
+++ b/configure.ac
@@ -445,30 +445,33 @@
     [PKG_CHECK_MODULES([FLAC], [flac], [], [using_flac=no])])
 
 
-dnl When enable_dl_amrbw, do not let add libraries to be linked in
-dnl since they will be dlopen()'ed instead.
-ac_sox_save_AMRWB_LIBS="$AMRWB_LIBS"
 tmp_using_amrwb=no
 AC_CHECK_HEADERS(opencore-amrwb/dec_if.h,
     [AC_CHECK_LIB(opencore-amrwb, D_IF_init,
-        [AMRWB_LIBS="$AMRWB_LIBS -lopencore-amrwb"; tmp_using_amrwb=$opt_default])])
+        [OPENCORE_AMRWB_LIBS="$OPENCORE_AMRWB_LIBS -lopencore-amrwb"; tmp_using_amrwb=$opt_default])])
 AC_CHECK_HEADERS(vo-amrwbenc/enc_if.h,
     [AC_CHECK_LIB(vo-amrwbenc, E_IF_init,
-		    AMRWB_LIBS="$AMRWB_LIBS -lvo-amrwbenc"; tmp_using_amrwb=$opt_default)])
-AC_ARG_ENABLE(dl_amrwb,
-	      AS_HELP_STRING([--enable-dl-amrwb], 
-			     [Dlopen amrbw instead of linking in.]),
-			     enable_dl_amrwb=$enableval, enable_dl_amrwb=no)
-if test "x$using_libltdl" = "xyes" -a "x$enable_dl_amrwb" = "xyes"; then
-  AC_DEFINE(DL_AMRWB, 1, [Define to dlopen() amrwb.]) 
-  dnl When enable_dl_amrwb, do not let SOX_PATH_AMRWB add libraries
-  dnl to be linked in (since they will be dlopen()'ed instead).
-  AMRWB_LIBS="$ac_sox_save_AMRWB_LIBS"
-  dnl Force to using regardless if headers or libraries were found.
-  tmp_using_amrwb=yes
+        [VO_AMRWBENC_LIBS="$VO_AMRWBENC_LIBS -lvo-amrwbenc"; tmp_using_amrwb=$opt_default])])
+AC_ARG_ENABLE(dl_opencore_amrwb,
+	      AS_HELP_STRING([--enable-dl-opencore-amrwb],
+			     [Dlopen opencore-amrbw instead of linking in.]))
+AC_ARG_ENABLE(dl_vo_amrwbenc,
+	      AS_HELP_STRING([--enable-dl-vo-amrwbenc],
+			     [Dlopen vo-amrbwenc instead of linking in.]))
+if test "$using_libltdl" != "yes"; then
+  enable_dl_opencore_amrwb=no
+  enable_dl_vo_amrwbenc=no
+fi
+if test "$enable_dl_opencore_amrwb" = "yes"; then
+  AC_DEFINE(DL_OPENCORE_AMRWB, 1, [Define to dlopen() opencore-amrwb.])
 else
-  enable_dl_amrwb="no"
+  AMRWB_LIBS="$AMRWB_LIBS $OPENCORE_AMRWB_LIBS"
 fi
+if test "$enable_dl_vo_amrwbenc" = "yes"; then
+  AC_DEFINE(DL_VO_AMRWBENC, 1, [Define to dlopen() vo-amrwbenc.])
+else
+  AMRWB_LIBS="$AMRWB_LIBS $VO_AMRWBENC_LIBS"
+fi
 AC_OPTIONAL_FORMAT(amrwb, AMRWB, [using_amrwb=$tmp_using_amrwb])
 
 dnl When enable_dl_amrnb, do not let add libraries to be linked in
@@ -479,12 +482,11 @@
 		 [AC_CHECK_LIB(opencore-amrnb, Decoder_Interface_init, 
 		  AMRNB_LIBS="$AMRNB_LIBS -lopencore-amrnb", tmp_using_amrnb=no)],
 		  [tmp_using_amrnb=no])
-AC_ARG_ENABLE(dl_amrnb,
-	      AS_HELP_STRING([--enable-dl-amrnb], 
-			     [Dlopen amrnb instead of linking in.]),
-			     enable_dl_amrnb=$enableval, enable_dl_amrnb=no)
-if test "x$using_libltdl" = "xyes" -a "x$enable_dl_amrnb" = "xyes"; then
-  AC_DEFINE(DL_AMRNB, 1, [Define to dlopen() amrnb.]) 
+AC_ARG_ENABLE(dl_opencore_amrnb,
+	      AS_HELP_STRING([--enable-dl-opencore-amrnb],
+			     [Dlopen opencore-amrnb instead of linking in.]))
+if test "$using_libltdl" = "yes" -a "$enable_dl_opencore_amrnb" = "yes"; then
+  AC_DEFINE(DL_OPENCORE_AMRNB, 1, [Define to dlopen() opencore-amrnb.])
   dnl When enable_dl_amrnb, do not let SOX_PATH_AMRNB add libraries
   dnl to be linked in (since they will be dlopen()'ed instead).
   AMRNB_LIBS="$ac_sox_save_AMRNB_LIBS"
@@ -491,7 +493,7 @@
   dnl Force to using regardless if headers or libraries were found.
   tmp_using_amrnb=yes
 else
-  enable_dl_amrnb="no"
+  enable_dl_opencore_amrnb="no"
 fi
 AC_OPTIONAL_FORMAT(amrnb, AMRNB, [using_amrnb=$tmp_using_amrnb])
 
@@ -638,11 +640,12 @@
 echo "OPTIONAL FILE FORMATS"
 echo "amrnb......................$using_amrnb"
 if test "x$using_amrnb" = "xyes"; then
-echo " dlopen amrnb..............$enable_dl_amrnb"
+echo " dlopen amrnb..............${enable_dl_opencore_amrnb:-no}"
 fi
 echo "amrwb......................$using_amrwb"
 if test "x$using_amrwb" = "xyes"; then
-echo " dlopen amrwb..............$enable_dl_amrwb"
+echo " dlopen opencore-amrwb.....${enable_dl_opencore_amrwb:-no}"
+echo " dlopen vo-amrwbenc........${enable_dl_vo_amrwbenc:-no}"
 fi
 echo "flac.......................$using_flac"
 echo "gsm........................$using_gsm"
--- a/src/amr-nb.c
+++ b/src/amr-nb.c
@@ -45,7 +45,7 @@
 #define AMR_RATE            8000
 #define AMR_DESC            "3GPP Adaptive Multi Rate Narrow-Band (AMR-NB) lossy speech compressor"
 
-#ifdef DL_AMRNB
+#ifdef DL_OPENCORE_AMRNB
   #define AMR_FUNC  LSX_DLENTRY_DYNAMIC
 #else
   #define AMR_FUNC  LSX_DLENTRY_STATIC
@@ -80,7 +80,7 @@
 #define AMR_OPENCORE_DESC "amr-nb OpenCore library"
 static const char* const amr_opencore_library_names[] =
 {
-#ifdef DL_AMRWB
+#ifdef DL_OPENCORE_AMRNB
   "libopencore-amrnb",
   "libopencore-amrnb-0",
 #endif
--- a/src/amr-wb.c
+++ b/src/amr-wb.c
@@ -43,23 +43,23 @@
 #define AMR_RATE            16000
 #define AMR_DESC            "3GPP Adaptive Multi Rate Wide-Band (AMR-WB) lossy speech compressor"
 
-#ifdef DL_AMRWB
-  #define AMR_FUNC  LSX_DLENTRY_DYNAMIC
-#else
-  #define AMR_FUNC  LSX_DLENTRY_STATIC
-#endif /* DL_AMRWB */
-
 /* OpenCore definitions: */
 
-#if defined(HAVE_OPENCORE_AMRWB_DEC_IF_H) || defined(DL_AMRWB)
+#ifdef DL_OPENCORE_AMRWB
+  #define AMR_OC_FUNC  LSX_DLENTRY_DYNAMIC
+#else
+  #define AMR_OC_FUNC  LSX_DLENTRY_STATIC
+#endif
+
+#if defined(HAVE_OPENCORE_AMRWB_DEC_IF_H) || defined(DL_OPENCORE_AMRWB)
   #define AMR_OPENCORE 1
   #define AMR_OPENCORE_ENABLE_ENCODE 0
 #endif
 
 #define AMR_OPENCORE_FUNC_ENTRIES(f,x) \
-  AMR_FUNC(f,x, void*, D_IF_init,   (void)) \
-  AMR_FUNC(f,x, void,  D_IF_decode, (void* state, const unsigned char* in, short* out, int bfi)) \
-  AMR_FUNC(f,x, void,  D_IF_exit,   (void* state)) \
+  AMR_OC_FUNC(f,x, void*, D_IF_init,   (void)) \
+  AMR_OC_FUNC(f,x, void,  D_IF_decode, (void* state, const unsigned char* in, short* out, int bfi)) \
+  AMR_OC_FUNC(f,x, void,  D_IF_exit,   (void* state)) \
 
 #define AmrDecoderInit() \
   D_IF_init()
@@ -71,7 +71,7 @@
 #define AMR_OPENCORE_DESC "amr-wb OpenCore library"
 static const char* const amr_opencore_library_names[] =
 {
-#ifdef DL_AMRWB
+#ifdef DL_OPENCORE_AMRWB
   "libopencore-amrwb",
   "libopencore-amrwb-0",
 #endif
@@ -80,14 +80,20 @@
 
 /* VO definitions: */
 
-#if defined(HAVE_VO_AMRWBENC_ENC_IF_H) || defined(DL_AMRWB)
+#ifdef DL_VO_AMRWBENC
+  #define AMR_VO_FUNC  LSX_DLENTRY_DYNAMIC
+#else
+  #define AMR_VO_FUNC  LSX_DLENTRY_STATIC
+#endif
+
+#if defined(HAVE_VO_AMRWBENC_ENC_IF_H) || defined(DL_VO_AMRWBENC)
   #define AMR_VO 1
 #endif
 
 #define AMR_VO_FUNC_ENTRIES(f,x) \
-  AMR_FUNC(f,x, void*, E_IF_init,     (void)) \
-  AMR_FUNC(f,x, int,   E_IF_encode,(void* state, int16_t mode, int16_t* in, uint8_t* out, int16_t dtx)) \
-  AMR_FUNC(f,x, void,  E_IF_exit,     (void* state)) \
+  AMR_VO_FUNC(f,x, void*, E_IF_init,     (void)) \
+  AMR_VO_FUNC(f,x, int,   E_IF_encode,(void* state, int16_t mode, int16_t* in, uint8_t* out, int16_t dtx)) \
+  AMR_VO_FUNC(f,x, void,  E_IF_exit,     (void* state)) \
 
 #define AmrEncoderInit() \
   E_IF_init()
@@ -99,7 +105,7 @@
 #define AMR_VO_DESC "amr-wb VisualOn library"
 static const char* const amr_vo_library_names[] =
 {
-#ifdef DL_AMRWB
+#ifdef DL_VO_AMRWBENC
   "libvo-amrwbenc",
   "libvo-amrwbenc-0",
 #endif