[pulseaudio-discuss] [PATCH v2] make Adrian's echo cancellation code optional

Peter Meerwald pmeerw at pmeerw.net
Sun Dec 11 07:07:42 PST 2011


From: Peter Meerwald <p.meerwald at bct-electronic.com>

makes the Adrian echo canceller implementation optional at compile time

this patch supersedes an earlier patch proposal and addresses the following
comments:
* separate patch from speex dependency rework (Arun)
* check that at least one EC implementation is available (Arun)
* properly align yes/no in configure summary for Adrian (Frederic)

---
 configure.ac                                 |   15 ++++++++++++++-
 src/Makefile.am                              |   10 +++++++---
 src/modules/echo-cancel/echo-cancel.h        |    4 ++++
 src/modules/echo-cancel/module-echo-cancel.c |    8 +++++++-
 4 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index ac7dcbf..0009c17 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1176,7 +1176,14 @@ AC_SUBST(WEBRTC_CFLAGS)
 AC_SUBST(WEBRTC_LIBS)
 AM_CONDITIONAL([HAVE_WEBRTC], [test "x$HAVE_WEBRTC" = "x1"])
 
+AC_ARG_ENABLE([adrian-aec],
+    AS_HELP_STRING([--enable-adrian-aec], [Enable Adrian's optional echo canceller]))
+AS_IF([test "x$enable_adrian_aec" != "xno"],
+    [HAVE_ADRIAN_EC=1])
+AM_CONDITIONAL([HAVE_ADRIAN_EC], [test "x$HAVE_ADRIAN_EC" = "x1"])
+
+

 ###################################
 #            Output               #
 ###################################
@@ -1322,6 +1329,7 @@ AS_IF([test "x$HAVE_IPV6" = "x1"], ENABLE_IPV6=yes, ENABLE_IPV6=no)
 AS_IF([test "x$HAVE_OPENSSL" = "x1"], ENABLE_OPENSSL=yes, ENABLE_OPENSSL=no)
 AS_IF([test "x$HAVE_FFTW" = "x1"], ENABLE_FFTW=yes, ENABLE_FFTW=no)
 AS_IF([test "x$HAVE_ORC" = "xyes"], ENABLE_ORC=yes, ENABLE_ORC=no)
+AS_IF([test "x$HAVE_ADRIAN_EC" = "x1"], ENABLE_ADRIAN_EC=yes, ENABLE_ADRIAN_EC=no)
 AS_IF([test "x$HAVE_SPEEX" = "x1"], ENABLE_SPEEX=yes, ENABLE_SPEEX=no)
 AS_IF([test "x$HAVE_WEBRTC" = "x1"], ENABLE_WEBRTC=yes, ENABLE_WEBRTC=no)
 AS_IF([test "x$HAVE_TDB" = "x1"], ENABLE_TDB=yes, ENABLE_TDB=no)
@@ -1370,7 +1378,8 @@ echo "
     Enable OpenSSL (for Airtunes): ${ENABLE_OPENSSL}
     Enable fftw:                   ${ENABLE_FFTW}
     Enable orc:                    ${ENABLE_ORC}
-    Enable speex:                  ${ENABLE_SPEEX}
+    Enable Adrian echo canceller:  ${ENABLE_ADRIAN_EC}
+    Enable speex (resampler, AEC): ${ENABLE_SPEEX}
     Enable WebRTC echo canceller:  ${ENABLE_WEBRTC}
     Database
       tdb:                         ${ENABLE_TDB}
@@ -1388,6 +1397,10 @@ echo "
     Legacy Database Entry Support: ${ENABLE_LEGACY_DATABASE_ENTRY_FORMAT}
 "
 
+if test "${ENABLE_SPEEX}" = "no" && test "${ENABLE_WEBRTC}" = "no" && test "${ENABLE_ADRIAN_EC}" = "no" ; then
+AC_MSG_ERROR([At least one echo canceller implementation must be available.])
+fi
+
 if test "${ENABLE_DBUS}" = "no" && test "x$os_is_win32" != "x1" ; then
    echo "
 ===== WARNING WARNING WARNING WARNING WARNING WARNING WARNING =====
diff --git a/src/Makefile.am b/src/Makefile.am
index 852e962..649f82f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1744,12 +1744,15 @@ module_suspend_on_idle_la_CFLAGS = $(AM_CFLAGS)
 
 # echo-cancel module
 module_echo_cancel_la_SOURCES = \
-		modules/echo-cancel/module-echo-cancel.c modules/echo-cancel/echo-cancel.h \
-		modules/echo-cancel/adrian-aec.c modules/echo-cancel/adrian-aec.h \
-		modules/echo-cancel/adrian.c modules/echo-cancel/adrian.h
+		modules/echo-cancel/module-echo-cancel.c modules/echo-cancel/echo-cancel.h
 module_echo_cancel_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_echo_cancel_la_LIBADD = $(MODULE_LIBADD) $(LIBSPEEX_LIBS)
 module_echo_cancel_la_CFLAGS = $(AM_CFLAGS) $(SERVER_CFLAGS) $(LIBSPEEX_CFLAGS)
+if HAVE_ADRIAN_EC
+module_echo_cancel_la_SOURCES += \
+		modules/echo-cancel/adrian-aec.c modules/echo-cancel/adrian-aec.h \
+		modules/echo-cancel/adrian.c modules/echo-cancel/adrian.h
+module_echo_cancel_la_CFLAGS += -DHAVE_ADRIAN_EC=1
 if HAVE_ORC
 ORC_SOURCE += modules/echo-cancel/adrian-aec
 nodist_module_echo_cancel_la_SOURCES = \
@@ -1758,6 +1761,7 @@ nodist_module_echo_cancel_la_SOURCES = \
 module_echo_cancel_la_LIBADD += $(ORC_LIBS)
 module_echo_cancel_la_CFLAGS += $(ORC_CFLAGS) -I$(top_builddir)/src/modules/echo-cancel
 endif
+endif
 if HAVE_SPEEX
 module_echo_cancel_la_SOURCES += modules/echo-cancel/speex.c
 endif
diff --git a/src/modules/echo-cancel/echo-cancel.h b/src/modules/echo-cancel/echo-cancel.h
index 15d44f5..870d163 100644
--- a/src/modules/echo-cancel/echo-cancel.h
+++ b/src/modules/echo-cancel/echo-cancel.h
@@ -52,10 +52,12 @@ struct pa_echo_canceller_params {
             SpeexPreprocessState *pp_state;
         } speex;
 #endif
+#ifdef HAVE_ADRIAN_EC
         struct {
             uint32_t blocksize;
             AEC *aec;
         } adrian;
+#endif
 #ifdef HAVE_WEBRTC
         struct {
             /* This is a void* so that we don't have to convert this whole file
@@ -136,6 +138,7 @@ void pa_speex_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *p
 void pa_speex_ec_done(pa_echo_canceller *ec);
 #endif
 
+#ifdef HAVE_ADRIAN_EC
 /* Adrian Andre's echo canceller */
 pa_bool_t pa_adrian_ec_init(pa_core *c, pa_echo_canceller *ec,
                            pa_sample_spec *source_ss, pa_channel_map *source_map,
@@ -143,6 +146,7 @@ pa_bool_t pa_adrian_ec_init(pa_core *c, pa_echo_canceller *ec,
                            uint32_t *blocksize, const char *args);
 void pa_adrian_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out);
 void pa_adrian_ec_done(pa_echo_canceller *ec);
+#endif
 
 #ifdef HAVE_WEBRTC
 /* WebRTC canceller functions */
diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index 0640afc..5c7bb78 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -85,7 +85,9 @@ typedef enum {
 #ifdef HAVE_SPEEX
     PA_ECHO_CANCELLER_SPEEX,
 #endif
+#ifdef HAVE_ADRIAN_EC
     PA_ECHO_CANCELLER_ADRIAN,
+#endif
 #ifdef HAVE_WEBRTC
     PA_ECHO_CANCELLER_WEBRTC,
 #endif
@@ -106,12 +108,14 @@ static const pa_echo_canceller ec_table[] = {
         .done                   = pa_speex_ec_done,
     },
 #endif
+#ifdef HAVE_ADRIAN_EC
     {
         /* Adrian Andre's NLMS implementation */
         .init                   = pa_adrian_ec_init,
         .run                    = pa_adrian_ec_run,
         .done                   = pa_adrian_ec_done,
     },
+#endif
 #ifdef HAVE_WEBRTC
     {
         /* WebRTC's audio processing engine */
@@ -1549,13 +1553,15 @@ static pa_echo_canceller_method_t get_ec_method_from_string(const char *method)
     if (pa_streq(method, "speex"))
         return PA_ECHO_CANCELLER_SPEEX;
 #endif
+#ifdef HAVE_ADRIAN_EC
     if (pa_streq(method, "adrian"))
         return PA_ECHO_CANCELLER_ADRIAN;
+#endif
 #ifdef HAVE_WEBRTC
     if (pa_streq(method, "webrtc"))
         return PA_ECHO_CANCELLER_WEBRTC;
 #endif
     return PA_ECHO_CANCELLER_INVALID;
 }
 
 /* Common initialisation bits between module-echo-cancel and the standalone test program */
-- 
1.7.4.1



More information about the pulseaudio-discuss mailing list