]> code.delx.au - pulseaudio/blobdiff - src/modules/echo-cancel/module-echo-cancel.c
build-sys: Make speex library optional
[pulseaudio] / src / modules / echo-cancel / module-echo-cancel.c
index b810a4edad258e3b4d96799f5101849c6718c4ac..9f3e85c96ed08360cb20f327e16eb56a18d09e51 100644 (file)
@@ -82,26 +82,30 @@ PA_MODULE_USAGE(
 /* NOTE: Make sure the enum and ec_table are maintained in the correct order */
 typedef enum {
     PA_ECHO_CANCELLER_INVALID = -1,
-    PA_ECHO_CANCELLER_SPEEX = 0,
+#ifdef HAVE_SPEEX
+    PA_ECHO_CANCELLER_SPEEX,
+#endif
     PA_ECHO_CANCELLER_ADRIAN,
 #ifdef HAVE_WEBRTC
     PA_ECHO_CANCELLER_WEBRTC,
 #endif
 } pa_echo_canceller_method_t;
 
-#if HAVE_WEBRTC
+#ifdef HAVE_WEBRTC
 #define DEFAULT_ECHO_CANCELLER "webrtc"
 #else
 #define DEFAULT_ECHO_CANCELLER "speex"
 #endif
 
 static const pa_echo_canceller ec_table[] = {
+#ifdef HAVE_SPEEX
     {
         /* Speex */
         .init                   = pa_speex_ec_init,
         .run                    = pa_speex_ec_run,
         .done                   = pa_speex_ec_done,
     },
+#endif
     {
         /* Adrian Andre's NLMS implementation */
         .init                   = pa_adrian_ec_init,
@@ -1399,7 +1403,7 @@ static pa_bool_t source_output_may_move_to_cb(pa_source_output *o, pa_source *de
     pa_assert_ctl_context();
     pa_assert_se(u = o->userdata);
 
-    if (u->dead)
+    if (u->dead || u->autoloaded)
         return FALSE;
 
     return (u->source != dest) && (u->sink != dest->monitor_of);
@@ -1412,7 +1416,7 @@ static pa_bool_t sink_input_may_move_to_cb(pa_sink_input *i, pa_sink *dest) {
     pa_sink_input_assert_ref(i);
     pa_assert_se(u = i->userdata);
 
-    if (u->dead)
+    if (u->dead || u->autoloaded)
         return FALSE;
 
     return u->sink != dest;
@@ -1541,16 +1545,17 @@ void pa_echo_canceller_set_capture_volume(pa_echo_canceller *ec, pa_cvolume *v)
 }
 
 static pa_echo_canceller_method_t get_ec_method_from_string(const char *method) {
+#ifdef HAVE_SPEEX
     if (pa_streq(method, "speex"))
         return PA_ECHO_CANCELLER_SPEEX;
-    else if (pa_streq(method, "adrian"))
+#endif
+    if (pa_streq(method, "adrian"))
         return PA_ECHO_CANCELLER_ADRIAN;
 #ifdef HAVE_WEBRTC
-    else if (pa_streq(method, "webrtc"))
+    if (pa_streq(method, "webrtc"))
         return PA_ECHO_CANCELLER_WEBRTC;
 #endif
-    else
-        return PA_ECHO_CANCELLER_INVALID;
+    return PA_ECHO_CANCELLER_INVALID;
 }
 
 /* Common initialisation bits between module-echo-cancel and the standalone test program */
@@ -2036,12 +2041,6 @@ int main(int argc, char* argv[]) {
         goto usage;
     }
 
-    u.ec = pa_xnew0(pa_echo_canceller, 1);
-    if (!u.ec) {
-        pa_log("Failed to alloc echo canceller");
-        goto fail;
-    }
-
     u.captured_file = fopen(argv[2], "r");
     if (u.captured_file == NULL) {
         perror ("fopen failed");