build-sys: Make speex library optional

make speex library dependency optional, this affects the resampler
and the echo canceller module

this patch supersedes an earlier patch proposal and addresses the following
comments:
* fix order of pa_echo_canceller_method_t enum and ec_table (Frederic)
* the default resampler is speex if available as before, otherwise ffmpeg (Arun)
* does not touch the Adrian EC implementation (see separate patch) (Arun)
This commit is contained in:
Peter Meerwald 2011-12-11 16:07:41 +01:00 committed by Arun Raghavan
parent 87e6f489a9
commit 5f2286e6f7
5 changed files with 97 additions and 11 deletions

View file

@ -586,10 +586,6 @@ PKG_CHECK_MODULES(LIBSNDFILE, [ sndfile >= 1.0.20 ])
AC_SUBST(LIBSNDFILE_CFLAGS)
AC_SUBST(LIBSNDFILE_LIBS)
PKG_CHECK_MODULES(LIBSPEEX, [ speexdsp >= 1.2 ])
AC_SUBST(LIBSPEEX_CFLAGS)
AC_SUBST(LIBSPEEX_LIBS)
#### atomic-ops ####
AC_MSG_CHECKING([whether we need libatomic_ops])
@ -1053,6 +1049,24 @@ AS_IF([test "x$with_fftw" = "xyes" && test "x$HAVE_FFTW" = "x0"],
AM_CONDITIONAL([HAVE_FFTW], [test "x$HAVE_FFTW" = "x1"])
#### speex (optional) ####
AC_ARG_WITH([speex],
AS_HELP_STRING([--without-speex],[Omit speex (resampling, AEC)]))
AS_IF([test "x$with_speex" != "xno"],
[PKG_CHECK_MODULES(LIBSPEEX, [ speexdsp >= 1.2 ], HAVE_SPEEX=1, HAVE_SPEEX=0)],
HAVE_SPEEX=0)
AS_IF([test "x$with_speex" = "xyes" && test "x$HAVE_SPEEX" = "x0"],
[AC_MSG_ERROR([*** speex support not found])])
AM_CONDITIONAL([HAVE_SPEEX], [test "x$HAVE_SPEEX" = "x1"])
AS_IF([test "x$HAVE_SPEEX" = "x1"], AC_DEFINE([HAVE_SPEEX], 1, [Have speex]))
AC_SUBST(LIBSPEEX_CFLAGS)
AC_SUBST(LIBSPEEX_LIBS)
#### ORC (optional) ####
ORC_CHECK([0.4.11])
@ -1310,6 +1324,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_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)
AS_IF([test "x$HAVE_GDBM" = "x1"], ENABLE_GDBM=yes, ENABLE_GDBM=no)
@ -1357,6 +1372,7 @@ echo "
Enable OpenSSL (for Airtunes): ${ENABLE_OPENSSL}
Enable fftw: ${ENABLE_FFTW}
Enable orc: ${ENABLE_ORC}
Enable speex: ${ENABLE_SPEEX}
Enable WebRTC echo canceller: ${ENABLE_WEBRTC}
Database
tdb: ${ENABLE_TDB}
@ -1397,3 +1413,14 @@ and is thus a critical part of PulseAudio on that platform.
===== WARNING WARNING WARNING WARNING WARNING WARNING WARNING =====
"
fi
if test "${ENABLE_SPEEX}" = "no" && test "x$os_is_win32" != "x1" ; then
echo "
===== WARNING WARNING WARNING WARNING WARNING WARNING WARNING =====
You do not have speex support enabled. It is strongly recommended
that you enable speex support if your platform supports it as it is
the primary method used for audio resampling and is thus a critical
part of PulseAudio on that platform.
===== WARNING WARNING WARNING WARNING WARNING WARNING WARNING =====
"
fi

View file

@ -1745,7 +1745,6 @@ 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/speex.c \
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_LDFLAGS = $(MODULE_LDFLAGS)
@ -1759,6 +1758,9 @@ 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
if HAVE_SPEEX
module_echo_cancel_la_SOURCES += modules/echo-cancel/speex.c
endif
if HAVE_WEBRTC
module_echo_cancel_la_SOURCES += modules/echo-cancel/webrtc.cc
module_echo_cancel_la_CFLAGS += -DHAVE_WEBRTC=1

View file

@ -31,8 +31,11 @@
#include <pulsecore/core.h>
#include <pulsecore/macro.h>
#ifdef HAVE_SPEEX
#include <speex/speex_echo.h>
#include <speex/speex_preprocess.h>
#endif
#include "adrian.h"
/* Common data structures */
@ -43,10 +46,12 @@ typedef struct pa_echo_canceller_params pa_echo_canceller_params;
struct pa_echo_canceller_params {
union {
#ifdef HAVE_SPEEX
struct {
SpeexEchoState *state;
SpeexPreprocessState *pp_state;
} speex;
#endif
struct {
uint32_t blocksize;
AEC *aec;
@ -121,6 +126,7 @@ struct pa_echo_canceller {
void pa_echo_canceller_get_capture_volume(pa_echo_canceller *ec, pa_cvolume *v);
void pa_echo_canceller_set_capture_volume(pa_echo_canceller *ec, pa_cvolume *v);
#ifdef HAVE_SPEEX
/* Speex canceller functions */
pa_bool_t pa_speex_ec_init(pa_core *c, pa_echo_canceller *ec,
pa_sample_spec *source_ss, pa_channel_map *source_map,
@ -128,6 +134,7 @@ pa_bool_t pa_speex_ec_init(pa_core *c, pa_echo_canceller *ec,
uint32_t *blocksize, const char *args);
void pa_speex_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out);
void pa_speex_ec_done(pa_echo_canceller *ec);
#endif
/* Adrian Andre's echo canceller */
pa_bool_t pa_adrian_ec_init(pa_core *c, pa_echo_canceller *ec,

View file

@ -82,7 +82,9 @@ 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,
@ -96,12 +98,14 @@ typedef enum {
#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,
@ -1541,15 +1545,16 @@ 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;
}

View file

@ -29,7 +29,9 @@
#include <samplerate.h>
#endif
#ifdef HAVE_SPEEX
#include <speex/speex_resampler.h>
#endif
#include <pulse/xmalloc.h>
#include <pulsecore/sconv.h>
@ -90,9 +92,11 @@ struct pa_resampler {
} src;
#endif
#ifdef HAVE_SPEEX
struct { /* data specific to speex */
SpeexResamplerState* state;
} speex;
#endif
struct { /* data specific to ffmpeg */
struct AVResampleContext *state;
@ -102,7 +106,9 @@ struct pa_resampler {
static int copy_init(pa_resampler *r);
static int trivial_init(pa_resampler*r);
#ifdef HAVE_SPEEX
static int speex_init(pa_resampler*r);
#endif
static int ffmpeg_init(pa_resampler*r);
static int peaks_init(pa_resampler*r);
#ifdef HAVE_LIBSAMPLERATE
@ -126,6 +132,7 @@ static int (* const init_table[])(pa_resampler*r) = {
[PA_RESAMPLER_SRC_LINEAR] = NULL,
#endif
[PA_RESAMPLER_TRIVIAL] = trivial_init,
#ifdef HAVE_SPEEX
[PA_RESAMPLER_SPEEX_FLOAT_BASE+0] = speex_init,
[PA_RESAMPLER_SPEEX_FLOAT_BASE+1] = speex_init,
[PA_RESAMPLER_SPEEX_FLOAT_BASE+2] = speex_init,
@ -148,6 +155,30 @@ static int (* const init_table[])(pa_resampler*r) = {
[PA_RESAMPLER_SPEEX_FIXED_BASE+8] = speex_init,
[PA_RESAMPLER_SPEEX_FIXED_BASE+9] = speex_init,
[PA_RESAMPLER_SPEEX_FIXED_BASE+10] = speex_init,
#else
[PA_RESAMPLER_SPEEX_FLOAT_BASE+0] = NULL,
[PA_RESAMPLER_SPEEX_FLOAT_BASE+1] = NULL,
[PA_RESAMPLER_SPEEX_FLOAT_BASE+2] = NULL,
[PA_RESAMPLER_SPEEX_FLOAT_BASE+3] = NULL,
[PA_RESAMPLER_SPEEX_FLOAT_BASE+4] = NULL,
[PA_RESAMPLER_SPEEX_FLOAT_BASE+5] = NULL,
[PA_RESAMPLER_SPEEX_FLOAT_BASE+6] = NULL,
[PA_RESAMPLER_SPEEX_FLOAT_BASE+7] = NULL,
[PA_RESAMPLER_SPEEX_FLOAT_BASE+8] = NULL,
[PA_RESAMPLER_SPEEX_FLOAT_BASE+9] = NULL,
[PA_RESAMPLER_SPEEX_FLOAT_BASE+10] = NULL,
[PA_RESAMPLER_SPEEX_FIXED_BASE+0] = NULL,
[PA_RESAMPLER_SPEEX_FIXED_BASE+1] = NULL,
[PA_RESAMPLER_SPEEX_FIXED_BASE+2] = NULL,
[PA_RESAMPLER_SPEEX_FIXED_BASE+3] = NULL,
[PA_RESAMPLER_SPEEX_FIXED_BASE+4] = NULL,
[PA_RESAMPLER_SPEEX_FIXED_BASE+5] = NULL,
[PA_RESAMPLER_SPEEX_FIXED_BASE+6] = NULL,
[PA_RESAMPLER_SPEEX_FIXED_BASE+7] = NULL,
[PA_RESAMPLER_SPEEX_FIXED_BASE+8] = NULL,
[PA_RESAMPLER_SPEEX_FIXED_BASE+9] = NULL,
[PA_RESAMPLER_SPEEX_FIXED_BASE+10] = NULL,
#endif
[PA_RESAMPLER_FFMPEG] = ffmpeg_init,
[PA_RESAMPLER_AUTO] = NULL,
[PA_RESAMPLER_COPY] = copy_init,
@ -195,8 +226,13 @@ pa_resampler* pa_resampler_new(
method = PA_RESAMPLER_AUTO;
}
if (method == PA_RESAMPLER_AUTO)
if (method == PA_RESAMPLER_AUTO) {
#ifdef HAVE_SPEEX
method = PA_RESAMPLER_SPEEX_FLOAT_BASE + 3;
#else
method = PA_RESAMPLER_FFMPEG;
#endif
}
r = pa_xnew(pa_resampler, 1);
r->mempool = pool;
@ -476,6 +512,13 @@ int pa_resample_method_supported(pa_resample_method_t m) {
return 0;
#endif
#ifndef HAVE_SPEEX
if (m >= PA_RESAMPLER_SPEEX_FLOAT_BASE && m <= PA_RESAMPLER_SPEEX_FLOAT_MAX)
return 0;
if (m >= PA_RESAMPLER_SPEEX_FIXED_BASE && m <= PA_RESAMPLER_SPEEX_FIXED_MAX)
return 0;
#endif
return 1;
}
@ -1271,6 +1314,7 @@ static int libsamplerate_init(pa_resampler *r) {
}
#endif
#ifdef HAVE_SPEEX
/*** speex based implementation ***/
static void speex_resample_float(pa_resampler *r, const pa_memchunk *input, unsigned in_n_frames, pa_memchunk *output, unsigned *out_n_frames) {
@ -1364,6 +1408,7 @@ static int speex_init(pa_resampler *r) {
return 0;
}
#endif
/* Trivial implementation */